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 | |
Jay Srinivasan | f057205 | 2012-10-23 18:12:56 -0700 | [diff] [blame] | 8 | #include "metrics/metrics_library.h" |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 9 | #include <policy/device_policy.h> |
| 10 | #include <policy/libpolicy.h> |
| 11 | |
Gilad Arnold | f3815bb | 2013-01-14 11:58:24 -0800 | [diff] [blame] | 12 | #include "update_engine/gpio_handler.h" |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 13 | #include "update_engine/omaha_request_params.h" |
Gilad Arnold | f3815bb | 2013-01-14 11:58:24 -0800 | [diff] [blame] | 14 | |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 15 | namespace chromeos_update_engine { |
| 16 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 17 | // SystemState is the root class within the update engine. So we should avoid |
| 18 | // any circular references in header file inclusion. Hence forward-declaring |
| 19 | // the required classes. |
David Zeuthen | f413fe5 | 2013-04-22 14:04:39 -0700 | [diff] [blame] | 20 | class ClockInterface; |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 21 | class ConnectionManager; |
| 22 | class PrefsInterface; |
| 23 | class PayloadStateInterface; |
| 24 | class GpioHandler; |
| 25 | class UpdateAttempter; |
| 26 | |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 27 | // An interface to global system context, including platform resources, |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 28 | // the current state of the system, high-level objects whose lifetime is same |
| 29 | // as main, system interfaces, etc. |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 30 | // Carved out separately so it can be mocked for unit tests. |
| 31 | // Currently it has only one method, but we should start migrating other |
| 32 | // methods to use this as and when needed to unit test them. |
| 33 | // TODO (jaysri): Consider renaming this to something like GlobalContext. |
| 34 | class SystemState { |
| 35 | public: |
| 36 | // Destructs this object. |
| 37 | virtual ~SystemState() {} |
| 38 | |
| 39 | // Returns true if the OOBE process has been completed and EULA accepted. |
| 40 | // False otherwise. |
| 41 | virtual bool IsOOBEComplete() = 0; |
| 42 | |
Jay Srinivasan | 53173b9 | 2013-05-17 17:13:01 -0700 | [diff] [blame] | 43 | // Returns true if we're running an official (i.e, non-dev, non-test) build. |
| 44 | // False otherwise. |
| 45 | virtual bool IsOfficialBuild() = 0; |
| 46 | |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 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 | |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 57 | // Gets the Metrics Library interface for reporting UMA stats. |
Jay Srinivasan | f057205 | 2012-10-23 18:12:56 -0700 | [diff] [blame] | 58 | virtual MetricsLibraryInterface* metrics_lib() = 0; |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 59 | |
| 60 | // Gets the interface object for persisted store. |
| 61 | virtual PrefsInterface* prefs() = 0; |
| 62 | |
Jay Srinivasan | 2b5a0f0 | 2012-12-19 17:25:56 -0800 | [diff] [blame] | 63 | // Gets the interface for the payload state object. |
| 64 | virtual PayloadStateInterface* payload_state() = 0; |
Gilad Arnold | bf7919b | 2013-01-08 13:07:37 -0800 | [diff] [blame] | 65 | |
| 66 | // Returns a pointer to the GPIO handler. |
| 67 | virtual GpioHandler* gpio_handler() const = 0; |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 68 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 69 | // Returns a pointer to the update attempter object. |
| 70 | virtual UpdateAttempter* update_attempter() = 0; |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 71 | |
| 72 | // Returns a pointer to the object that stores the parameters that are |
| 73 | // common to all Omaha requests. |
| 74 | virtual OmahaRequestParams* request_params() = 0; |
Chris Sosa | be45bef | 2013-04-09 18:25:12 -0700 | [diff] [blame] | 75 | |
| 76 | // If true, this is the first instance of the update engine since the system |
| 77 | // restarted. Important for tracking whether you are running instance of the |
| 78 | // update engine on first boot or due to a crash/restart. |
| 79 | virtual bool system_rebooted() = 0; |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | } // namespace chromeos_update_engine |
| 83 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 84 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_SYSTEM_STATE_H_ |