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_MEMORY_MEMORY_INFO_PROVIDER_H_
6 #define EXTENSIONS_BROWSER_API_SYSTEM_MEMORY_MEMORY_INFO_PROVIDER_H_
8 #include "base/lazy_instance.h"
9 #include "extensions/browser/api/system_info/system_info_provider.h"
10 #include "extensions/common/api/system_memory.h"
12 namespace extensions
{
14 class MemoryInfoProvider
: public SystemInfoProvider
{
16 static MemoryInfoProvider
* Get();
18 const core_api::system_memory::MemoryInfo
& memory_info() const {
22 static void InitializeForTesting(scoped_refptr
<MemoryInfoProvider
> provider
);
25 friend class MockMemoryInfoProviderImpl
;
28 ~MemoryInfoProvider() override
;
30 // Overriden from SystemInfoProvider.
31 bool QueryInfo() override
;
33 // The last information filled up by QueryInfo and is accessed on multiple
34 // threads, but the whole class is being guarded by SystemInfoProvider base
37 // |info_| is accessed on the UI thread while |is_waiting_for_completion_| is
38 // false and on the sequenced worker pool while |is_waiting_for_completion_|
40 core_api::system_memory::MemoryInfo info_
;
42 static base::LazyInstance
<scoped_refptr
<MemoryInfoProvider
> > provider_
;
44 DISALLOW_COPY_AND_ASSIGN(MemoryInfoProvider
);
47 } // namespace extensions
49 #endif // EXTENSIONS_BROWSER_API_SYSTEM_MEMORY_MEMORY_INFO_PROVIDER_H_