1 // 2 // Copyright (C) 2014 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #ifndef UPDATE_ENGINE_UPDATE_MANAGER_REAL_STATE_H_ 18 #define UPDATE_ENGINE_UPDATE_MANAGER_REAL_STATE_H_ 19 20 #include <memory> 21 22 #include "update_engine/update_manager/state.h" 23 24 namespace chromeos_update_manager { 25 26 // State concrete implementation. 27 class RealState : public State { 28 public: ~RealState()29 ~RealState() override {} 30 RealState(ConfigProvider * config_provider,DevicePolicyProvider * device_policy_provider,RandomProvider * random_provider,ShillProvider * shill_provider,SystemProvider * system_provider,TimeProvider * time_provider,UpdaterProvider * updater_provider)31 RealState(ConfigProvider* config_provider, 32 DevicePolicyProvider* device_policy_provider, 33 RandomProvider* random_provider, 34 ShillProvider* shill_provider, 35 SystemProvider* system_provider, 36 TimeProvider* time_provider, 37 UpdaterProvider* updater_provider) 38 : config_provider_(config_provider), 39 device_policy_provider_(device_policy_provider), 40 random_provider_(random_provider), 41 shill_provider_(shill_provider), 42 system_provider_(system_provider), 43 time_provider_(time_provider), 44 updater_provider_(updater_provider) {} 45 46 // These methods return the given provider. config_provider()47 ConfigProvider* config_provider() override { return config_provider_.get(); } device_policy_provider()48 DevicePolicyProvider* device_policy_provider() override { 49 return device_policy_provider_.get(); 50 } random_provider()51 RandomProvider* random_provider() override { return random_provider_.get(); } shill_provider()52 ShillProvider* shill_provider() override { return shill_provider_.get(); } system_provider()53 SystemProvider* system_provider() override { return system_provider_.get(); } time_provider()54 TimeProvider* time_provider() override { return time_provider_.get(); } updater_provider()55 UpdaterProvider* updater_provider() override { 56 return updater_provider_.get(); 57 } 58 59 private: 60 // Instances of the providers. 61 std::unique_ptr<ConfigProvider> config_provider_; 62 std::unique_ptr<DevicePolicyProvider> device_policy_provider_; 63 std::unique_ptr<RandomProvider> random_provider_; 64 std::unique_ptr<ShillProvider> shill_provider_; 65 std::unique_ptr<SystemProvider> system_provider_; 66 std::unique_ptr<TimeProvider> time_provider_; 67 std::unique_ptr<UpdaterProvider> updater_provider_; 68 }; 69 70 } // namespace chromeos_update_manager 71 72 #endif // UPDATE_ENGINE_UPDATE_MANAGER_REAL_STATE_H_ 73