- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / api / system_cpu / cpu_info_provider.cc
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/api/system_cpu/cpu_info_provider.h"
6
7 #include "base/sys_info.h"
8
9 namespace extensions {
10
11 using api::system_cpu::CpuInfo;
12
13 // Static member intialization.
14 base::LazyInstance<scoped_refptr<CpuInfoProvider> >
15     CpuInfoProvider::provider_ = LAZY_INSTANCE_INITIALIZER;
16
17 CpuInfoProvider::CpuInfoProvider() {}
18
19 CpuInfoProvider::~CpuInfoProvider() {}
20
21 const CpuInfo& CpuInfoProvider::cpu_info() const {
22   return info_;
23 }
24
25 void CpuInfoProvider::InitializeForTesting(
26     scoped_refptr<CpuInfoProvider> provider) {
27   DCHECK(provider.get() != NULL);
28   provider_.Get() = provider;
29 }
30
31 bool CpuInfoProvider::QueryInfo() {
32   info_.num_of_processors = base::SysInfo::NumberOfProcessors();
33   info_.arch_name = base::SysInfo::OperatingSystemArchitecture();
34   info_.model_name = base::SysInfo::CPUModelName();
35   return true;
36 }
37
38 // static
39 CpuInfoProvider* CpuInfoProvider::Get() {
40   if (provider_.Get().get() == NULL)
41     provider_.Get() = new CpuInfoProvider();
42   return provider_.Get();
43 }
44
45 }  // namespace extensions