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 | |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame^] | 8 | #include <base/time/time.h> |
Jay Srinivasan | f057205 | 2012-10-23 18:12:56 -0700 | [diff] [blame] | 9 | #include "metrics/metrics_library.h" |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 10 | #include <policy/device_policy.h> |
| 11 | #include <policy/libpolicy.h> |
| 12 | |
Gilad Arnold | f3815bb | 2013-01-14 11:58:24 -0800 | [diff] [blame] | 13 | #include "update_engine/gpio_handler.h" |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 14 | #include "update_engine/omaha_request_params.h" |
Gilad Arnold | f3815bb | 2013-01-14 11:58:24 -0800 | [diff] [blame] | 15 | |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 16 | namespace chromeos_update_engine { |
| 17 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 18 | // SystemState is the root class within the update engine. So we should avoid |
| 19 | // any circular references in header file inclusion. Hence forward-declaring |
| 20 | // the required classes. |
David Zeuthen | f413fe5 | 2013-04-22 14:04:39 -0700 | [diff] [blame] | 21 | class ClockInterface; |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 22 | class ConnectionManager; |
Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 23 | class HardwareInterface; |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 24 | class PrefsInterface; |
| 25 | class PayloadStateInterface; |
| 26 | class GpioHandler; |
| 27 | class UpdateAttempter; |
David Zeuthen | 526cb58 | 2013-08-06 12:26:18 -0700 | [diff] [blame] | 28 | class P2PManager; |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 29 | |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 30 | // An interface to global system context, including platform resources, |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 31 | // the current state of the system, high-level objects whose lifetime is same |
| 32 | // as main, system interfaces, etc. |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 33 | // Carved out separately so it can be mocked for unit tests. |
| 34 | // Currently it has only one method, but we should start migrating other |
| 35 | // methods to use this as and when needed to unit test them. |
| 36 | // TODO (jaysri): Consider renaming this to something like GlobalContext. |
| 37 | class SystemState { |
| 38 | public: |
| 39 | // Destructs this object. |
| 40 | virtual ~SystemState() {} |
| 41 | |
David Zeuthen | 639aa36 | 2014-02-03 16:23:44 -0800 | [diff] [blame] | 42 | // Returns true if the OOBE process has been completed and EULA |
| 43 | // accepted, False otherwise. If True is returned, the time-stamp |
| 44 | // of when OOBE happened is returned in |out_time_of_oobe|. |
| 45 | virtual bool IsOOBEComplete(base::Time* out_time_of_oobe) = 0; |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 46 | |
| 47 | // Sets or gets the latest device policy. |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 48 | virtual void set_device_policy(const policy::DevicePolicy* device_policy) = 0; |
| 49 | virtual const policy::DevicePolicy* device_policy() const = 0; |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 50 | |
David Zeuthen | f413fe5 | 2013-04-22 14:04:39 -0700 | [diff] [blame] | 51 | // Gets the interface object for the clock. |
| 52 | virtual ClockInterface* clock() = 0; |
| 53 | |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 54 | // Gets the connection manager object. |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 55 | virtual ConnectionManager* connection_manager() = 0; |
Jay Srinivasan | f057205 | 2012-10-23 18:12:56 -0700 | [diff] [blame] | 56 | |
Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 57 | // Gets the hardware interface object. |
| 58 | virtual HardwareInterface* hardware() = 0; |
| 59 | |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 60 | // Gets the Metrics Library interface for reporting UMA stats. |
Jay Srinivasan | f057205 | 2012-10-23 18:12:56 -0700 | [diff] [blame] | 61 | virtual MetricsLibraryInterface* metrics_lib() = 0; |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 62 | |
| 63 | // Gets the interface object for persisted store. |
| 64 | virtual PrefsInterface* prefs() = 0; |
| 65 | |
Chris Sosa | aa18e16 | 2013-06-20 13:20:30 -0700 | [diff] [blame] | 66 | // Gets the interface object for the persisted store that persists across |
| 67 | // powerwashes. Please note that this should be used very seldomly and must |
| 68 | // be forwards and backwards compatible as powerwash is used to go back and |
| 69 | // forth in system versions. |
| 70 | virtual PrefsInterface* powerwash_safe_prefs() = 0; |
| 71 | |
Jay Srinivasan | 2b5a0f0 | 2012-12-19 17:25:56 -0800 | [diff] [blame] | 72 | // Gets the interface for the payload state object. |
| 73 | virtual PayloadStateInterface* payload_state() = 0; |
Gilad Arnold | bf7919b | 2013-01-08 13:07:37 -0800 | [diff] [blame] | 74 | |
| 75 | // Returns a pointer to the GPIO handler. |
| 76 | virtual GpioHandler* gpio_handler() const = 0; |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 77 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 78 | // Returns a pointer to the update attempter object. |
| 79 | virtual UpdateAttempter* update_attempter() = 0; |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 80 | |
| 81 | // Returns a pointer to the object that stores the parameters that are |
| 82 | // common to all Omaha requests. |
| 83 | virtual OmahaRequestParams* request_params() = 0; |
Chris Sosa | be45bef | 2013-04-09 18:25:12 -0700 | [diff] [blame] | 84 | |
David Zeuthen | 526cb58 | 2013-08-06 12:26:18 -0700 | [diff] [blame] | 85 | // Returns a pointer to the P2PManager singleton. |
| 86 | virtual P2PManager* p2p_manager() = 0; |
| 87 | |
Chris Sosa | be45bef | 2013-04-09 18:25:12 -0700 | [diff] [blame] | 88 | // If true, this is the first instance of the update engine since the system |
| 89 | // restarted. Important for tracking whether you are running instance of the |
| 90 | // update engine on first boot or due to a crash/restart. |
| 91 | virtual bool system_rebooted() = 0; |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | } // namespace chromeos_update_engine |
| 95 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 96 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_SYSTEM_STATE_H_ |