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