| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_STATISTICS_PROVIDER_H_ | 5 #ifndef CHROMEOS_SYSTEM_STATISTICS_PROVIDER_H_ |
| 6 #define CHROMEOS_SYSTEM_STATISTICS_PROVIDER_H_ | 6 #define CHROMEOS_SYSTEM_STATISTICS_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // Firmware type and associated values. The values are from crossystem output | 34 // Firmware type and associated values. The values are from crossystem output |
| 35 // for the mainfw_type key. Normal and developer correspond to Chrome OS | 35 // for the mainfw_type key. Normal and developer correspond to Chrome OS |
| 36 // firmware with MP and developer keys respectively, nonchrome indicates the | 36 // firmware with MP and developer keys respectively, nonchrome indicates the |
| 37 // machine doesn't run on Chrome OS firmware. See crossystem source for more | 37 // machine doesn't run on Chrome OS firmware. See crossystem source for more |
| 38 // details. | 38 // details. |
| 39 CHROMEOS_EXPORT extern const char kFirmwareTypeKey[]; | 39 CHROMEOS_EXPORT extern const char kFirmwareTypeKey[]; |
| 40 CHROMEOS_EXPORT extern const char kFirmwareTypeValueDeveloper[]; | 40 CHROMEOS_EXPORT extern const char kFirmwareTypeValueDeveloper[]; |
| 41 CHROMEOS_EXPORT extern const char kFirmwareTypeValueNonchrome[]; | 41 CHROMEOS_EXPORT extern const char kFirmwareTypeValueNonchrome[]; |
| 42 CHROMEOS_EXPORT extern const char kFirmwareTypeValueNormal[]; | 42 CHROMEOS_EXPORT extern const char kFirmwareTypeValueNormal[]; |
| 43 | 43 |
| 44 // Serial number key (only VPD v2+ devices). Use GetMachineID() to cover legacy |
| 45 // devices. |
| 46 CHROMEOS_EXPORT extern const char kSerialNumberKey[]; |
| 47 |
| 44 // HWID key. | 48 // HWID key. |
| 45 CHROMEOS_EXPORT extern const char kHardwareClassKey[]; | 49 CHROMEOS_EXPORT extern const char kHardwareClassKey[]; |
| 46 | 50 |
| 47 // Key/values reporting if Chrome OS is running in a VM or not. These values are | 51 // Key/values reporting if Chrome OS is running in a VM or not. These values are |
| 48 // read from crossystem output. See crossystem source for VM detection logic. | 52 // read from crossystem output. See crossystem source for VM detection logic. |
| 49 CHROMEOS_EXPORT extern const char kIsVmKey[]; | 53 CHROMEOS_EXPORT extern const char kIsVmKey[]; |
| 50 CHROMEOS_EXPORT extern const char kIsVmValueTrue[]; | 54 CHROMEOS_EXPORT extern const char kIsVmValueTrue[]; |
| 51 CHROMEOS_EXPORT extern const char kIsVmValueFalse[]; | 55 CHROMEOS_EXPORT extern const char kIsVmValueFalse[]; |
| 52 | 56 |
| 53 // OEM customization flag that permits exiting enterprise enrollment flow in | 57 // OEM customization flag that permits exiting enterprise enrollment flow in |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Returns true if the named machine statistic (e.g. "hardware_class") is | 100 // Returns true if the named machine statistic (e.g. "hardware_class") is |
| 97 // found and stores it in |result| (if provided). Probing for the existance of | 101 // found and stores it in |result| (if provided). Probing for the existance of |
| 98 // a statistic by setting |result| to nullptr supresses the usual warning in | 102 // a statistic by setting |result| to nullptr supresses the usual warning in |
| 99 // case the statistic is not found. Safe to call from any thread except the | 103 // case the statistic is not found. Safe to call from any thread except the |
| 100 // task runner passed to Initialize() (e.g. FILE). This may block if called | 104 // task runner passed to Initialize() (e.g. FILE). This may block if called |
| 101 // early before the statistics are loaded from disk. | 105 // early before the statistics are loaded from disk. |
| 102 // StartLoadingMachineStatistics() must be called before this. | 106 // StartLoadingMachineStatistics() must be called before this. |
| 103 virtual bool GetMachineStatistic(const std::string& name, | 107 virtual bool GetMachineStatistic(const std::string& name, |
| 104 std::string* result) = 0; | 108 std::string* result) = 0; |
| 105 | 109 |
| 106 // Checks whether a machine statistic is present (without logging a warning). | |
| 107 bool HasMachineStatistic(const std::string& name); | |
| 108 | |
| 109 // Similar to GetMachineStatistic for boolean flags. | 110 // Similar to GetMachineStatistic for boolean flags. |
| 110 virtual bool GetMachineFlag(const std::string& name, bool* result) = 0; | 111 virtual bool GetMachineFlag(const std::string& name, bool* result) = 0; |
| 111 | 112 |
| 113 // Returns the machine serial number after examining a set of well-known |
| 114 // keys. In case no serial is found, an empty string is returned. |
| 115 std::string GetMachineID(); |
| 116 |
| 112 // Cancels any pending file operations. | 117 // Cancels any pending file operations. |
| 113 virtual void Shutdown() = 0; | 118 virtual void Shutdown() = 0; |
| 114 | 119 |
| 115 // Returns true if the machine is a VM. | 120 // Returns true if the machine is a VM. |
| 116 virtual bool IsRunningOnVm() = 0; | 121 virtual bool IsRunningOnVm() = 0; |
| 117 | 122 |
| 118 // Get the Singleton instance. | 123 // Get the Singleton instance. |
| 119 static StatisticsProvider* GetInstance(); | 124 static StatisticsProvider* GetInstance(); |
| 120 | 125 |
| 121 // Set the instance returned by GetInstance() for testing. | 126 // Set the instance returned by GetInstance() for testing. |
| 122 static void SetTestProvider(StatisticsProvider* test_provider); | 127 static void SetTestProvider(StatisticsProvider* test_provider); |
| 123 | 128 |
| 124 protected: | 129 protected: |
| 125 virtual ~StatisticsProvider() {} | 130 virtual ~StatisticsProvider() {} |
| 126 }; | 131 }; |
| 127 | 132 |
| 128 } // namespace system | 133 } // namespace system |
| 129 } // namespace chromeos | 134 } // namespace chromeos |
| 130 | 135 |
| 131 #endif // CHROMEOS_SYSTEM_STATISTICS_PROVIDER_H_ | 136 #endif // CHROMEOS_SYSTEM_STATISTICS_PROVIDER_H_ |
| OLD | NEW |