| 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 |  | 
|  | 25 | virtual Variable<base::Time>* var_last_checked_time() override { | 
|  | 26 | return var_last_checked_time_.get(); | 
|  | 27 | } | 
|  | 28 |  | 
|  | 29 | virtual Variable<base::Time>* var_update_completed_time() override { | 
|  | 30 | return var_update_completed_time_.get(); | 
|  | 31 | } | 
|  | 32 |  | 
|  | 33 | virtual Variable<double>* var_progress() override { | 
|  | 34 | return var_progress_.get(); | 
|  | 35 | } | 
|  | 36 |  | 
|  | 37 | virtual Variable<Stage>* var_stage() override { | 
|  | 38 | return var_stage_.get(); | 
|  | 39 | } | 
|  | 40 |  | 
|  | 41 | virtual Variable<std::string>* var_new_version() override { | 
|  | 42 | return var_new_version_.get(); | 
|  | 43 | } | 
|  | 44 |  | 
|  | 45 | virtual Variable<size_t>* var_payload_size() override { | 
|  | 46 | return var_payload_size_.get(); | 
|  | 47 | } | 
|  | 48 |  | 
|  | 49 | virtual Variable<std::string>* var_curr_channel() override { | 
|  | 50 | return var_curr_channel_.get(); | 
|  | 51 | } | 
|  | 52 |  | 
|  | 53 | virtual Variable<std::string>* var_new_channel() override { | 
|  | 54 | return var_new_channel_.get(); | 
|  | 55 | } | 
|  | 56 |  | 
|  | 57 | virtual Variable<bool>* var_p2p_enabled() override { | 
|  | 58 | return var_p2p_enabled_.get(); | 
|  | 59 | } | 
|  | 60 |  | 
|  | 61 | virtual Variable<bool>* var_cellular_enabled() override { | 
|  | 62 | return var_cellular_enabled_.get(); | 
|  | 63 | } | 
|  | 64 |  | 
|  | 65 | protected: | 
|  | 66 | virtual bool DoInit() { return true; } | 
|  | 67 |  | 
|  | 68 | private: | 
|  | 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_ |