blob: 7ed0b4efd76a95f8a5b116cd65ca272381320a71 [file] [log] [blame]
Gilad Arnoldae47a9a2014-03-26 12:16:47 -07001// Copyright (c) 2014 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_POLICY_MANAGER_REAL_UPDATER_PROVIDER_H_
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_REAL_UPDATER_PROVIDER_H_
7
Alex Deymo1f012912014-04-24 19:08:04 -07008#include <base/memory/scoped_ptr.h>
Gilad Arnoldae47a9a2014-03-26 12:16:47 -07009
Alex Deymoc7ab6162014-04-25 18:32:50 -070010#include "update_engine/policy_manager/generic_variables.h"
Alex Deymo1f012912014-04-24 19:08:04 -070011#include "update_engine/policy_manager/updater_provider.h"
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070012#include "update_engine/system_state.h"
13
14namespace chromeos_policy_manager {
15
16// A concrete UpdaterProvider implementation using local (in-process) bindings.
17class RealUpdaterProvider : public UpdaterProvider {
18 public:
19 // We assume that any other object handle we get from the system state is
20 // "volatile", and so must be re-acquired whenever access is needed; this
21 // guarantees that parts of the system state can be mocked out at any time
22 // during testing. We further assume that, by the time Init() is called, the
23 // system state object is fully populated and usable.
24 explicit RealUpdaterProvider(
25 chromeos_update_engine::SystemState* system_state);
26
Alex Deymo42c30c32014-04-24 18:41:18 -070027 // Initializes the provider and returns whether it succeeded.
28 bool Init() { return true; }
29
Alex Deymoc7ab6162014-04-25 18:32:50 -070030 virtual Variable<base::Time>* var_updater_started_time() override {
31 return &var_updater_started_time_;
32 }
33
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070034 virtual Variable<base::Time>* var_last_checked_time() override {
35 return var_last_checked_time_.get();
36 }
37
38 virtual Variable<base::Time>* var_update_completed_time() override {
39 return var_update_completed_time_.get();
40 }
41
42 virtual Variable<double>* var_progress() override {
43 return var_progress_.get();
44 }
45
46 virtual Variable<Stage>* var_stage() override {
47 return var_stage_.get();
48 }
49
50 virtual Variable<std::string>* var_new_version() override {
51 return var_new_version_.get();
52 }
53
Alex Deymof967ebe2014-05-05 14:46:17 -070054 virtual Variable<int64_t>* var_payload_size() override {
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070055 return var_payload_size_.get();
56 }
57
58 virtual Variable<std::string>* var_curr_channel() override {
59 return var_curr_channel_.get();
60 }
61
62 virtual Variable<std::string>* var_new_channel() override {
63 return var_new_channel_.get();
64 }
65
66 virtual Variable<bool>* var_p2p_enabled() override {
67 return var_p2p_enabled_.get();
68 }
69
70 virtual Variable<bool>* var_cellular_enabled() override {
71 return var_cellular_enabled_.get();
72 }
73
Gilad Arnolda6dab942014-04-25 11:46:03 -070074 virtual Variable<unsigned int>*
75 var_consecutive_failed_update_checks() override {
76 return var_consecutive_failed_update_checks_.get();
77 }
78
David Zeuthen21716e22014-04-23 15:42:05 -070079 private:
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070080 // A pointer to the update engine's system state aggregator.
81 chromeos_update_engine::SystemState* system_state_;
82
Alex Deymoc7ab6162014-04-25 18:32:50 -070083 // Variable implementations.
84 ConstCopyVariable<base::Time> var_updater_started_time_;
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070085 scoped_ptr<Variable<base::Time>> var_last_checked_time_;
86 scoped_ptr<Variable<base::Time>> var_update_completed_time_;
87 scoped_ptr<Variable<double>> var_progress_;
88 scoped_ptr<Variable<Stage>> var_stage_;
89 scoped_ptr<Variable<std::string>> var_new_version_;
Alex Deymof967ebe2014-05-05 14:46:17 -070090 scoped_ptr<Variable<int64_t>> var_payload_size_;
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070091 scoped_ptr<Variable<std::string>> var_curr_channel_;
92 scoped_ptr<Variable<std::string>> var_new_channel_;
93 scoped_ptr<Variable<bool>> var_p2p_enabled_;
94 scoped_ptr<Variable<bool>> var_cellular_enabled_;
Gilad Arnolda6dab942014-04-25 11:46:03 -070095 scoped_ptr<Variable<unsigned int>> var_consecutive_failed_update_checks_;
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070096
97 DISALLOW_COPY_AND_ASSIGN(RealUpdaterProvider);
98};
99
100} // namespace chromeos_policy_manager
101
102#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_REAL_UPDATER_PROVIDER_H_