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 | |
Gilad Arnold | 1b9d6ae | 2014-03-03 13:46:07 -0800 | [diff] [blame^] | 8 | #include "update_engine/system_state.h" |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 9 | |
Gilad Arnold | 1b9d6ae | 2014-03-03 13:46:07 -0800 | [diff] [blame^] | 10 | #include "update_engine/clock.h" |
| 11 | #include "update_engine/connection_manager.h" |
| 12 | #include "update_engine/gpio_handler.h" |
| 13 | #include "update_engine/hardware.h" |
| 14 | #include "update_engine/payload_state.h" |
| 15 | #include "update_engine/prefs.h" |
| 16 | #include "update_engine/real_dbus_wrapper.h" |
| 17 | #include "update_engine/update_attempter.h" |
| 18 | #include "update_engine/p2p_manager.h" |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 19 | |
| 20 | namespace chromeos_update_engine { |
| 21 | |
| 22 | // A real implementation of the SystemStateInterface which is |
| 23 | // used by the actual product code. |
| 24 | class RealSystemState : public SystemState { |
| 25 | public: |
| 26 | // Constructors and destructors. |
| 27 | RealSystemState(); |
| 28 | virtual ~RealSystemState() {} |
| 29 | |
David Zeuthen | 639aa36 | 2014-02-03 16:23:44 -0800 | [diff] [blame] | 30 | virtual bool IsOOBEComplete(base::Time* out_time_of_oobe); |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 31 | |
| 32 | virtual inline void set_device_policy( |
| 33 | const policy::DevicePolicy* device_policy) { |
| 34 | device_policy_ = device_policy; |
| 35 | } |
| 36 | |
| 37 | virtual inline const policy::DevicePolicy* device_policy() const { |
| 38 | return device_policy_; |
| 39 | } |
| 40 | |
David Zeuthen | f413fe5 | 2013-04-22 14:04:39 -0700 | [diff] [blame] | 41 | virtual inline ClockInterface* clock() { |
| 42 | return &clock_; |
| 43 | } |
| 44 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 45 | virtual inline ConnectionManager* connection_manager() { |
| 46 | return &connection_manager_; |
| 47 | } |
| 48 | |
Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 49 | virtual inline HardwareInterface* hardware() { |
| 50 | return &hardware_; |
| 51 | } |
| 52 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 53 | virtual inline MetricsLibraryInterface* metrics_lib() { |
| 54 | return &metrics_lib_; |
| 55 | } |
| 56 | |
| 57 | virtual inline PrefsInterface* prefs() { |
| 58 | return &prefs_; |
| 59 | } |
| 60 | |
Chris Sosa | aa18e16 | 2013-06-20 13:20:30 -0700 | [diff] [blame] | 61 | virtual inline PrefsInterface* powerwash_safe_prefs() { |
| 62 | return &powerwash_safe_prefs_; |
| 63 | } |
| 64 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 65 | virtual inline PayloadStateInterface* payload_state() { |
| 66 | return &payload_state_; |
| 67 | } |
| 68 | |
| 69 | virtual inline GpioHandler* gpio_handler() const { |
| 70 | return gpio_handler_.get(); |
| 71 | } |
| 72 | |
| 73 | virtual inline UpdateAttempter* update_attempter() { |
| 74 | return update_attempter_.get(); |
| 75 | } |
| 76 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 77 | // Returns a pointer to the object that stores the parameters that are |
| 78 | // common to all Omaha requests. |
| 79 | virtual inline OmahaRequestParams* request_params() { |
| 80 | return &request_params_; |
| 81 | } |
| 82 | |
David Zeuthen | 526cb58 | 2013-08-06 12:26:18 -0700 | [diff] [blame] | 83 | virtual inline P2PManager* p2p_manager() { |
| 84 | return p2p_manager_.get(); |
| 85 | } |
| 86 | |
Chris Sosa | be45bef | 2013-04-09 18:25:12 -0700 | [diff] [blame] | 87 | virtual inline bool system_rebooted(){ |
| 88 | return system_rebooted_; |
| 89 | } |
| 90 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 91 | // Initializes this concrete object. Other methods should be invoked only |
| 92 | // if the object has been initialized successfully. |
| 93 | bool Initialize(bool enable_gpio); |
| 94 | |
| 95 | private: |
David Zeuthen | f413fe5 | 2013-04-22 14:04:39 -0700 | [diff] [blame] | 96 | // Interface for the clock. |
| 97 | Clock clock_; |
| 98 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 99 | // The latest device policy object from the policy provider. |
| 100 | const policy::DevicePolicy* device_policy_; |
| 101 | |
| 102 | // The connection manager object that makes download |
| 103 | // decisions depending on the current type of connection. |
| 104 | ConnectionManager connection_manager_; |
| 105 | |
Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 106 | // Interface for the hardware functions. |
| 107 | Hardware hardware_; |
| 108 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 109 | // The Metrics Library interface for reporting UMA stats. |
| 110 | MetricsLibrary metrics_lib_; |
| 111 | |
| 112 | // Interface for persisted store. |
| 113 | Prefs prefs_; |
| 114 | |
Chris Sosa | aa18e16 | 2013-06-20 13:20:30 -0700 | [diff] [blame] | 115 | // Interface for persisted store that persists across powerwashes. |
| 116 | Prefs powerwash_safe_prefs_; |
| 117 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 118 | // All state pertaining to payload state such as |
| 119 | // response, URL, backoff states. |
| 120 | PayloadState payload_state_; |
| 121 | |
| 122 | // Pointer to a GPIO handler and other needed modules (note that the order of |
| 123 | // declaration significant for destruction, as the latter depends on the |
| 124 | // former). |
| 125 | scoped_ptr<UdevInterface> udev_iface_; |
| 126 | scoped_ptr<FileDescriptor> file_descriptor_; |
| 127 | scoped_ptr<GpioHandler> gpio_handler_; |
| 128 | |
| 129 | // The dbus object used to initialize the update attempter. |
Gilad Arnold | 1b9d6ae | 2014-03-03 13:46:07 -0800 | [diff] [blame^] | 130 | RealDBusWrapper dbus_; |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 131 | |
| 132 | // Pointer to the update attempter object. |
| 133 | scoped_ptr<UpdateAttempter> update_attempter_; |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 134 | |
| 135 | // Common parameters for all Omaha requests. |
| 136 | OmahaRequestParams request_params_; |
Chris Sosa | be45bef | 2013-04-09 18:25:12 -0700 | [diff] [blame] | 137 | |
David Zeuthen | 526cb58 | 2013-08-06 12:26:18 -0700 | [diff] [blame] | 138 | scoped_ptr<P2PManager> p2p_manager_; |
| 139 | |
Chris Sosa | be45bef | 2013-04-09 18:25:12 -0700 | [diff] [blame] | 140 | // If true, this is the first instance of the update engine since the system |
| 141 | // rebooted. Important for tracking whether you are running instance of the |
| 142 | // update engine on first boot or due to a crash/restart. |
| 143 | bool system_rebooted_; |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | } // namespace chromeos_update_engine |
| 147 | |
| 148 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_REAL_SYSTEM_STATE_H_ |