blob: e32aa0ec1bb252122de53fee4e3b31e81605b691 [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
Gilad Arnoldcf175a02014-07-10 16:48:47 -07005#ifndef UPDATE_ENGINE_SYSTEM_STATE_H_
6#define UPDATE_ENGINE_SYSTEM_STATE_H_
Jay Srinivasan43488792012-06-19 00:25:31 -07007
Alex Deymo30534502015-07-20 15:06:33 -07008#include "update_engine/dbus_proxies.h"
9
Gilad Arnold1f847232014-04-07 12:07:49 -070010class MetricsLibraryInterface;
Gilad Arnoldf3815bb2013-01-14 11:58:24 -080011
Alex Deymo63784a52014-05-28 10:46:14 -070012namespace chromeos_update_manager {
Alex Deymo94c06162014-03-21 20:34:46 -070013
Alex Deymo63784a52014-05-28 10:46:14 -070014class UpdateManager;
Alex Deymo94c06162014-03-21 20:34:46 -070015
Alex Deymo63784a52014-05-28 10:46:14 -070016} // namespace chromeos_update_manager
Alex Deymo94c06162014-03-21 20:34:46 -070017
Gilad Arnold1f847232014-04-07 12:07:49 -070018namespace policy {
19
20class DevicePolicy;
21
22} // namespace policy
23
Jay Srinivasan43488792012-06-19 00:25:31 -070024namespace chromeos_update_engine {
25
Jay Srinivasan55f50c22013-01-10 19:24:35 -080026// SystemState is the root class within the update engine. So we should avoid
27// any circular references in header file inclusion. Hence forward-declaring
28// the required classes.
David Zeuthenf413fe52013-04-22 14:04:39 -070029class ClockInterface;
Alex Deymof6ee0162015-07-31 12:35:22 -070030class ConnectionManagerInterface;
Alex Deymo94c06162014-03-21 20:34:46 -070031class HardwareInterface;
Gilad Arnold1f847232014-04-07 12:07:49 -070032class OmahaRequestParams;
David Zeuthen526cb582013-08-06 12:26:18 -070033class P2PManager;
Alex Deymo94c06162014-03-21 20:34:46 -070034class PayloadStateInterface;
35class PrefsInterface;
36class UpdateAttempter;
Jay Srinivasan55f50c22013-01-10 19:24:35 -080037
Jay Srinivasan43488792012-06-19 00:25:31 -070038// An interface to global system context, including platform resources,
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080039// the current state of the system, high-level objects whose lifetime is same
40// as main, system interfaces, etc.
Jay Srinivasan43488792012-06-19 00:25:31 -070041// Carved out separately so it can be mocked for unit tests.
42// Currently it has only one method, but we should start migrating other
43// methods to use this as and when needed to unit test them.
Alex Deymo94c06162014-03-21 20:34:46 -070044// TODO(jaysri): Consider renaming this to something like GlobalContext.
Jay Srinivasan43488792012-06-19 00:25:31 -070045class SystemState {
46 public:
47 // Destructs this object.
48 virtual ~SystemState() {}
49
Jay Srinivasan43488792012-06-19 00:25:31 -070050 // Sets or gets the latest device policy.
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080051 virtual void set_device_policy(const policy::DevicePolicy* device_policy) = 0;
Gilad Arnold1f847232014-04-07 12:07:49 -070052 virtual const policy::DevicePolicy* device_policy() = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070053
David Zeuthenf413fe52013-04-22 14:04:39 -070054 // Gets the interface object for the clock.
55 virtual ClockInterface* clock() = 0;
56
Jay Srinivasan43488792012-06-19 00:25:31 -070057 // Gets the connection manager object.
Alex Deymof6ee0162015-07-31 12:35:22 -070058 virtual ConnectionManagerInterface* connection_manager() = 0;
Jay Srinivasanf0572052012-10-23 18:12:56 -070059
Alex Deymo42432912013-07-12 20:21:15 -070060 // Gets the hardware interface object.
61 virtual HardwareInterface* hardware() = 0;
62
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080063 // Gets the Metrics Library interface for reporting UMA stats.
Jay Srinivasanf0572052012-10-23 18:12:56 -070064 virtual MetricsLibraryInterface* metrics_lib() = 0;
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080065
66 // Gets the interface object for persisted store.
67 virtual PrefsInterface* prefs() = 0;
68
Chris Sosaaa18e162013-06-20 13:20:30 -070069 // Gets the interface object for the persisted store that persists across
70 // powerwashes. Please note that this should be used very seldomly and must
71 // be forwards and backwards compatible as powerwash is used to go back and
72 // forth in system versions.
73 virtual PrefsInterface* powerwash_safe_prefs() = 0;
74
Jay Srinivasan2b5a0f02012-12-19 17:25:56 -080075 // Gets the interface for the payload state object.
76 virtual PayloadStateInterface* payload_state() = 0;
Gilad Arnoldbf7919b2013-01-08 13:07:37 -080077
Jay Srinivasan55f50c22013-01-10 19:24:35 -080078 // Returns a pointer to the update attempter object.
Gilad Arnold1f847232014-04-07 12:07:49 -070079 virtual UpdateAttempter* update_attempter() = 0;
Jay Srinivasanae4697c2013-03-18 17:08:08 -070080
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 Sosabe45bef2013-04-09 18:25:12 -070084
David Zeuthen526cb582013-08-06 12:26:18 -070085 // Returns a pointer to the P2PManager singleton.
86 virtual P2PManager* p2p_manager() = 0;
87
Alex Deymo63784a52014-05-28 10:46:14 -070088 // Returns a pointer to the UpdateManager singleton.
89 virtual chromeos_update_manager::UpdateManager* update_manager() = 0;
Alex Deymo94c06162014-03-21 20:34:46 -070090
Alex Deymo30534502015-07-20 15:06:33 -070091 // DBus proxies. Mocked during test.
92 virtual org::chromium::PowerManagerProxyInterface* power_manager_proxy() = 0;
93
Chris Sosabe45bef2013-04-09 18:25:12 -070094 // If true, this is the first instance of the update engine since the system
95 // restarted. Important for tracking whether you are running instance of the
96 // update engine on first boot or due to a crash/restart.
97 virtual bool system_rebooted() = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070098};
99
100} // namespace chromeos_update_engine
101
Gilad Arnoldcf175a02014-07-10 16:48:47 -0700102#endif // UPDATE_ENGINE_SYSTEM_STATE_H_