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