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_WIN_H_ | 5 #ifndef CONTENT_BROWSER_MEMORY_BROWSER_MEMORY_MONITOR_WIN_H_ |
6 #define COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_WIN_H_ | 6 #define CONTENT_BROWSER_MEMORY_BROWSER_MEMORY_MONITOR_WIN_H_ |
7 | 7 |
8 #include "components/memory_coordinator/browser/memory_monitor.h" | 8 #include "content/browser/memory/memory_monitor.h" |
9 #include "components/memory_coordinator/common/memory_coordinator_export.h" | |
10 | 9 |
11 namespace base { | 10 namespace base { |
12 struct SystemMemoryInfoKB; | 11 struct SystemMemoryInfoKB; |
13 } // namespace base | 12 } // namespace base |
14 | 13 |
15 namespace memory_coordinator { | 14 namespace content { |
16 | 15 |
17 // A memory monitor for the Windows platform. After much experimentation this | 16 // A memory monitor for the Windows platform. After much experimentation this |
18 // class uses a very simple heuristic to anticipate paging (critical memory | 17 // class uses a very simple heuristic to anticipate paging (critical memory |
19 // pressure). When the amount of memory available dips below a provided | 18 // pressure). When the amount of memory available dips below a provided |
20 // threshold, it is assumed that paging is inevitable. | 19 // threshold, it is assumed that paging is inevitable. |
21 class MEMORY_COORDINATOR_EXPORT MemoryMonitorWin : public MemoryMonitor { | 20 class CONTENT_EXPORT MemoryMonitorWin : public MemoryMonitor { |
22 public: | 21 public: |
23 // Default constants governing the amount of free memory that the memory | 22 // Default constants governing the amount of free memory that the memory |
24 // manager attempts to maintain. | 23 // manager attempts to maintain. |
25 static const int kLargeMemoryThresholdMB; | 24 static const int kLargeMemoryThresholdMB; |
26 static const int kSmallMemoryTargetFreeMB; | 25 static const int kSmallMemoryTargetFreeMB; |
27 static const int kLargeMemoryTargetFreeMB; | 26 static const int kLargeMemoryTargetFreeMB; |
28 | 27 |
29 MemoryMonitorWin(MemoryMonitorDelegate* delegate, int target_free_mb); | 28 MemoryMonitorWin(MemoryMonitorDelegate* delegate, int target_free_mb); |
30 ~MemoryMonitorWin() override {} | 29 ~MemoryMonitorWin() override {} |
31 | 30 |
(...skipping 21 matching lines...) Expand all Loading... |
53 // The delegate to be used for retrieving system memory information. Used as a | 52 // The delegate to be used for retrieving system memory information. Used as a |
54 // testing seam. | 53 // testing seam. |
55 MemoryMonitorDelegate* delegate_; | 54 MemoryMonitorDelegate* delegate_; |
56 | 55 |
57 // The amount of memory that the memory manager (MM) attempts to keep in a | 56 // The amount of memory that the memory manager (MM) attempts to keep in a |
58 // free state. When less than this amount of physical memory is free, it is | 57 // free state. When less than this amount of physical memory is free, it is |
59 // assumed that the MM will start paging things out. | 58 // assumed that the MM will start paging things out. |
60 int target_free_mb_; | 59 int target_free_mb_; |
61 }; | 60 }; |
62 | 61 |
63 } // namespace memory_coordinator | 62 // A delegate that wraps functions used by MemoryMonitorWin. Used as a testing |
| 63 // seam. |
| 64 class CONTENT_EXPORT MemoryMonitorWinDelegate { |
| 65 public: |
| 66 MemoryMonitorWinDelegate() {} |
| 67 virtual ~MemoryMonitorWinDelegate() {} |
64 | 68 |
65 #endif // COMPONENTS_MEMORY_COORDINATOR_BROWSER_MEMORY_MONITOR_WIN_H_ | 69 // Returns system memory information. |
| 70 virtual void GetSystemMemoryInfo(base::SystemMemoryInfoKB* mem_info) = 0; |
| 71 |
| 72 private: |
| 73 DISALLOW_COPY_AND_ASSIGN(MemoryMonitorWinDelegate); |
| 74 }; |
| 75 |
| 76 } // namespace content |
| 77 |
| 78 #endif // CONTENT_BROWSER_MEMORY_BROWSER_MEMORY_MONITOR_WIN_H_ |
OLD | NEW |