blob: ecb2fc0cd5c015e7bdf4ebbec488633c0a3c20bb [file] [log] [blame]
Jay Srinivasan55f50c22013-01-10 19:24:35 -08001// Copyright (c) 2013 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_REAL_SYSTEM_STATE_H_
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_REAL_SYSTEM_STATE_H_
7
8#include <update_engine/system_state.h>
9
10#include <update_engine/connection_manager.h>
11#include <update_engine/gpio_handler.h>
12#include <update_engine/payload_state.h>
13#include <update_engine/prefs.h>
14#include <update_engine/update_attempter.h>
15
16namespace chromeos_update_engine {
17
18// A real implementation of the SystemStateInterface which is
19// used by the actual product code.
20class RealSystemState : public SystemState {
21public:
22 // Constructors and destructors.
23 RealSystemState();
24 virtual ~RealSystemState() {}
25
26 virtual bool IsOOBEComplete();
27
28 virtual inline void set_device_policy(
29 const policy::DevicePolicy* device_policy) {
30 device_policy_ = device_policy;
31 }
32
33 virtual inline const policy::DevicePolicy* device_policy() const {
34 return device_policy_;
35 }
36
37 virtual inline ConnectionManager* connection_manager() {
38 return &connection_manager_;
39 }
40
41 virtual inline MetricsLibraryInterface* metrics_lib() {
42 return &metrics_lib_;
43 }
44
45 virtual inline PrefsInterface* prefs() {
46 return &prefs_;
47 }
48
49 virtual inline PayloadStateInterface* payload_state() {
50 return &payload_state_;
51 }
52
53 virtual inline GpioHandler* gpio_handler() const {
54 return gpio_handler_.get();
55 }
56
57 virtual inline UpdateAttempter* update_attempter() {
58 return update_attempter_.get();
59 }
60
Jay Srinivasanae4697c2013-03-18 17:08:08 -070061 // Returns a pointer to the object that stores the parameters that are
62 // common to all Omaha requests.
63 virtual inline OmahaRequestParams* request_params() {
64 return &request_params_;
65 }
66
Jay Srinivasan55f50c22013-01-10 19:24:35 -080067 // Initializes this concrete object. Other methods should be invoked only
68 // if the object has been initialized successfully.
69 bool Initialize(bool enable_gpio);
70
71private:
72 // The latest device policy object from the policy provider.
73 const policy::DevicePolicy* device_policy_;
74
75 // The connection manager object that makes download
76 // decisions depending on the current type of connection.
77 ConnectionManager connection_manager_;
78
79 // The Metrics Library interface for reporting UMA stats.
80 MetricsLibrary metrics_lib_;
81
82 // Interface for persisted store.
83 Prefs prefs_;
84
85 // All state pertaining to payload state such as
86 // response, URL, backoff states.
87 PayloadState payload_state_;
88
89 // Pointer to a GPIO handler and other needed modules (note that the order of
90 // declaration significant for destruction, as the latter depends on the
91 // former).
92 scoped_ptr<UdevInterface> udev_iface_;
93 scoped_ptr<FileDescriptor> file_descriptor_;
94 scoped_ptr<GpioHandler> gpio_handler_;
95
96 // The dbus object used to initialize the update attempter.
97 ConcreteDbusGlib dbus_;
98
99 // Pointer to the update attempter object.
100 scoped_ptr<UpdateAttempter> update_attempter_;
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700101
102 // Common parameters for all Omaha requests.
103 OmahaRequestParams request_params_;
Jay Srinivasan55f50c22013-01-10 19:24:35 -0800104};
105
106} // namespace chromeos_update_engine
107
108#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_REAL_SYSTEM_STATE_H_