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 | |
| 8 | #include <policy/device_policy.h> |
| 9 | #include <policy/libpolicy.h> |
| 10 | |
| 11 | #include <update_engine/connection_manager.h> |
| 12 | |
| 13 | namespace chromeos_update_engine { |
| 14 | |
| 15 | // An interface to global system context, including platform resources, |
| 16 | // the current state of the system, high-level objects, system interfaces, etc. |
| 17 | // Carved out separately so it can be mocked for unit tests. |
| 18 | // Currently it has only one method, but we should start migrating other |
| 19 | // methods to use this as and when needed to unit test them. |
| 20 | // TODO (jaysri): Consider renaming this to something like GlobalContext. |
| 21 | class SystemState { |
| 22 | public: |
| 23 | // Destructs this object. |
| 24 | virtual ~SystemState() {} |
| 25 | |
| 26 | // Returns true if the OOBE process has been completed and EULA accepted. |
| 27 | // False otherwise. |
| 28 | virtual bool IsOOBEComplete() = 0; |
| 29 | |
| 30 | // Sets or gets the latest device policy. |
| 31 | virtual void SetDevicePolicy(const policy::DevicePolicy* device_policy) = 0; |
| 32 | virtual const policy::DevicePolicy* GetDevicePolicy() const = 0; |
| 33 | |
| 34 | // Gets the connection manager object. |
| 35 | virtual ConnectionManager* GetConnectionManager() = 0; |
| 36 | }; |
| 37 | |
| 38 | // A real implementation of the SystemStateInterface which is |
| 39 | // used by the actual product code. |
| 40 | class RealSystemState : public SystemState { |
| 41 | public: |
| 42 | // Constructors and destructors. |
| 43 | RealSystemState(); |
| 44 | virtual ~RealSystemState() {} |
| 45 | |
| 46 | virtual bool IsOOBEComplete(); |
| 47 | |
| 48 | virtual void SetDevicePolicy(const policy::DevicePolicy* device_policy); |
| 49 | virtual const policy::DevicePolicy* GetDevicePolicy() const; |
| 50 | |
| 51 | virtual ConnectionManager* GetConnectionManager(); |
| 52 | |
| 53 | private: |
| 54 | // The latest device policy object from the policy provider. |
| 55 | const policy::DevicePolicy* device_policy_; |
| 56 | |
| 57 | // The connection manager object that makes download |
| 58 | // decisions depending on the current type of connection. |
| 59 | ConnectionManager connection_manager_; |
| 60 | }; |
| 61 | |
| 62 | } // namespace chromeos_update_engine |
| 63 | |
| 64 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H_ |