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 CHROME_BROWSER_EXTENSIONS_API_SYSTEM_CPU_CPU_INFO_PROVIDER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SYSTEM_CPU_CPU_INFO_PROVIDER_H_
8 #include "base/lazy_instance.h"
9 #include "chrome/browser/extensions/api/system_info/system_info_provider.h"
10 #include "chrome/common/extensions/api/system_cpu.h"
12 namespace extensions {
14 class CpuInfoProvider : public SystemInfoProvider {
16 // Return the single shared instance of CpuInfoProvider.
17 static CpuInfoProvider* Get();
19 const api::system_cpu::CpuInfo& cpu_info() const;
21 static void InitializeForTesting(scoped_refptr<CpuInfoProvider> provider);
24 friend class MockCpuInfoProviderImpl;
27 virtual ~CpuInfoProvider();
29 // Overriden from SystemInfoProvider.
30 virtual bool QueryInfo() OVERRIDE;
32 // The last information filled up by QueryInfo and is accessed on multiple
33 // threads, but the whole class is being guarded by SystemInfoProvider base
36 // |info_| is accessed on the UI thread while |is_waiting_for_completion_| is
37 // false and on the sequenced worker pool while |is_waiting_for_completion_|
39 api::system_cpu::CpuInfo info_;
41 static base::LazyInstance<scoped_refptr<CpuInfoProvider> > provider_;
43 DISALLOW_COPY_AND_ASSIGN(CpuInfoProvider);
46 } // namespace extensions
48 #endif // CHROME_BROWSER_EXTENSIONS_API_SYSTEM_CPU_CPU_INFO_PROVIDER_H_