real_state.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #ifndef UPDATE_ENGINE_UPDATE_MANAGER_REAL_STATE_H_
  17. #define UPDATE_ENGINE_UPDATE_MANAGER_REAL_STATE_H_
  18. #include <memory>
  19. #include "update_engine/update_manager/state.h"
  20. namespace chromeos_update_manager {
  21. // State concrete implementation.
  22. class RealState : public State {
  23. public:
  24. ~RealState() override {}
  25. RealState(ConfigProvider* config_provider,
  26. DevicePolicyProvider* device_policy_provider,
  27. RandomProvider* random_provider,
  28. ShillProvider* shill_provider,
  29. SystemProvider* system_provider,
  30. TimeProvider* time_provider,
  31. UpdaterProvider* updater_provider)
  32. : config_provider_(config_provider),
  33. device_policy_provider_(device_policy_provider),
  34. random_provider_(random_provider),
  35. shill_provider_(shill_provider),
  36. system_provider_(system_provider),
  37. time_provider_(time_provider),
  38. updater_provider_(updater_provider) {}
  39. // These methods return the given provider.
  40. ConfigProvider* config_provider() override { return config_provider_.get(); }
  41. DevicePolicyProvider* device_policy_provider() override {
  42. return device_policy_provider_.get();
  43. }
  44. RandomProvider* random_provider() override { return random_provider_.get(); }
  45. ShillProvider* shill_provider() override { return shill_provider_.get(); }
  46. SystemProvider* system_provider() override { return system_provider_.get(); }
  47. TimeProvider* time_provider() override { return time_provider_.get(); }
  48. UpdaterProvider* updater_provider() override {
  49. return updater_provider_.get();
  50. }
  51. private:
  52. // Instances of the providers.
  53. std::unique_ptr<ConfigProvider> config_provider_;
  54. std::unique_ptr<DevicePolicyProvider> device_policy_provider_;
  55. std::unique_ptr<RandomProvider> random_provider_;
  56. std::unique_ptr<ShillProvider> shill_provider_;
  57. std::unique_ptr<SystemProvider> system_provider_;
  58. std::unique_ptr<TimeProvider> time_provider_;
  59. std::unique_ptr<UpdaterProvider> updater_provider_;
  60. };
  61. } // namespace chromeos_update_manager
  62. #endif // UPDATE_ENGINE_UPDATE_MANAGER_REAL_STATE_H_