blob: 313d67058ba53ec3c5cb454e34d91a4a5c968050 [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"
Jay Srinivasanae4697c2013-03-18 17:08:08 -070013#include "update_engine/omaha_request_params.h"
Gilad Arnoldf3815bb2013-01-14 11:58:24 -080014
Jay Srinivasan43488792012-06-19 00:25:31 -070015namespace chromeos_update_engine {
16
Jay Srinivasan55f50c22013-01-10 19:24:35 -080017// 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 Zeuthenf413fe52013-04-22 14:04:39 -070020class ClockInterface;
Jay Srinivasan55f50c22013-01-10 19:24:35 -080021class ConnectionManager;
22class PrefsInterface;
23class PayloadStateInterface;
24class GpioHandler;
25class UpdateAttempter;
26
Jay Srinivasan43488792012-06-19 00:25:31 -070027// An interface to global system context, including platform resources,
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080028// the current state of the system, high-level objects whose lifetime is same
29// as main, system interfaces, etc.
Jay Srinivasan43488792012-06-19 00:25:31 -070030// 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.
34class 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
43 // Sets or gets the latest device policy.
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080044 virtual void set_device_policy(const policy::DevicePolicy* device_policy) = 0;
45 virtual const policy::DevicePolicy* device_policy() const = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070046
David Zeuthenf413fe52013-04-22 14:04:39 -070047 // Gets the interface object for the clock.
48 virtual ClockInterface* clock() = 0;
49
Jay Srinivasan43488792012-06-19 00:25:31 -070050 // Gets the connection manager object.
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080051 virtual ConnectionManager* connection_manager() = 0;
Jay Srinivasanf0572052012-10-23 18:12:56 -070052
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080053 // Gets the Metrics Library interface for reporting UMA stats.
Jay Srinivasanf0572052012-10-23 18:12:56 -070054 virtual MetricsLibraryInterface* metrics_lib() = 0;
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080055
56 // Gets the interface object for persisted store.
57 virtual PrefsInterface* prefs() = 0;
58
Jay Srinivasan2b5a0f02012-12-19 17:25:56 -080059 // Gets the interface for the payload state object.
60 virtual PayloadStateInterface* payload_state() = 0;
Gilad Arnoldbf7919b2013-01-08 13:07:37 -080061
62 // Returns a pointer to the GPIO handler.
63 virtual GpioHandler* gpio_handler() const = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070064
Jay Srinivasan55f50c22013-01-10 19:24:35 -080065 // Returns a pointer to the update attempter object.
66 virtual UpdateAttempter* update_attempter() = 0;
Jay Srinivasanae4697c2013-03-18 17:08:08 -070067
68 // Returns a pointer to the object that stores the parameters that are
69 // common to all Omaha requests.
70 virtual OmahaRequestParams* request_params() = 0;
Chris Sosabe45bef2013-04-09 18:25:12 -070071
72 // If true, this is the first instance of the update engine since the system
73 // restarted. Important for tracking whether you are running instance of the
74 // update engine on first boot or due to a crash/restart.
75 virtual bool system_rebooted() = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070076};
77
78} // namespace chromeos_update_engine
79
Jay Srinivasan55f50c22013-01-10 19:24:35 -080080#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_SYSTEM_STATE_H_