blob: cc87c4034915605f4be7b2dddcfc272c62cfc80b [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
8#include <string>
9
10#include <base/memory/scoped_ptr.h>
11
12#include "update_engine/hardware_interface.h"
Alex Deymo63784a52014-05-28 10:46:14 -070013#include "update_engine/update_manager/config_provider.h"
14#include "update_engine/update_manager/generic_variables.h"
Alex Deymof9f12632014-04-17 13:51:26 -070015
Alex Deymo63784a52014-05-28 10:46:14 -070016namespace chromeos_update_manager {
Alex Deymof9f12632014-04-17 13:51:26 -070017
18// ConfigProvider concrete implementation.
19class RealConfigProvider : public ConfigProvider {
20 public:
21 explicit RealConfigProvider(
22 chromeos_update_engine::HardwareInterface* hardware)
23 : hardware_(hardware) {}
24
Alex Deymo42c30c32014-04-24 18:41:18 -070025 // Initializes the provider and returns whether it succeeded.
26 bool Init();
27
Alex Deymof9f12632014-04-17 13:51:26 -070028 Variable<bool>* var_is_oobe_enabled() override {
29 return var_is_oobe_enabled_.get();
30 }
31
32 private:
Alex Deymo63784a52014-05-28 10:46:14 -070033 friend class UmRealConfigProviderTest;
Alex Deymof9f12632014-04-17 13:51:26 -070034
Alex Deymof9f12632014-04-17 13:51:26 -070035 // Used for testing. Sets the root prefix, which is by default "". Call this
36 // method before calling Init() in order to mock out the place where the files
37 // are being read from.
38 void SetRootPrefix(const std::string& prefix) {
39 root_prefix_ = prefix;
40 }
41
42 scoped_ptr<ConstCopyVariable<bool>> var_is_oobe_enabled_;
43
44 chromeos_update_engine::HardwareInterface* hardware_;
45
46 // Prefix to prepend to the file paths. Useful for testing.
47 std::string root_prefix_;
48
49 DISALLOW_COPY_AND_ASSIGN(RealConfigProvider);
50};
51
Alex Deymo63784a52014-05-28 10:46:14 -070052} // namespace chromeos_update_manager
Alex Deymof9f12632014-04-17 13:51:26 -070053
Gilad Arnold48415f12014-06-27 07:10:58 -070054#endif // UPDATE_ENGINE_UPDATE_MANAGER_REAL_CONFIG_PROVIDER_H_