OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_ | 5 #ifndef COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_ |
6 #define COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_ | 6 #define COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/memory_coordinator/common/memory_coordinator_export.h" |
11 | 12 |
12 namespace memory_coordinator { | 13 namespace memory_coordinator { |
13 | 14 |
14 // A simple class that monitors the amount of free memory available on a system. | 15 // A simple class that monitors the amount of free memory available on a system. |
15 // This is an interface to facilitate dependency injection for testing. | 16 // This is an interface to facilitate dependency injection for testing. |
16 class MemoryMonitor { | 17 class MEMORY_COORDINATOR_EXPORT MemoryMonitor { |
17 public: | 18 public: |
18 MemoryMonitor() {} | 19 MemoryMonitor() {} |
19 virtual ~MemoryMonitor() {} | 20 virtual ~MemoryMonitor() {} |
20 | 21 |
21 // Returns the amount of free memory available on the system until the system | 22 // Returns the amount of free memory available on the system until the system |
22 // will be in a critical state. Critical is as defined by the OS (swapping | 23 // will be in a critical state. Critical is as defined by the OS (swapping |
23 // will occur, or physical memory will run out, etc). It is possible for this | 24 // will occur, or physical memory will run out, etc). It is possible for this |
24 // to return negative values, in which case that much memory would have to be | 25 // to return negative values, in which case that much memory would have to be |
25 // freed in order to exit a critical memory state. | 26 // freed in order to exit a critical memory state. |
26 virtual int GetFreeMemoryUntilCriticalMB() = 0; | 27 virtual int GetFreeMemoryUntilCriticalMB() = 0; |
27 | 28 |
28 private: | 29 private: |
29 DISALLOW_COPY_AND_ASSIGN(MemoryMonitor); | 30 DISALLOW_COPY_AND_ASSIGN(MemoryMonitor); |
30 }; | 31 }; |
31 | 32 |
32 // Factory function for creating a monitor for the current platform. | 33 // Factory function for creating a monitor for the current platform. |
33 std::unique_ptr<MemoryMonitor> CreateMemoryMonitor(); | 34 MEMORY_COORDINATOR_EXPORT std::unique_ptr<MemoryMonitor> CreateMemoryMonitor(); |
34 | 35 |
35 } // namespace memory_coordinator | 36 } // namespace memory_coordinator |
36 | 37 |
37 #endif // COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_ | 38 #endif // COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_H_ |
OLD | NEW |