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