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.
5 #ifndef EXTENSIONS_BROWSER_API_SYSTEM_CPU_CPU_INFO_PROVIDER_H_
6 #define EXTENSIONS_BROWSER_API_SYSTEM_CPU_CPU_INFO_PROVIDER_H_
11 #include "base/lazy_instance.h"
12 #include "extensions/browser/api/system_info/system_info_provider.h"
13 #include "extensions/common/api/system_cpu.h"
15 namespace extensions
{
17 class CpuInfoProvider
: public SystemInfoProvider
{
19 // Return the single shared instance of CpuInfoProvider.
20 static CpuInfoProvider
* Get();
22 const api::system_cpu::CpuInfo
& cpu_info() const { return info_
; }
24 static void InitializeForTesting(scoped_refptr
<CpuInfoProvider
> provider
);
27 friend class MockCpuInfoProviderImpl
;
30 ~CpuInfoProvider() override
;
32 // Platform specific implementation for querying the CPU time information
33 // for each processor.
34 virtual bool QueryCpuTimePerProcessor(
35 std::vector
<linked_ptr
<api::system_cpu::ProcessorInfo
>>* infos
);
37 // Overriden from SystemInfoProvider.
38 bool QueryInfo() override
;
40 // Creates a list of codenames for currently active features.
41 std::vector
<std::string
> GetFeatures() const;
43 // The last information filled up by QueryInfo and is accessed on multiple
44 // threads, but the whole class is being guarded by SystemInfoProvider base
47 // |info_| is accessed on the UI thread while |is_waiting_for_completion_| is
48 // false and on the sequenced worker pool while |is_waiting_for_completion_|
50 api::system_cpu::CpuInfo info_
;
52 static base::LazyInstance
<scoped_refptr
<CpuInfoProvider
> > provider_
;
55 DISALLOW_COPY_AND_ASSIGN(CpuInfoProvider
);
58 } // namespace extensions
60 #endif // EXTENSIONS_BROWSER_API_SYSTEM_CPU_CPU_INFO_PROVIDER_H_