blob: cb33ce0fb30ba74a4f493d69e637dde21b847315 [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
Jay Srinivasanf0572052012-10-23 18:12:56 -07008#include "metrics/metrics_library.h"
Jay Srinivasan43488792012-06-19 00:25:31 -07009#include <policy/device_policy.h>
10#include <policy/libpolicy.h>
11
Gilad Arnoldf3815bb2013-01-14 11:58:24 -080012#include "update_engine/gpio_handler.h"
13
Jay Srinivasan43488792012-06-19 00:25:31 -070014namespace chromeos_update_engine {
15
Jay Srinivasan55f50c22013-01-10 19:24:35 -080016// SystemState is the root class within the update engine. So we should avoid
17// any circular references in header file inclusion. Hence forward-declaring
18// the required classes.
19class ConnectionManager;
20class PrefsInterface;
21class PayloadStateInterface;
22class GpioHandler;
23class UpdateAttempter;
24
Jay Srinivasan43488792012-06-19 00:25:31 -070025// An interface to global system context, including platform resources,
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080026// the current state of the system, high-level objects whose lifetime is same
27// as main, system interfaces, etc.
Jay Srinivasan43488792012-06-19 00:25:31 -070028// Carved out separately so it can be mocked for unit tests.
29// Currently it has only one method, but we should start migrating other
30// methods to use this as and when needed to unit test them.
31// TODO (jaysri): Consider renaming this to something like GlobalContext.
32class SystemState {
33 public:
34 // Destructs this object.
35 virtual ~SystemState() {}
36
37 // Returns true if the OOBE process has been completed and EULA accepted.
38 // False otherwise.
39 virtual bool IsOOBEComplete() = 0;
40
41 // Sets or gets the latest device policy.
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080042 virtual void set_device_policy(const policy::DevicePolicy* device_policy) = 0;
43 virtual const policy::DevicePolicy* device_policy() const = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070044
45 // Gets the connection manager object.
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080046 virtual ConnectionManager* connection_manager() = 0;
Jay Srinivasanf0572052012-10-23 18:12:56 -070047
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080048 // Gets the Metrics Library interface for reporting UMA stats.
Jay Srinivasanf0572052012-10-23 18:12:56 -070049 virtual MetricsLibraryInterface* metrics_lib() = 0;
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080050
51 // Gets the interface object for persisted store.
52 virtual PrefsInterface* prefs() = 0;
53
Jay Srinivasan2b5a0f02012-12-19 17:25:56 -080054 // Gets the interface for the payload state object.
55 virtual PayloadStateInterface* payload_state() = 0;
Gilad Arnoldbf7919b2013-01-08 13:07:37 -080056
57 // Returns a pointer to the GPIO handler.
58 virtual GpioHandler* gpio_handler() const = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070059
Jay Srinivasan55f50c22013-01-10 19:24:35 -080060 // Returns a pointer to the update attempter object.
61 virtual UpdateAttempter* update_attempter() = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070062};
63
64} // namespace chromeos_update_engine
65
Jay Srinivasan55f50c22013-01-10 19:24:35 -080066#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_SYSTEM_STATE_H_