blob: b0080959cc4ae660729f4197c688d2afea55e3c0 [file] [log] [blame]
Jay Srinivasan43488792012-06-19 00:25:31 -07001// 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 Arnold1f847232014-04-07 12:07:49 -07008class MetricsLibraryInterface;
Gilad Arnoldf3815bb2013-01-14 11:58:24 -08009
Alex Deymo63784a52014-05-28 10:46:14 -070010namespace chromeos_update_manager {
Alex Deymo94c06162014-03-21 20:34:46 -070011
Alex Deymo63784a52014-05-28 10:46:14 -070012class UpdateManager;
Alex Deymo94c06162014-03-21 20:34:46 -070013
Alex Deymo63784a52014-05-28 10:46:14 -070014} // namespace chromeos_update_manager
Alex Deymo94c06162014-03-21 20:34:46 -070015
Gilad Arnold1f847232014-04-07 12:07:49 -070016namespace policy {
17
18class DevicePolicy;
19
20} // namespace policy
21
Jay Srinivasan43488792012-06-19 00:25:31 -070022namespace chromeos_update_engine {
23
Jay Srinivasan55f50c22013-01-10 19:24:35 -080024// 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 Zeuthenf413fe52013-04-22 14:04:39 -070027class ClockInterface;
Jay Srinivasan55f50c22013-01-10 19:24:35 -080028class ConnectionManager;
Jay Srinivasan55f50c22013-01-10 19:24:35 -080029class GpioHandler;
Alex Deymo94c06162014-03-21 20:34:46 -070030class HardwareInterface;
Gilad Arnold1f847232014-04-07 12:07:49 -070031class OmahaRequestParams;
David Zeuthen526cb582013-08-06 12:26:18 -070032class P2PManager;
Alex Deymo94c06162014-03-21 20:34:46 -070033class PayloadStateInterface;
34class PrefsInterface;
35class UpdateAttempter;
Jay Srinivasan55f50c22013-01-10 19:24:35 -080036
Jay Srinivasan43488792012-06-19 00:25:31 -070037// An interface to global system context, including platform resources,
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080038// the current state of the system, high-level objects whose lifetime is same
39// as main, system interfaces, etc.
Jay Srinivasan43488792012-06-19 00:25:31 -070040// 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 Deymo94c06162014-03-21 20:34:46 -070043// TODO(jaysri): Consider renaming this to something like GlobalContext.
Jay Srinivasan43488792012-06-19 00:25:31 -070044class SystemState {
45 public:
46 // Destructs this object.
47 virtual ~SystemState() {}
48
Jay Srinivasan43488792012-06-19 00:25:31 -070049 // Sets or gets the latest device policy.
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080050 virtual void set_device_policy(const policy::DevicePolicy* device_policy) = 0;
Gilad Arnold1f847232014-04-07 12:07:49 -070051 virtual const policy::DevicePolicy* device_policy() = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070052
David Zeuthenf413fe52013-04-22 14:04:39 -070053 // Gets the interface object for the clock.
54 virtual ClockInterface* clock() = 0;
55
Jay Srinivasan43488792012-06-19 00:25:31 -070056 // Gets the connection manager object.
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080057 virtual ConnectionManager* connection_manager() = 0;
Jay Srinivasanf0572052012-10-23 18:12:56 -070058
Alex Deymo42432912013-07-12 20:21:15 -070059 // Gets the hardware interface object.
60 virtual HardwareInterface* hardware() = 0;
61
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080062 // Gets the Metrics Library interface for reporting UMA stats.
Jay Srinivasanf0572052012-10-23 18:12:56 -070063 virtual MetricsLibraryInterface* metrics_lib() = 0;
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080064
65 // Gets the interface object for persisted store.
66 virtual PrefsInterface* prefs() = 0;
67
Chris Sosaaa18e162013-06-20 13:20:30 -070068 // 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 Srinivasan2b5a0f02012-12-19 17:25:56 -080074 // Gets the interface for the payload state object.
75 virtual PayloadStateInterface* payload_state() = 0;
Gilad Arnoldbf7919b2013-01-08 13:07:37 -080076
Jay Srinivasan55f50c22013-01-10 19:24:35 -080077 // Returns a pointer to the update attempter object.
Gilad Arnold1f847232014-04-07 12:07:49 -070078 virtual UpdateAttempter* update_attempter() = 0;
Jay Srinivasanae4697c2013-03-18 17:08:08 -070079
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 Sosabe45bef2013-04-09 18:25:12 -070083
David Zeuthen526cb582013-08-06 12:26:18 -070084 // Returns a pointer to the P2PManager singleton.
85 virtual P2PManager* p2p_manager() = 0;
86
Alex Deymo63784a52014-05-28 10:46:14 -070087 // Returns a pointer to the UpdateManager singleton.
88 virtual chromeos_update_manager::UpdateManager* update_manager() = 0;
Alex Deymo94c06162014-03-21 20:34:46 -070089
Chris Sosabe45bef2013-04-09 18:25:12 -070090 // 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 Srinivasan43488792012-06-19 00:25:31 -070094};
95
96} // namespace chromeos_update_engine
97
Jay Srinivasan55f50c22013-01-10 19:24:35 -080098#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_SYSTEM_STATE_H_