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

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

Issue 2218703006: Clean up handling of invalid HWID when running ChromeOS in VMs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix after review comments (no functional changes) Created 4 years, 4 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
« no previous file with comments | « chromeos/system/fake_statistics_provider.h ('k') | chromeos/system/statistics_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/system/fake_statistics_provider.h" 5 #include "chromeos/system/fake_statistics_provider.h"
6 6
7 namespace chromeos { 7 namespace chromeos {
8 namespace system { 8 namespace system {
9 9
10 FakeStatisticsProvider::FakeStatisticsProvider() { 10 FakeStatisticsProvider::FakeStatisticsProvider() {
(...skipping 20 matching lines...) Expand all
31 bool* result) { 31 bool* result) {
32 std::map<std::string, bool>::const_iterator match = machine_flags_.find(name); 32 std::map<std::string, bool>::const_iterator match = machine_flags_.find(name);
33 if (match != machine_flags_.end() && result) 33 if (match != machine_flags_.end() && result)
34 *result = match->second; 34 *result = match->second;
35 return match != machine_flags_.end(); 35 return match != machine_flags_.end();
36 } 36 }
37 37
38 void FakeStatisticsProvider::Shutdown() { 38 void FakeStatisticsProvider::Shutdown() {
39 } 39 }
40 40
41 bool FakeStatisticsProvider::IsRunningOnVm() {
42 std::string is_vm;
43 return GetMachineStatistic(kIsVmKey, &is_vm) && is_vm == kIsVmValueTrue;
44 }
45
46
41 void FakeStatisticsProvider::SetMachineStatistic(const std::string& key, 47 void FakeStatisticsProvider::SetMachineStatistic(const std::string& key,
42 const std::string& value) { 48 const std::string& value) {
43 machine_statistics_[key] = value; 49 machine_statistics_[key] = value;
44 } 50 }
45 51
46 void FakeStatisticsProvider::ClearMachineStatistic(const std::string& key) { 52 void FakeStatisticsProvider::ClearMachineStatistic(const std::string& key) {
47 machine_statistics_.erase(key); 53 machine_statistics_.erase(key);
48 } 54 }
49 55
50 void FakeStatisticsProvider::SetMachineFlag(const std::string& key, 56 void FakeStatisticsProvider::SetMachineFlag(const std::string& key,
51 bool value) { 57 bool value) {
52 machine_flags_[key] = value; 58 machine_flags_[key] = value;
53 } 59 }
54 60
55 void FakeStatisticsProvider::ClearMachineFlag(const std::string& key) { 61 void FakeStatisticsProvider::ClearMachineFlag(const std::string& key) {
56 machine_flags_.erase(key); 62 machine_flags_.erase(key);
57 } 63 }
58 64
59 ScopedFakeStatisticsProvider::ScopedFakeStatisticsProvider() { 65 ScopedFakeStatisticsProvider::ScopedFakeStatisticsProvider() {
60 StatisticsProvider::SetTestProvider(this); 66 StatisticsProvider::SetTestProvider(this);
61 } 67 }
62 68
63 ScopedFakeStatisticsProvider::~ScopedFakeStatisticsProvider() { 69 ScopedFakeStatisticsProvider::~ScopedFakeStatisticsProvider() {
64 StatisticsProvider::SetTestProvider(NULL); 70 StatisticsProvider::SetTestProvider(NULL);
65 } 71 }
66 72
67 } // namespace system 73 } // namespace system
68 } // namespace chromeos 74 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/system/fake_statistics_provider.h ('k') | chromeos/system/statistics_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698