Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Side by Side Diff: chromeos/system/fake_statistics_provider.cc

Issue 644413003: Replace MockStatisticsProvider with FakeStatisticsProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium 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
5 #include "chromeos/system/fake_statistics_provider.h"
6
7 namespace chromeos {
8 namespace system {
9
10 FakeStatisticsProvider::FakeStatisticsProvider() {
11 }
12
13 FakeStatisticsProvider::~FakeStatisticsProvider() {
14 }
15
16 void FakeStatisticsProvider::StartLoadingMachineStatistics(
17 const scoped_refptr<base::TaskRunner>& file_task_runner,
18 bool load_oem_manifest) {
19 }
20
21 bool FakeStatisticsProvider::GetMachineStatistic(const std::string& name,
22 std::string* result) {
23 std::map<std::string, std::string>::const_iterator match =
24 machine_statistics_.find(name);
25 if (match != machine_statistics_.end() && result)
26 *result = match->second;
27 return match != machine_statistics_.end();
28 }
29
30 bool FakeStatisticsProvider::GetMachineFlag(const std::string& name,
31 bool* result) {
32 std::map<std::string, bool>::const_iterator match = machine_flags_.find(name);
33 if (match != machine_flags_.end() && result)
34 *result = match->second;
35 return match != machine_flags_.end();
36 }
37
38 void FakeStatisticsProvider::Shutdown() {
39 }
40
41 void FakeStatisticsProvider::SetMachineStatistic(const std::string& key,
42 const std::string& value) {
43 machine_statistics_[key] = value;
44 }
45
46 void FakeStatisticsProvider::ClearMachineStatistic(const std::string& key) {
47 machine_statistics_.erase(key);
48 }
49
50 void FakeStatisticsProvider::SetMachineFlag(const std::string& key,
51 bool value) {
52 machine_flags_[key] = value;
53 }
54
55 void FakeStatisticsProvider::ClearMachineFlag(const std::string& key) {
56 machine_flags_.erase(key);
57 }
58
59 ScopedFakeStatisticsProvider::ScopedFakeStatisticsProvider() {
60 StatisticsProvider::SetTestProvider(this);
61 }
62
63 ScopedFakeStatisticsProvider::~ScopedFakeStatisticsProvider() {
64 StatisticsProvider::SetTestProvider(NULL);
65 }
66
67 } // namespace system
68 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698