blob: 7d7ac093f09e7f22d019a25558e303f26ab8c137 [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
12#include <update_engine/connection_manager.h>
13
14namespace chromeos_update_engine {
15
16// An interface to global system context, including platform resources,
17// the current state of the system, high-level objects, system interfaces, etc.
18// Carved out separately so it can be mocked for unit tests.
19// Currently it has only one method, but we should start migrating other
20// methods to use this as and when needed to unit test them.
21// TODO (jaysri): Consider renaming this to something like GlobalContext.
22class SystemState {
23 public:
24 // Destructs this object.
25 virtual ~SystemState() {}
26
27 // Returns true if the OOBE process has been completed and EULA accepted.
28 // False otherwise.
29 virtual bool IsOOBEComplete() = 0;
30
31 // Sets or gets the latest device policy.
32 virtual void SetDevicePolicy(const policy::DevicePolicy* device_policy) = 0;
33 virtual const policy::DevicePolicy* GetDevicePolicy() const = 0;
34
35 // Gets the connection manager object.
36 virtual ConnectionManager* GetConnectionManager() = 0;
Jay Srinivasanf0572052012-10-23 18:12:56 -070037
38 // Sets or gets the Metrics Library interface for reporting UMA stats.
39 virtual void set_metrics_lib(MetricsLibraryInterface* metrics_lib) = 0;
40 virtual MetricsLibraryInterface* metrics_lib() = 0;
Jay Srinivasan43488792012-06-19 00:25:31 -070041};
42
43// A real implementation of the SystemStateInterface which is
44// used by the actual product code.
45class RealSystemState : public SystemState {
46public:
47 // Constructors and destructors.
48 RealSystemState();
49 virtual ~RealSystemState() {}
50
51 virtual bool IsOOBEComplete();
52
53 virtual void SetDevicePolicy(const policy::DevicePolicy* device_policy);
54 virtual const policy::DevicePolicy* GetDevicePolicy() const;
55
56 virtual ConnectionManager* GetConnectionManager();
57
Jay Srinivasanf0572052012-10-23 18:12:56 -070058 virtual void set_metrics_lib(MetricsLibraryInterface* metrics_lib);
59 virtual MetricsLibraryInterface* metrics_lib();
60
Jay Srinivasan43488792012-06-19 00:25:31 -070061private:
62 // The latest device policy object from the policy provider.
63 const policy::DevicePolicy* device_policy_;
64
65 // The connection manager object that makes download
66 // decisions depending on the current type of connection.
67 ConnectionManager connection_manager_;
Jay Srinivasanf0572052012-10-23 18:12:56 -070068
69 // The Metrics Library interface for reporting UMA stats.
70 MetricsLibraryInterface* metrics_lib_;
Jay Srinivasan43488792012-06-19 00:25:31 -070071};
72
73} // namespace chromeos_update_engine
74
75#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H_