| 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 #include "chromeos/system/statistics_provider.h" | 5 #include "chromeos/system/statistics_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // Path to the tool used to get system info, and delimiters for the output | 30 // Path to the tool used to get system info, and delimiters for the output |
| 31 // format of the tool. | 31 // format of the tool. |
| 32 const char* kCrosSystemTool[] = { "/usr/bin/crossystem" }; | 32 const char* kCrosSystemTool[] = { "/usr/bin/crossystem" }; |
| 33 const char kCrosSystemEq[] = "="; | 33 const char kCrosSystemEq[] = "="; |
| 34 const char kCrosSystemDelim[] = "\n"; | 34 const char kCrosSystemDelim[] = "\n"; |
| 35 const char kCrosSystemCommentDelim[] = "#"; | 35 const char kCrosSystemCommentDelim[] = "#"; |
| 36 const char kCrosSystemUnknownValue[] = "(error)"; | 36 const char kCrosSystemUnknownValue[] = "(error)"; |
| 37 | 37 |
| 38 const char kHardwareClassCrosSystemKey[] = "hwid"; | 38 const char kHardwareClassCrosSystemKey[] = "hwid"; |
| 39 const char kUnknownHardwareClass[] = "unknown"; | 39 const char kUnknownHardwareClass[] = "unknown"; |
| 40 const char kSerialNumber[] = "sn"; | |
| 41 | 40 |
| 42 // File to get machine hardware info from, and key/value delimiters of | 41 // File to get machine hardware info from, and key/value delimiters of |
| 43 // the file. | 42 // the file. |
| 44 // /tmp/machine-info is generated by platform/init/chromeos_startup. | 43 // /tmp/machine-info is generated by platform/init/chromeos_startup. |
| 45 const char kMachineHardwareInfoFile[] = "/tmp/machine-info"; | 44 const char kMachineHardwareInfoFile[] = "/tmp/machine-info"; |
| 46 const char kMachineHardwareInfoEq[] = "="; | 45 const char kMachineHardwareInfoEq[] = "="; |
| 47 const char kMachineHardwareInfoDelim[] = " \n"; | 46 const char kMachineHardwareInfoDelim[] = " \n"; |
| 48 | 47 |
| 49 // File to get ECHO coupon info from, and key/value delimiters of | 48 // File to get ECHO coupon info from, and key/value delimiters of |
| 50 // the file. | 49 // the file. |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 262 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 264 if (command_line->HasSwitch(switches::kAppOemManifestFile)) { | 263 if (command_line->HasSwitch(switches::kAppOemManifestFile)) { |
| 265 LoadOemManifestFromFile( | 264 LoadOemManifestFromFile( |
| 266 command_line->GetSwitchValuePath(switches::kAppOemManifestFile)); | 265 command_line->GetSwitchValuePath(switches::kAppOemManifestFile)); |
| 267 } else if (base::SysInfo::IsRunningOnChromeOS()) { | 266 } else if (base::SysInfo::IsRunningOnChromeOS()) { |
| 268 LoadOemManifestFromFile(base::FilePath(kOemManifestFilePath)); | 267 LoadOemManifestFromFile(base::FilePath(kOemManifestFilePath)); |
| 269 } | 268 } |
| 270 oem_manifest_loaded_ = true; | 269 oem_manifest_loaded_ = true; |
| 271 } | 270 } |
| 272 | 271 |
| 273 if (!base::SysInfo::IsRunningOnChromeOS() && | |
| 274 machine_info_.find(kSerialNumber) == machine_info_.end()) { | |
| 275 // Set stub value for testing. | |
| 276 machine_info_[kSerialNumber] = "stub_serial_number"; | |
| 277 } | |
| 278 | |
| 279 // Finished loading the statistics. | 272 // Finished loading the statistics. |
| 280 on_statistics_loaded_.Signal(); | 273 on_statistics_loaded_.Signal(); |
| 281 VLOG(1) << "Finished loading statistics."; | 274 VLOG(1) << "Finished loading statistics."; |
| 282 } | 275 } |
| 283 | 276 |
| 284 void StatisticsProviderImpl::LoadOemManifestFromFile( | 277 void StatisticsProviderImpl::LoadOemManifestFromFile( |
| 285 const base::FilePath& file) { | 278 const base::FilePath& file) { |
| 286 // Called from LoadMachineStatistics. Check cancellation_flag_ again here. | 279 // Called from LoadMachineStatistics. Check cancellation_flag_ again here. |
| 287 if (cancellation_flag_.IsSet()) | 280 if (cancellation_flag_.IsSet()) |
| 288 return; | 281 return; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 318 return StatisticsProviderImpl::GetInstance(); | 311 return StatisticsProviderImpl::GetInstance(); |
| 319 } | 312 } |
| 320 | 313 |
| 321 // static | 314 // static |
| 322 void StatisticsProvider::SetTestProvider(StatisticsProvider* test_provider) { | 315 void StatisticsProvider::SetTestProvider(StatisticsProvider* test_provider) { |
| 323 g_test_statistics_provider = test_provider; | 316 g_test_statistics_provider = test_provider; |
| 324 } | 317 } |
| 325 | 318 |
| 326 } // namespace system | 319 } // namespace system |
| 327 } // namespace chromeos | 320 } // namespace chromeos |
| OLD | NEW |