OLD | NEW |
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 #ifndef CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_ | 5 #ifndef CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_ |
6 #define CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_ | 6 #define CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chromeos/chromeos_export.h" |
12 #include "chromeos/system/statistics_provider.h" | 13 #include "chromeos/system/statistics_provider.h" |
13 | 14 |
14 namespace chromeos { | 15 namespace chromeos { |
15 namespace system { | 16 namespace system { |
16 | 17 |
17 // A fake StatisticsProvider implementation that is useful in tests. | 18 // A fake StatisticsProvider implementation that is useful in tests. |
18 class FakeStatisticsProvider : public StatisticsProvider { | 19 class CHROMEOS_EXPORT FakeStatisticsProvider : public StatisticsProvider { |
19 public: | 20 public: |
20 FakeStatisticsProvider(); | 21 FakeStatisticsProvider(); |
21 ~FakeStatisticsProvider() override; | 22 ~FakeStatisticsProvider() override; |
22 | 23 |
23 // StatisticsProvider implementation: | 24 // StatisticsProvider implementation: |
24 void StartLoadingMachineStatistics( | 25 void StartLoadingMachineStatistics( |
25 const scoped_refptr<base::TaskRunner>& file_task_runner, | 26 const scoped_refptr<base::TaskRunner>& file_task_runner, |
26 bool load_oem_manifest) override; | 27 bool load_oem_manifest) override; |
27 bool GetMachineStatistic(const std::string& name, | 28 bool GetMachineStatistic(const std::string& name, |
28 std::string* result) override; | 29 std::string* result) override; |
29 bool GetMachineFlag(const std::string& name, bool* result) override; | 30 bool GetMachineFlag(const std::string& name, bool* result) override; |
30 void Shutdown() override; | 31 void Shutdown() override; |
31 bool IsRunningOnVm() override; | 32 bool IsRunningOnVm() override; |
32 | 33 |
33 void SetMachineStatistic(const std::string& key, const std::string& value); | 34 void SetMachineStatistic(const std::string& key, const std::string& value); |
34 void ClearMachineStatistic(const std::string& key); | 35 void ClearMachineStatistic(const std::string& key); |
35 void SetMachineFlag(const std::string& key, bool value); | 36 void SetMachineFlag(const std::string& key, bool value); |
36 void ClearMachineFlag(const std::string& key); | 37 void ClearMachineFlag(const std::string& key); |
37 | 38 |
38 private: | 39 private: |
39 std::map<std::string, std::string> machine_statistics_; | 40 std::map<std::string, std::string> machine_statistics_; |
40 std::map<std::string, bool> machine_flags_; | 41 std::map<std::string, bool> machine_flags_; |
41 | 42 |
42 DISALLOW_COPY_AND_ASSIGN(FakeStatisticsProvider); | 43 DISALLOW_COPY_AND_ASSIGN(FakeStatisticsProvider); |
43 }; | 44 }; |
44 | 45 |
45 // A convenience subclass that automatically registers itself as the test | 46 // A convenience subclass that automatically registers itself as the test |
46 // StatisticsProvider during construction and cleans up at destruction. | 47 // StatisticsProvider during construction and cleans up at destruction. |
47 class ScopedFakeStatisticsProvider : public FakeStatisticsProvider { | 48 class CHROMEOS_EXPORT ScopedFakeStatisticsProvider |
| 49 : public FakeStatisticsProvider { |
48 public: | 50 public: |
49 ScopedFakeStatisticsProvider(); | 51 ScopedFakeStatisticsProvider(); |
50 ~ScopedFakeStatisticsProvider() override; | 52 ~ScopedFakeStatisticsProvider() override; |
51 | 53 |
52 private: | 54 private: |
53 DISALLOW_COPY_AND_ASSIGN(ScopedFakeStatisticsProvider); | 55 DISALLOW_COPY_AND_ASSIGN(ScopedFakeStatisticsProvider); |
54 }; | 56 }; |
55 | 57 |
56 } // namespace system | 58 } // namespace system |
57 } // namespace chromeos | 59 } // namespace chromeos |
58 | 60 |
59 #endif // CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_ | 61 #endif // CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_ |
OLD | NEW |