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/command_line.h" |
9 #include "base/file_path.h" | 10 #include "base/file_path.h" |
10 #include "base/file_util.h" | 11 #include "base/file_util.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
13 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
14 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
15 #include "base/time.h" | 16 #include "base/time.h" |
16 #include "base/chromeos/chromeos_version.h" | 17 #include "base/chromeos/chromeos_version.h" |
17 #include "chrome/browser/chromeos/system/name_value_pairs_parser.h" | 18 #include "chrome/browser/chromeos/system/name_value_pairs_parser.h" |
18 #include "chrome/common/child_process_logging.h" | 19 #include "chrome/common/child_process_logging.h" |
| 20 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
20 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
21 | 23 |
22 using content::BrowserThread; | 24 using content::BrowserThread; |
23 | 25 |
24 namespace chromeos { | 26 namespace chromeos { |
25 namespace system { | 27 namespace system { |
26 namespace { | 28 namespace { |
27 | 29 |
28 // 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 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 return Singleton<StatisticsProviderImpl, | 205 return Singleton<StatisticsProviderImpl, |
204 DefaultSingletonTraits<StatisticsProviderImpl> >::get(); | 206 DefaultSingletonTraits<StatisticsProviderImpl> >::get(); |
205 } | 207 } |
206 | 208 |
207 // The stub StatisticsProvider implementation used on Linux desktop. | 209 // The stub StatisticsProvider implementation used on Linux desktop. |
208 class StatisticsProviderStubImpl : public StatisticsProvider { | 210 class StatisticsProviderStubImpl : public StatisticsProvider { |
209 public: | 211 public: |
210 // StatisticsProvider implementation: | 212 // StatisticsProvider implementation: |
211 virtual bool GetMachineStatistic(const std::string& name, | 213 virtual bool GetMachineStatistic(const std::string& name, |
212 std::string* result) OVERRIDE { | 214 std::string* result) OVERRIDE { |
| 215 if (name == "CHROMEOS_RELEASE_BOARD") { |
| 216 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 217 if (command_line->HasSwitch(switches::kChromeOSReleaseBoard)) { |
| 218 *result = command_line-> |
| 219 GetSwitchValueASCII(switches::kChromeOSReleaseBoard); |
| 220 return true; |
| 221 } |
| 222 } |
213 return false; | 223 return false; |
214 } | 224 } |
215 | 225 |
216 static StatisticsProviderStubImpl* GetInstance() { | 226 static StatisticsProviderStubImpl* GetInstance() { |
217 return Singleton<StatisticsProviderStubImpl, | 227 return Singleton<StatisticsProviderStubImpl, |
218 DefaultSingletonTraits<StatisticsProviderStubImpl> >::get(); | 228 DefaultSingletonTraits<StatisticsProviderStubImpl> >::get(); |
219 } | 229 } |
220 | 230 |
221 private: | 231 private: |
222 friend struct DefaultSingletonTraits<StatisticsProviderStubImpl>; | 232 friend struct DefaultSingletonTraits<StatisticsProviderStubImpl>; |
223 | 233 |
224 StatisticsProviderStubImpl() { | 234 StatisticsProviderStubImpl() { |
225 } | 235 } |
226 | 236 |
227 DISALLOW_COPY_AND_ASSIGN(StatisticsProviderStubImpl); | 237 DISALLOW_COPY_AND_ASSIGN(StatisticsProviderStubImpl); |
228 }; | 238 }; |
229 | 239 |
230 StatisticsProvider* StatisticsProvider::GetInstance() { | 240 StatisticsProvider* StatisticsProvider::GetInstance() { |
231 if (base::chromeos::IsRunningOnChromeOS()) { | 241 if (base::chromeos::IsRunningOnChromeOS()) { |
232 return StatisticsProviderImpl::GetInstance(); | 242 return StatisticsProviderImpl::GetInstance(); |
233 } else { | 243 } else { |
234 return StatisticsProviderStubImpl::GetInstance(); | 244 return StatisticsProviderStubImpl::GetInstance(); |
235 } | 245 } |
236 } | 246 } |
237 | 247 |
238 } // namespace system | 248 } // namespace system |
239 } // namespace chromeos | 249 } // namespace chromeos |
OLD | NEW |