Alex Deymo | 2de23f5 | 2014-02-26 14:30:13 -0800 | [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 | |
Gilad Arnold | 2cbb385 | 2014-03-07 12:40:50 -0800 | [diff] [blame] | 5 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_STATE_H_ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_STATE_H_ |
Alex Deymo | 2de23f5 | 2014-02-26 14:30:13 -0800 | [diff] [blame] | 7 | |
| 8 | #include "update_engine/policy_manager/random_provider.h" |
| 9 | #include "update_engine/policy_manager/shill_provider.h" |
| 10 | |
| 11 | namespace chromeos_policy_manager { |
| 12 | |
| 13 | // The State class is an interface to the ensemble of providers. This class |
| 14 | // gives visibility of the state providers to policy implementations. |
| 15 | class State { |
| 16 | public: |
| 17 | virtual ~State() {} |
| 18 | |
| 19 | // Initializes the State instance. Returns whether the initialization |
| 20 | // succeeded. |
| 21 | bool Init() { |
| 22 | return (random_provider_ && random_provider_->Init() && |
| 23 | shill_provider_ && shill_provider_->Init()); |
| 24 | } |
| 25 | |
| 26 | // These functions return the given provider. |
| 27 | RandomProvider* random_provider() { return random_provider_.get(); } |
| 28 | ShillProvider* shill_provider() { return shill_provider_.get(); } |
| 29 | |
| 30 | protected: |
| 31 | // Initialize the private scoped_ptr for each provider. |
| 32 | void set_random_provider(RandomProvider* random_provider) { |
| 33 | return random_provider_.reset(random_provider); |
| 34 | } |
| 35 | |
| 36 | void set_shill_provider(ShillProvider* shill_provider) { |
| 37 | return shill_provider_.reset(shill_provider); |
| 38 | } |
| 39 | |
| 40 | private: |
| 41 | // Instances of the providers. |
| 42 | scoped_ptr<RandomProvider> random_provider_; |
| 43 | scoped_ptr<ShillProvider> shill_provider_; |
| 44 | }; |
| 45 | |
| 46 | } // namespace chromeos_policy_manager |
| 47 | |
Gilad Arnold | 2cbb385 | 2014-03-07 12:40:50 -0800 | [diff] [blame] | 48 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_STATE_H_ |