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

Unified 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: Add clarifying comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/system/fake_statistics_provider.h ('k') | chromeos/system/mock_statistics_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/system/fake_statistics_provider.cc
diff --git a/chromeos/system/fake_statistics_provider.cc b/chromeos/system/fake_statistics_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e9f530b88b2cc3e81de912c9decf2683e63ba1b5
--- /dev/null
+++ b/chromeos/system/fake_statistics_provider.cc
@@ -0,0 +1,68 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chromeos/system/fake_statistics_provider.h"
+
+namespace chromeos {
+namespace system {
+
+FakeStatisticsProvider::FakeStatisticsProvider() {
+}
+
+FakeStatisticsProvider::~FakeStatisticsProvider() {
+}
+
+void FakeStatisticsProvider::StartLoadingMachineStatistics(
+ const scoped_refptr<base::TaskRunner>& file_task_runner,
+ bool load_oem_manifest) {
+}
+
+bool FakeStatisticsProvider::GetMachineStatistic(const std::string& name,
+ std::string* result) {
+ std::map<std::string, std::string>::const_iterator match =
+ machine_statistics_.find(name);
+ if (match != machine_statistics_.end() && result)
+ *result = match->second;
+ return match != machine_statistics_.end();
+}
+
+bool FakeStatisticsProvider::GetMachineFlag(const std::string& name,
+ bool* result) {
+ std::map<std::string, bool>::const_iterator match = machine_flags_.find(name);
+ if (match != machine_flags_.end() && result)
+ *result = match->second;
+ return match != machine_flags_.end();
+}
+
+void FakeStatisticsProvider::Shutdown() {
+}
+
+void FakeStatisticsProvider::SetMachineStatistic(const std::string& key,
+ const std::string& value) {
+ machine_statistics_[key] = value;
+}
+
+void FakeStatisticsProvider::ClearMachineStatistic(const std::string& key) {
+ machine_statistics_.erase(key);
+}
+
+void FakeStatisticsProvider::SetMachineFlag(const std::string& key,
+ bool value) {
+ machine_flags_[key] = value;
+}
+
+void FakeStatisticsProvider::ClearMachineFlag(const std::string& key) {
+ machine_flags_.erase(key);
+}
+
+ScopedFakeStatisticsProvider::ScopedFakeStatisticsProvider() {
+ StatisticsProvider::SetTestProvider(this);
+}
+
+ScopedFakeStatisticsProvider::~ScopedFakeStatisticsProvider() {
+ StatisticsProvider::SetTestProvider(NULL);
+}
+
+} // namespace system
+} // namespace chromeos
« no previous file with comments | « chromeos/system/fake_statistics_provider.h ('k') | chromeos/system/mock_statistics_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698