blob: 4b30d1a694caf5e312cebc123cf72545f44a8c1d [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.
20class ConnectionManager;
21class PrefsInterface;
22class PayloadStateInterface;
23class GpioHandler;
24class UpdateAttempter;
25
Jay Srinivasan43488792012-06-19 00:25:31 -070026// An interface to global system context, including platform resources,
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080027// the current state of the system, high-level objects whose lifetime is same
28// as main, system interfaces, etc.
Jay Srinivasan43488792012-06-19 00:25:31 -070029// Carved out separately so it can be mocked for unit tests.
30// Currently it has only one method, but we should start migrating other
31// methods to use this as and when needed to unit test them.
32// TODO (jaysri): Consider renaming this to something like GlobalContext.
33class SystemState {
34 public:
35 // Destructs this object.
36 virtual ~SystemState() {}
37
38 // Returns true if the OOBE process has been completed and EULA accepted.
39 // False otherwise.
40 virtual bool IsOOBEComplete() = 0;
41
42 // Sets or gets the latest device policy.
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080043 virtual void set_device_policy(const policy::DevicePolicy* device_policy) = 0;
44 virtual const policy::DevicePolicy* device_policy() const = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070045
46 // Gets the connection manager object.
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080047 virtual ConnectionManager* connection_manager() = 0;
Jay Srinivasanf0572052012-10-23 18:12:56 -070048
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080049 // Gets the Metrics Library interface for reporting UMA stats.
Jay Srinivasanf0572052012-10-23 18:12:56 -070050 virtual MetricsLibraryInterface* metrics_lib() = 0;
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080051
52 // Gets the interface object for persisted store.
53 virtual PrefsInterface* prefs() = 0;
54
Jay Srinivasan2b5a0f02012-12-19 17:25:56 -080055 // Gets the interface for the payload state object.
56 virtual PayloadStateInterface* payload_state() = 0;
Gilad Arnoldbf7919b2013-01-08 13:07:37 -080057
58 // Returns a pointer to the GPIO handler.
59 virtual GpioHandler* gpio_handler() const = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070060
Jay Srinivasan55f50c22013-01-10 19:24:35 -080061 // Returns a pointer to the update attempter object.
62 virtual UpdateAttempter* update_attempter() = 0;
Jay Srinivasanae4697c2013-03-18 17:08:08 -070063
64 // Returns a pointer to the object that stores the parameters that are
65 // common to all Omaha requests.
66 virtual OmahaRequestParams* request_params() = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070067};
68
69} // namespace chromeos_update_engine
70
Jay Srinivasan55f50c22013-01-10 19:24:35 -080071#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_SYSTEM_STATE_H_