| 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 GetEnterpriseMachineID() to |
| 45 // cover legacy 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 (possibly due to the device having already |
| 115 // been enrolled or claimed by a local user), an empty string is returned. |
| 116 // Caveat: For lumpy, the last letter is ommitted from the serial number for |
| 117 // historical reasons. |
| 118 // TODO(tnagel): Drop "Enterprise" from the method name and remove lumpy |
| 119 // special casing after lumpy EOL. |
| 120 std::string GetEnterpriseMachineID(); |
| 121 |
| 112 // Cancels any pending file operations. | 122 // Cancels any pending file operations. |
| 113 virtual void Shutdown() = 0; | 123 virtual void Shutdown() = 0; |
| 114 | 124 |
| 115 // Returns true if the machine is a VM. | 125 // Returns true if the machine is a VM. |
| 116 virtual bool IsRunningOnVm() = 0; | 126 virtual bool IsRunningOnVm() = 0; |
| 117 | 127 |
| 118 // Get the Singleton instance. | 128 // Get the Singleton instance. |
| 119 static StatisticsProvider* GetInstance(); | 129 static StatisticsProvider* GetInstance(); |
| 120 | 130 |
| 121 // Set the instance returned by GetInstance() for testing. | 131 // Set the instance returned by GetInstance() for testing. |
| 122 static void SetTestProvider(StatisticsProvider* test_provider); | 132 static void SetTestProvider(StatisticsProvider* test_provider); |
| 123 | 133 |
| 124 protected: | 134 protected: |
| 125 virtual ~StatisticsProvider() {} | 135 virtual ~StatisticsProvider() {} |
| 126 }; | 136 }; |
| 127 | 137 |
| 128 } // namespace system | 138 } // namespace system |
| 129 } // namespace chromeos | 139 } // namespace chromeos |
| 130 | 140 |
| 131 #endif // CHROMEOS_SYSTEM_STATISTICS_PROVIDER_H_ | 141 #endif // CHROMEOS_SYSTEM_STATISTICS_PROVIDER_H_ |
| OLD | NEW |