| 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 260 |
| 261 if (load_oem_manifest) { | 261 if (load_oem_manifest) { |
| 262 // If kAppOemManifestFile switch is specified, load OEM Manifest file. | 262 // If kAppOemManifestFile switch is specified, load OEM Manifest file. |
| 263 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 263 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 264 if (command_line->HasSwitch(switches::kAppOemManifestFile)) { | 264 if (command_line->HasSwitch(switches::kAppOemManifestFile)) { |
| 265 LoadOemManifestFromFile( | 265 LoadOemManifestFromFile( |
| 266 command_line->GetSwitchValuePath(switches::kAppOemManifestFile)); | 266 command_line->GetSwitchValuePath(switches::kAppOemManifestFile)); |
| 267 } else if (base::SysInfo::IsRunningOnChromeOS()) { | 267 } else if (base::SysInfo::IsRunningOnChromeOS()) { |
| 268 LoadOemManifestFromFile(base::FilePath(kOemManifestFilePath)); | 268 LoadOemManifestFromFile(base::FilePath(kOemManifestFilePath)); |
| 269 } | 269 } |
| 270 oem_manifest_loaded_ = true; | |
| 271 } | 270 } |
| 272 | 271 |
| 273 if (!base::SysInfo::IsRunningOnChromeOS() && | 272 if (!base::SysInfo::IsRunningOnChromeOS() && |
| 274 machine_info_.find(kSerialNumber) == machine_info_.end()) { | 273 machine_info_.find(kSerialNumber) == machine_info_.end()) { |
| 275 // Set stub value for testing. A time value is appended to avoid clashes of | 274 // Set stub value for testing. A time value is appended to avoid clashes of |
| 276 // the same serial for the same domain, which would invalidate earlier | 275 // the same serial for the same domain, which would invalidate earlier |
| 277 // enrollments. A fake /tmp/machine-info file should be used instead if | 276 // enrollments. A fake /tmp/machine-info file should be used instead if |
| 278 // a stable serial is needed, e.g. to test re-enrollment. | 277 // a stable serial is needed, e.g. to test re-enrollment. |
| 279 base::TimeDelta time = base::Time::Now() - base::Time::UnixEpoch(); | 278 base::TimeDelta time = base::Time::Now() - base::Time::UnixEpoch(); |
| 280 machine_info_[kSerialNumber] = | 279 machine_info_[kSerialNumber] = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 299 } | 298 } |
| 300 machine_info_[kOemDeviceRequisitionKey] = | 299 machine_info_[kOemDeviceRequisitionKey] = |
| 301 oem_manifest.device_requisition; | 300 oem_manifest.device_requisition; |
| 302 machine_flags_[kOemIsEnterpriseManagedKey] = | 301 machine_flags_[kOemIsEnterpriseManagedKey] = |
| 303 oem_manifest.enterprise_managed; | 302 oem_manifest.enterprise_managed; |
| 304 machine_flags_[kOemCanExitEnterpriseEnrollmentKey] = | 303 machine_flags_[kOemCanExitEnterpriseEnrollmentKey] = |
| 305 oem_manifest.can_exit_enrollment; | 304 oem_manifest.can_exit_enrollment; |
| 306 machine_flags_[kOemKeyboardDrivenOobeKey] = | 305 machine_flags_[kOemKeyboardDrivenOobeKey] = |
| 307 oem_manifest.keyboard_driven_oobe; | 306 oem_manifest.keyboard_driven_oobe; |
| 308 | 307 |
| 308 oem_manifest_loaded_ = true; |
| 309 VLOG(1) << "Loaded OEM Manifest statistics from " << file.value(); | 309 VLOG(1) << "Loaded OEM Manifest statistics from " << file.value(); |
| 310 } | 310 } |
| 311 | 311 |
| 312 StatisticsProviderImpl* StatisticsProviderImpl::GetInstance() { | 312 StatisticsProviderImpl* StatisticsProviderImpl::GetInstance() { |
| 313 return Singleton<StatisticsProviderImpl, | 313 return Singleton<StatisticsProviderImpl, |
| 314 DefaultSingletonTraits<StatisticsProviderImpl> >::get(); | 314 DefaultSingletonTraits<StatisticsProviderImpl> >::get(); |
| 315 } | 315 } |
| 316 | 316 |
| 317 static StatisticsProvider* g_test_statistics_provider = NULL; | 317 static StatisticsProvider* g_test_statistics_provider = NULL; |
| 318 | 318 |
| 319 // static | 319 // static |
| 320 StatisticsProvider* StatisticsProvider::GetInstance() { | 320 StatisticsProvider* StatisticsProvider::GetInstance() { |
| 321 if (g_test_statistics_provider) | 321 if (g_test_statistics_provider) |
| 322 return g_test_statistics_provider; | 322 return g_test_statistics_provider; |
| 323 return StatisticsProviderImpl::GetInstance(); | 323 return StatisticsProviderImpl::GetInstance(); |
| 324 } | 324 } |
| 325 | 325 |
| 326 // static | 326 // static |
| 327 void StatisticsProvider::SetTestProvider(StatisticsProvider* test_provider) { | 327 void StatisticsProvider::SetTestProvider(StatisticsProvider* test_provider) { |
| 328 g_test_statistics_provider = test_provider; | 328 g_test_statistics_provider = test_provider; |
| 329 } | 329 } |
| 330 | 330 |
| 331 } // namespace system | 331 } // namespace system |
| 332 } // namespace chromeos | 332 } // namespace chromeos |
| OLD | NEW |