blob: 82c9284fba768d8506e679fe570e232c8d0efde1 [file] [log] [blame]
Alex Deymof9f12632014-04-17 13:51:26 -07001// Copyright 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 Arnold48415f12014-06-27 07:10:58 -07005#ifndef UPDATE_ENGINE_UPDATE_MANAGER_REAL_CONFIG_PROVIDER_H_
6#define UPDATE_ENGINE_UPDATE_MANAGER_REAL_CONFIG_PROVIDER_H_
Alex Deymof9f12632014-04-17 13:51:26 -07007
Ben Chan02f7c1d2014-10-18 15:18:02 -07008#include <memory>
Alex Deymof9f12632014-04-17 13:51:26 -07009#include <string>
10
Alex Deymof9f12632014-04-17 13:51:26 -070011#include "update_engine/hardware_interface.h"
Alex Deymo63784a52014-05-28 10:46:14 -070012#include "update_engine/update_manager/config_provider.h"
13#include "update_engine/update_manager/generic_variables.h"
Alex Deymof9f12632014-04-17 13:51:26 -070014
Alex Deymo63784a52014-05-28 10:46:14 -070015namespace chromeos_update_manager {
Alex Deymof9f12632014-04-17 13:51:26 -070016
17// ConfigProvider concrete implementation.
18class RealConfigProvider : public ConfigProvider {
19 public:
20 explicit RealConfigProvider(
21 chromeos_update_engine::HardwareInterface* hardware)
22 : hardware_(hardware) {}
23
Alex Deymo42c30c32014-04-24 18:41:18 -070024 // Initializes the provider and returns whether it succeeded.
25 bool Init();
26
Alex Deymof9f12632014-04-17 13:51:26 -070027 Variable<bool>* var_is_oobe_enabled() override {
28 return var_is_oobe_enabled_.get();
29 }
30
31 private:
Alex Deymo63784a52014-05-28 10:46:14 -070032 friend class UmRealConfigProviderTest;
Alex Deymof9f12632014-04-17 13:51:26 -070033
Alex Deymof9f12632014-04-17 13:51:26 -070034 // Used for testing. Sets the root prefix, which is by default "". Call this
35 // method before calling Init() in order to mock out the place where the files
36 // are being read from.
37 void SetRootPrefix(const std::string& prefix) {
38 root_prefix_ = prefix;
39 }
40
Ben Chan02f7c1d2014-10-18 15:18:02 -070041 std::unique_ptr<ConstCopyVariable<bool>> var_is_oobe_enabled_;
Alex Deymof9f12632014-04-17 13:51:26 -070042
43 chromeos_update_engine::HardwareInterface* hardware_;
44
45 // Prefix to prepend to the file paths. Useful for testing.
46 std::string root_prefix_;
47
48 DISALLOW_COPY_AND_ASSIGN(RealConfigProvider);
49};
50
Alex Deymo63784a52014-05-28 10:46:14 -070051} // namespace chromeos_update_manager
Alex Deymof9f12632014-04-17 13:51:26 -070052
Gilad Arnold48415f12014-06-27 07:10:58 -070053#endif // UPDATE_ENGINE_UPDATE_MANAGER_REAL_CONFIG_PROVIDER_H_