OLD | NEW |
| (Empty) |
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 #ifndef CHROME_BROWSER_EXTENSIONS_API_SYSTEM_CPU_CPU_INFO_PROVIDER_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_API_SYSTEM_CPU_CPU_INFO_PROVIDER_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/cpu.h" | |
11 #include "base/lazy_instance.h" | |
12 #include "chrome/browser/extensions/api/system_info/system_info_provider.h" | |
13 #include "chrome/common/extensions/api/system_cpu.h" | |
14 | |
15 namespace extensions { | |
16 | |
17 class CpuInfoProvider : public SystemInfoProvider { | |
18 public: | |
19 // Return the single shared instance of CpuInfoProvider. | |
20 static CpuInfoProvider* Get(); | |
21 | |
22 const api::system_cpu::CpuInfo& cpu_info() const; | |
23 | |
24 static void InitializeForTesting(scoped_refptr<CpuInfoProvider> provider); | |
25 | |
26 private: | |
27 friend class MockCpuInfoProviderImpl; | |
28 | |
29 CpuInfoProvider(); | |
30 virtual ~CpuInfoProvider(); | |
31 | |
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); | |
36 | |
37 // Overriden from SystemInfoProvider. | |
38 virtual bool QueryInfo() OVERRIDE; | |
39 | |
40 // Creates a list of codenames for currently active features. | |
41 std::vector<std::string> GetFeatures() const; | |
42 | |
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 | |
45 // class. | |
46 // | |
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_| | |
49 // is true. | |
50 api::system_cpu::CpuInfo info_; | |
51 | |
52 static base::LazyInstance<scoped_refptr<CpuInfoProvider> > provider_; | |
53 base::CPU cpu_; | |
54 | |
55 DISALLOW_COPY_AND_ASSIGN(CpuInfoProvider); | |
56 }; | |
57 | |
58 } // namespace extensions | |
59 | |
60 #endif // CHROME_BROWSER_EXTENSIONS_API_SYSTEM_CPU_CPU_INFO_PROVIDER_H_ | |
OLD | NEW |