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