- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / api / system_cpu / cpu_info_provider.h
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 "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"
11
12 namespace extensions {
13
14 class CpuInfoProvider : public SystemInfoProvider {
15  public:
16   // Return the single shared instance of CpuInfoProvider.
17   static CpuInfoProvider* Get();
18
19   const api::system_cpu::CpuInfo& cpu_info() const;
20
21   static void InitializeForTesting(scoped_refptr<CpuInfoProvider> provider);
22
23  private:
24   friend class MockCpuInfoProviderImpl;
25
26   CpuInfoProvider();
27   virtual ~CpuInfoProvider();
28
29   // Overriden from SystemInfoProvider.
30   virtual bool QueryInfo() OVERRIDE;
31
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
34   // class.
35   //
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_|
38   // is true.
39   api::system_cpu::CpuInfo info_;
40
41   static base::LazyInstance<scoped_refptr<CpuInfoProvider> > provider_;
42
43   DISALLOW_COPY_AND_ASSIGN(CpuInfoProvider);
44 };
45
46 }  // namespace extensions
47
48 #endif  // CHROME_BROWSER_EXTENSIONS_API_SYSTEM_CPU_CPU_INFO_PROVIDER_H_