Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 1 | // Copyright (c) 2013 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_REAL_SYSTEM_STATE_H_ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_REAL_SYSTEM_STATE_H_ |
| 7 | |
| 8 | #include <update_engine/system_state.h> |
| 9 | |
| 10 | #include <update_engine/connection_manager.h> |
| 11 | #include <update_engine/gpio_handler.h> |
| 12 | #include <update_engine/payload_state.h> |
| 13 | #include <update_engine/prefs.h> |
| 14 | #include <update_engine/update_attempter.h> |
| 15 | |
| 16 | namespace chromeos_update_engine { |
| 17 | |
| 18 | // A real implementation of the SystemStateInterface which is |
| 19 | // used by the actual product code. |
| 20 | class RealSystemState : public SystemState { |
| 21 | public: |
| 22 | // Constructors and destructors. |
| 23 | RealSystemState(); |
| 24 | virtual ~RealSystemState() {} |
| 25 | |
| 26 | virtual bool IsOOBEComplete(); |
| 27 | |
| 28 | virtual inline void set_device_policy( |
| 29 | const policy::DevicePolicy* device_policy) { |
| 30 | device_policy_ = device_policy; |
| 31 | } |
| 32 | |
| 33 | virtual inline const policy::DevicePolicy* device_policy() const { |
| 34 | return device_policy_; |
| 35 | } |
| 36 | |
| 37 | virtual inline ConnectionManager* connection_manager() { |
| 38 | return &connection_manager_; |
| 39 | } |
| 40 | |
| 41 | virtual inline MetricsLibraryInterface* metrics_lib() { |
| 42 | return &metrics_lib_; |
| 43 | } |
| 44 | |
| 45 | virtual inline PrefsInterface* prefs() { |
| 46 | return &prefs_; |
| 47 | } |
| 48 | |
| 49 | virtual inline PayloadStateInterface* payload_state() { |
| 50 | return &payload_state_; |
| 51 | } |
| 52 | |
| 53 | virtual inline GpioHandler* gpio_handler() const { |
| 54 | return gpio_handler_.get(); |
| 55 | } |
| 56 | |
| 57 | virtual inline UpdateAttempter* update_attempter() { |
| 58 | return update_attempter_.get(); |
| 59 | } |
| 60 | |
| 61 | // Initializes this concrete object. Other methods should be invoked only |
| 62 | // if the object has been initialized successfully. |
| 63 | bool Initialize(bool enable_gpio); |
| 64 | |
| 65 | private: |
| 66 | // The latest device policy object from the policy provider. |
| 67 | const policy::DevicePolicy* device_policy_; |
| 68 | |
| 69 | // The connection manager object that makes download |
| 70 | // decisions depending on the current type of connection. |
| 71 | ConnectionManager connection_manager_; |
| 72 | |
| 73 | // The Metrics Library interface for reporting UMA stats. |
| 74 | MetricsLibrary metrics_lib_; |
| 75 | |
| 76 | // Interface for persisted store. |
| 77 | Prefs prefs_; |
| 78 | |
| 79 | // All state pertaining to payload state such as |
| 80 | // response, URL, backoff states. |
| 81 | PayloadState payload_state_; |
| 82 | |
| 83 | // Pointer to a GPIO handler and other needed modules (note that the order of |
| 84 | // declaration significant for destruction, as the latter depends on the |
| 85 | // former). |
| 86 | scoped_ptr<UdevInterface> udev_iface_; |
| 87 | scoped_ptr<FileDescriptor> file_descriptor_; |
| 88 | scoped_ptr<GpioHandler> gpio_handler_; |
| 89 | |
| 90 | // The dbus object used to initialize the update attempter. |
| 91 | ConcreteDbusGlib dbus_; |
| 92 | |
| 93 | // Pointer to the update attempter object. |
| 94 | scoped_ptr<UpdateAttempter> update_attempter_; |
| 95 | }; |
| 96 | |
| 97 | } // namespace chromeos_update_engine |
| 98 | |
| 99 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_REAL_SYSTEM_STATE_H_ |