Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame^] | 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 | // |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 16 | |
Gilad Arnold | 48415f1 | 2014-06-27 07:10:58 -0700 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_UPDATE_MANAGER_REAL_CONFIG_PROVIDER_H_ |
| 18 | #define UPDATE_ENGINE_UPDATE_MANAGER_REAL_CONFIG_PROVIDER_H_ |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 19 | |
Ben Chan | 02f7c1d | 2014-10-18 15:18:02 -0700 | [diff] [blame] | 20 | #include <memory> |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 21 | #include <string> |
| 22 | |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 23 | #include "update_engine/hardware_interface.h" |
Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 24 | #include "update_engine/update_manager/config_provider.h" |
| 25 | #include "update_engine/update_manager/generic_variables.h" |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 26 | |
Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 27 | namespace chromeos_update_manager { |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 28 | |
| 29 | // ConfigProvider concrete implementation. |
| 30 | class RealConfigProvider : public ConfigProvider { |
| 31 | public: |
| 32 | explicit RealConfigProvider( |
| 33 | chromeos_update_engine::HardwareInterface* hardware) |
| 34 | : hardware_(hardware) {} |
| 35 | |
Alex Deymo | 42c30c3 | 2014-04-24 18:41:18 -0700 | [diff] [blame] | 36 | // Initializes the provider and returns whether it succeeded. |
| 37 | bool Init(); |
| 38 | |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 39 | Variable<bool>* var_is_oobe_enabled() override { |
| 40 | return var_is_oobe_enabled_.get(); |
| 41 | } |
| 42 | |
| 43 | private: |
Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 44 | friend class UmRealConfigProviderTest; |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 45 | |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 46 | // Used for testing. Sets the root prefix, which is by default "". Call this |
| 47 | // method before calling Init() in order to mock out the place where the files |
| 48 | // are being read from. |
| 49 | void SetRootPrefix(const std::string& prefix) { |
| 50 | root_prefix_ = prefix; |
| 51 | } |
| 52 | |
Ben Chan | 02f7c1d | 2014-10-18 15:18:02 -0700 | [diff] [blame] | 53 | std::unique_ptr<ConstCopyVariable<bool>> var_is_oobe_enabled_; |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 54 | |
| 55 | chromeos_update_engine::HardwareInterface* hardware_; |
| 56 | |
| 57 | // Prefix to prepend to the file paths. Useful for testing. |
| 58 | std::string root_prefix_; |
| 59 | |
| 60 | DISALLOW_COPY_AND_ASSIGN(RealConfigProvider); |
| 61 | }; |
| 62 | |
Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 63 | } // namespace chromeos_update_manager |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 64 | |
Gilad Arnold | 48415f1 | 2014-06-27 07:10:58 -0700 | [diff] [blame] | 65 | #endif // UPDATE_ENGINE_UPDATE_MANAGER_REAL_CONFIG_PROVIDER_H_ |