Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/system/statistics_provider.h" | 5 #include "chrome/browser/chromeos/system/statistics_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/chromeos/chromeos_version.h" | 8 #include "base/chromeos/chromeos_version.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 // | 101 // |
| 102 // If you see the warning appeared for regular sessions, it probably | 102 // If you see the warning appeared for regular sessions, it probably |
| 103 // means that there is new client code that uses the statistics in the | 103 // means that there is new client code that uses the statistics in the |
| 104 // very early stage of the browser startup. The statistic name should be | 104 // very early stage of the browser startup. The statistic name should be |
| 105 // helpful to identify the caller. | 105 // helpful to identify the caller. |
| 106 if (!on_statistics_loaded_.IsSignaled()) { | 106 if (!on_statistics_loaded_.IsSignaled()) { |
| 107 LOG(WARNING) << "Waiting to load statistics. Requested statistic: " | 107 LOG(WARNING) << "Waiting to load statistics. Requested statistic: " |
| 108 << name; | 108 << name; |
| 109 on_statistics_loaded_.TimedWait(base::TimeDelta::FromSeconds(kTimeoutSecs)); | 109 on_statistics_loaded_.TimedWait(base::TimeDelta::FromSeconds(kTimeoutSecs)); |
| 110 } | 110 } |
| 111 | 111 |
|
petkov
2012/04/19 13:47:01
It might be a good idea to add another warning her
Joao da Silva
2012/04/19 16:01:30
Done.
| |
| 112 NameValuePairsParser::NameValueMap::iterator iter = machine_info_.find(name); | 112 NameValuePairsParser::NameValueMap::iterator iter = machine_info_.find(name); |
| 113 if (iter != machine_info_.end()) { | 113 if (iter != machine_info_.end()) { |
| 114 *result = iter->second; | 114 *result = iter->second; |
| 115 return true; | 115 return true; |
| 116 } | 116 } |
| 117 return false; | 117 return false; |
| 118 } | 118 } |
| 119 | 119 |
| 120 // manual_reset needs to be true, as we want to keep the signaled state. | 120 // manual_reset needs to be true, as we want to keep the signaled state. |
| 121 StatisticsProviderImpl::StatisticsProviderImpl() | 121 StatisticsProviderImpl::StatisticsProviderImpl() |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 132 BrowserThread::FILE, | 132 BrowserThread::FILE, |
| 133 FROM_HERE, | 133 FROM_HERE, |
| 134 base::Bind(&StatisticsProviderImpl::LoadMachineStatistics, | 134 base::Bind(&StatisticsProviderImpl::LoadMachineStatistics, |
| 135 base::Unretained(this))); | 135 base::Unretained(this))); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void StatisticsProviderImpl::LoadMachineStatistics() { | 138 void StatisticsProviderImpl::LoadMachineStatistics() { |
| 139 NameValuePairsParser parser(&machine_info_); | 139 NameValuePairsParser parser(&machine_info_); |
| 140 | 140 |
| 141 // Parse all of the key/value pairs from the crossystem tool. | 141 // Parse all of the key/value pairs from the crossystem tool. |
| 142 parser.ParseNameValuePairsFromTool( | 142 if (!parser.ParseNameValuePairsFromTool( |
| 143 arraysize(kCrosSystemTool), kCrosSystemTool, kCrosSystemEq, | 143 arraysize(kCrosSystemTool), kCrosSystemTool, kCrosSystemEq, |
| 144 kCrosSystemDelim, kCrosSystemCommentDelim); | 144 kCrosSystemDelim, kCrosSystemCommentDelim)) { |
| 145 LOG(WARNING) << "There were errors parsing the output of " | |
| 146 << kCrosSystemTool << "."; | |
| 147 } | |
| 145 | 148 |
| 146 // Ensure that the hardware class key is present with the expected | 149 // Ensure that the hardware class key is present with the expected |
| 147 // key name, and if it couldn't be retrieved, that the value is "unknown". | 150 // key name, and if it couldn't be retrieved, that the value is "unknown". |
| 148 std::string hardware_class = machine_info_[kHardwareClassCrosSystemKey]; | 151 std::string hardware_class = machine_info_[kHardwareClassCrosSystemKey]; |
| 149 if (hardware_class.empty() || hardware_class == kCrosSystemUnknownValue) | 152 if (hardware_class.empty() || hardware_class == kCrosSystemUnknownValue) |
| 150 machine_info_[kHardwareClassKey] = kUnknownHardwareClass; | 153 machine_info_[kHardwareClassKey] = kUnknownHardwareClass; |
| 151 else | 154 else |
| 152 machine_info_[kHardwareClassKey] = hardware_class; | 155 machine_info_[kHardwareClassKey] = hardware_class; |
| 153 | 156 |
| 154 parser.GetNameValuePairsFromFile(FilePath(kMachineHardwareInfoFile), | 157 parser.GetNameValuePairsFromFile(FilePath(kMachineHardwareInfoFile), |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 StatisticsProvider* StatisticsProvider::GetInstance() { | 224 StatisticsProvider* StatisticsProvider::GetInstance() { |
| 222 if (base::chromeos::IsRunningOnChromeOS()) { | 225 if (base::chromeos::IsRunningOnChromeOS()) { |
| 223 return StatisticsProviderImpl::GetInstance(); | 226 return StatisticsProviderImpl::GetInstance(); |
| 224 } else { | 227 } else { |
| 225 return StatisticsProviderStubImpl::GetInstance(); | 228 return StatisticsProviderStubImpl::GetInstance(); |
| 226 } | 229 } |
| 227 } | 230 } |
| 228 | 231 |
| 229 } // namespace system | 232 } // namespace system |
| 230 } // namespace chromeos | 233 } // namespace chromeos |
| OLD | NEW |