blob: e4b308e9663074ec52d5ef363dcab3515b616c1d [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 Deymo1f012912014-04-24 19:08:04 -070010#include "update_engine/policy_manager/updater_provider.h"
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070011#include "update_engine/system_state.h"
12
13namespace chromeos_policy_manager {
14
15// A concrete UpdaterProvider implementation using local (in-process) bindings.
16class RealUpdaterProvider : public UpdaterProvider {
17 public:
18 // We assume that any other object handle we get from the system state is
19 // "volatile", and so must be re-acquired whenever access is needed; this
20 // guarantees that parts of the system state can be mocked out at any time
21 // during testing. We further assume that, by the time Init() is called, the
22 // system state object is fully populated and usable.
23 explicit RealUpdaterProvider(
24 chromeos_update_engine::SystemState* system_state);
25
Alex Deymo42c30c32014-04-24 18:41:18 -070026 // Initializes the provider and returns whether it succeeded.
27 bool Init() { return true; }
28
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070029 virtual Variable<base::Time>* var_last_checked_time() override {
30 return var_last_checked_time_.get();
31 }
32
33 virtual Variable<base::Time>* var_update_completed_time() override {
34 return var_update_completed_time_.get();
35 }
36
37 virtual Variable<double>* var_progress() override {
38 return var_progress_.get();
39 }
40
41 virtual Variable<Stage>* var_stage() override {
42 return var_stage_.get();
43 }
44
45 virtual Variable<std::string>* var_new_version() override {
46 return var_new_version_.get();
47 }
48
49 virtual Variable<size_t>* var_payload_size() override {
50 return var_payload_size_.get();
51 }
52
53 virtual Variable<std::string>* var_curr_channel() override {
54 return var_curr_channel_.get();
55 }
56
57 virtual Variable<std::string>* var_new_channel() override {
58 return var_new_channel_.get();
59 }
60
61 virtual Variable<bool>* var_p2p_enabled() override {
62 return var_p2p_enabled_.get();
63 }
64
65 virtual Variable<bool>* var_cellular_enabled() override {
66 return var_cellular_enabled_.get();
67 }
68
David Zeuthen21716e22014-04-23 15:42:05 -070069 private:
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070070 // A pointer to the update engine's system state aggregator.
71 chromeos_update_engine::SystemState* system_state_;
72
73 // Pointers to all variable implementations.
74 scoped_ptr<Variable<base::Time>> var_last_checked_time_;
75 scoped_ptr<Variable<base::Time>> var_update_completed_time_;
76 scoped_ptr<Variable<double>> var_progress_;
77 scoped_ptr<Variable<Stage>> var_stage_;
78 scoped_ptr<Variable<std::string>> var_new_version_;
79 scoped_ptr<Variable<size_t>> var_payload_size_;
80 scoped_ptr<Variable<std::string>> var_curr_channel_;
81 scoped_ptr<Variable<std::string>> var_new_channel_;
82 scoped_ptr<Variable<bool>> var_p2p_enabled_;
83 scoped_ptr<Variable<bool>> var_cellular_enabled_;
84
85 DISALLOW_COPY_AND_ASSIGN(RealUpdaterProvider);
86};
87
88} // namespace chromeos_policy_manager
89
90#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_REAL_UPDATER_PROVIDER_H_