| 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_MEMORY_MEMORY_INFO_PROVIDER_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_SYSTEM_MEMORY_MEMORY_INFO_PROVIDER_H_ |
| 6 #define EXTENSIONS_BROWSER_API_SYSTEM_MEMORY_MEMORY_INFO_PROVIDER_H_ | 6 #define EXTENSIONS_BROWSER_API_SYSTEM_MEMORY_MEMORY_INFO_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "extensions/browser/api/system_info/system_info_provider.h" | 9 #include "extensions/browser/api/system_info/system_info_provider.h" |
| 10 #include "extensions/common/api/system_memory.h" | 10 #include "extensions/common/api/system_memory.h" |
| 11 | 11 |
| 12 namespace extensions { | 12 namespace extensions { |
| 13 | 13 |
| 14 class MemoryInfoProvider : public SystemInfoProvider { | 14 class MemoryInfoProvider : public SystemInfoProvider { |
| 15 public: | 15 public: |
| 16 static MemoryInfoProvider* Get(); | 16 static MemoryInfoProvider* Get(); |
| 17 | 17 |
| 18 const core_api::system_memory::MemoryInfo& memory_info() const { | 18 const api::system_memory::MemoryInfo& memory_info() const { return info_; } |
| 19 return info_; | |
| 20 } | |
| 21 | 19 |
| 22 static void InitializeForTesting(scoped_refptr<MemoryInfoProvider> provider); | 20 static void InitializeForTesting(scoped_refptr<MemoryInfoProvider> provider); |
| 23 | 21 |
| 24 private: | 22 private: |
| 25 friend class MockMemoryInfoProviderImpl; | 23 friend class MockMemoryInfoProviderImpl; |
| 26 | 24 |
| 27 MemoryInfoProvider(); | 25 MemoryInfoProvider(); |
| 28 ~MemoryInfoProvider() override; | 26 ~MemoryInfoProvider() override; |
| 29 | 27 |
| 30 // Overriden from SystemInfoProvider. | 28 // Overriden from SystemInfoProvider. |
| 31 bool QueryInfo() override; | 29 bool QueryInfo() override; |
| 32 | 30 |
| 33 // The last information filled up by QueryInfo and is accessed on multiple | 31 // The last information filled up by QueryInfo and is accessed on multiple |
| 34 // threads, but the whole class is being guarded by SystemInfoProvider base | 32 // threads, but the whole class is being guarded by SystemInfoProvider base |
| 35 // class. | 33 // class. |
| 36 // | 34 // |
| 37 // |info_| is accessed on the UI thread while |is_waiting_for_completion_| is | 35 // |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_| | 36 // false and on the sequenced worker pool while |is_waiting_for_completion_| |
| 39 // is true. | 37 // is true. |
| 40 core_api::system_memory::MemoryInfo info_; | 38 api::system_memory::MemoryInfo info_; |
| 41 | 39 |
| 42 static base::LazyInstance<scoped_refptr<MemoryInfoProvider> > provider_; | 40 static base::LazyInstance<scoped_refptr<MemoryInfoProvider> > provider_; |
| 43 | 41 |
| 44 DISALLOW_COPY_AND_ASSIGN(MemoryInfoProvider); | 42 DISALLOW_COPY_AND_ASSIGN(MemoryInfoProvider); |
| 45 }; | 43 }; |
| 46 | 44 |
| 47 } // namespace extensions | 45 } // namespace extensions |
| 48 | 46 |
| 49 #endif // EXTENSIONS_BROWSER_API_SYSTEM_MEMORY_MEMORY_INFO_PROVIDER_H_ | 47 #endif // EXTENSIONS_BROWSER_API_SYSTEM_MEMORY_MEMORY_INFO_PROVIDER_H_ |
| OLD | NEW |