OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 BASE_MEMORY_MEMORY_PRESSURE_MONITOR_WIN_H_ | 5 #ifndef BASE_MEMORY_MEMORY_PRESSURE_MONITOR_WIN_H_ |
6 #define BASE_MEMORY_MEMORY_PRESSURE_MONITOR_WIN_H_ | 6 #define BASE_MEMORY_MEMORY_PRESSURE_MONITOR_WIN_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/memory/memory_pressure_listener.h" | 9 #include "base/memory/memory_pressure_listener.h" |
10 #include "base/memory/memory_pressure_monitor.h" | 10 #include "base/memory/memory_pressure_monitor.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // thread. | 110 // thread. |
111 virtual bool GetSystemMemoryStatus(MEMORYSTATUSEX* mem_status); | 111 virtual bool GetSystemMemoryStatus(MEMORYSTATUSEX* mem_status); |
112 | 112 |
113 private: | 113 private: |
114 // Threshold amounts of available memory that trigger pressure levels. See | 114 // Threshold amounts of available memory that trigger pressure levels. See |
115 // memory_pressure_monitor.cc for a discussion of reasonable values for these. | 115 // memory_pressure_monitor.cc for a discussion of reasonable values for these. |
116 int moderate_threshold_mb_; | 116 int moderate_threshold_mb_; |
117 int critical_threshold_mb_; | 117 int critical_threshold_mb_; |
118 | 118 |
119 // A periodic timer to check for memory pressure changes. | 119 // A periodic timer to check for memory pressure changes. |
120 base::RepeatingTimer<MemoryPressureMonitor> timer_; | 120 base::RepeatingTimer timer_; |
121 | 121 |
122 // The current memory pressure. | 122 // The current memory pressure. |
123 MemoryPressureLevel current_memory_pressure_level_; | 123 MemoryPressureLevel current_memory_pressure_level_; |
124 | 124 |
125 // To slow down the amount of moderate pressure event calls, this gets used to | 125 // To slow down the amount of moderate pressure event calls, this gets used to |
126 // count the number of events since the last event occured. This is used by | 126 // count the number of events since the last event occured. This is used by |
127 // |CheckMemoryPressure| to apply hysteresis on the raw results of | 127 // |CheckMemoryPressure| to apply hysteresis on the raw results of |
128 // |CalculateCurrentPressureLevel|. | 128 // |CalculateCurrentPressureLevel|. |
129 int moderate_pressure_repeat_count_; | 129 int moderate_pressure_repeat_count_; |
130 | 130 |
131 // Ensures that this object is used from a single thread. | 131 // Ensures that this object is used from a single thread. |
132 base::ThreadChecker thread_checker_; | 132 base::ThreadChecker thread_checker_; |
133 | 133 |
134 // Weak pointer factory to ourself used for scheduling calls to | 134 // Weak pointer factory to ourself used for scheduling calls to |
135 // CheckMemoryPressure/CheckMemoryPressureAndRecordStatistics via |timer_|. | 135 // CheckMemoryPressure/CheckMemoryPressureAndRecordStatistics via |timer_|. |
136 base::WeakPtrFactory<MemoryPressureMonitor> weak_ptr_factory_; | 136 base::WeakPtrFactory<MemoryPressureMonitor> weak_ptr_factory_; |
137 | 137 |
138 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); | 138 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); |
139 }; | 139 }; |
140 | 140 |
141 } // namespace win | 141 } // namespace win |
142 } // namespace base | 142 } // namespace base |
143 | 143 |
144 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_WIN_H_ | 144 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_WIN_H_ |
OLD | NEW |