Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_SYSTEM_STATE_H_ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_SYSTEM_STATE_H_ |
| 7 | |
Jay Srinivasan | f057205 | 2012-10-23 18:12:56 -0700 | [diff] [blame^] | 8 | #include "metrics/metrics_library.h" |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 9 | #include <policy/device_policy.h> |
| 10 | #include <policy/libpolicy.h> |
| 11 | |
| 12 | #include <update_engine/connection_manager.h> |
| 13 | |
| 14 | namespace chromeos_update_engine { |
| 15 | |
| 16 | // An interface to global system context, including platform resources, |
| 17 | // the current state of the system, high-level objects, system interfaces, etc. |
| 18 | // Carved out separately so it can be mocked for unit tests. |
| 19 | // Currently it has only one method, but we should start migrating other |
| 20 | // methods to use this as and when needed to unit test them. |
| 21 | // TODO (jaysri): Consider renaming this to something like GlobalContext. |
| 22 | class SystemState { |
| 23 | public: |
| 24 | // Destructs this object. |
| 25 | virtual ~SystemState() {} |
| 26 | |
| 27 | // Returns true if the OOBE process has been completed and EULA accepted. |
| 28 | // False otherwise. |
| 29 | virtual bool IsOOBEComplete() = 0; |
| 30 | |
| 31 | // Sets or gets the latest device policy. |
| 32 | virtual void SetDevicePolicy(const policy::DevicePolicy* device_policy) = 0; |
| 33 | virtual const policy::DevicePolicy* GetDevicePolicy() const = 0; |
| 34 | |
| 35 | // Gets the connection manager object. |
| 36 | virtual ConnectionManager* GetConnectionManager() = 0; |
Jay Srinivasan | f057205 | 2012-10-23 18:12:56 -0700 | [diff] [blame^] | 37 | |
| 38 | // Sets or gets the Metrics Library interface for reporting UMA stats. |
| 39 | virtual void set_metrics_lib(MetricsLibraryInterface* metrics_lib) = 0; |
| 40 | virtual MetricsLibraryInterface* metrics_lib() = 0; |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | // A real implementation of the SystemStateInterface which is |
| 44 | // used by the actual product code. |
| 45 | class RealSystemState : public SystemState { |
| 46 | public: |
| 47 | // Constructors and destructors. |
| 48 | RealSystemState(); |
| 49 | virtual ~RealSystemState() {} |
| 50 | |
| 51 | virtual bool IsOOBEComplete(); |
| 52 | |
| 53 | virtual void SetDevicePolicy(const policy::DevicePolicy* device_policy); |
| 54 | virtual const policy::DevicePolicy* GetDevicePolicy() const; |
| 55 | |
| 56 | virtual ConnectionManager* GetConnectionManager(); |
| 57 | |
Jay Srinivasan | f057205 | 2012-10-23 18:12:56 -0700 | [diff] [blame^] | 58 | virtual void set_metrics_lib(MetricsLibraryInterface* metrics_lib); |
| 59 | virtual MetricsLibraryInterface* metrics_lib(); |
| 60 | |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 61 | private: |
| 62 | // The latest device policy object from the policy provider. |
| 63 | const policy::DevicePolicy* device_policy_; |
| 64 | |
| 65 | // The connection manager object that makes download |
| 66 | // decisions depending on the current type of connection. |
| 67 | ConnectionManager connection_manager_; |
Jay Srinivasan | f057205 | 2012-10-23 18:12:56 -0700 | [diff] [blame^] | 68 | |
| 69 | // The Metrics Library interface for reporting UMA stats. |
| 70 | MetricsLibraryInterface* metrics_lib_; |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | } // namespace chromeos_update_engine |
| 74 | |
| 75 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H_ |