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 #include "base/memory/memory_pressure_monitor_win.h" | 5 #include "base/memory/memory_pressure_monitor_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 void MemoryPressureMonitor::CheckMemoryPressureSoon() { | 84 void MemoryPressureMonitor::CheckMemoryPressureSoon() { |
85 DCHECK(thread_checker_.CalledOnValidThread()); | 85 DCHECK(thread_checker_.CalledOnValidThread()); |
86 | 86 |
87 ThreadTaskRunnerHandle::Get()->PostTask( | 87 ThreadTaskRunnerHandle::Get()->PostTask( |
88 FROM_HERE, Bind(&MemoryPressureMonitor::CheckMemoryPressure, | 88 FROM_HERE, Bind(&MemoryPressureMonitor::CheckMemoryPressure, |
89 weak_ptr_factory_.GetWeakPtr())); | 89 weak_ptr_factory_.GetWeakPtr())); |
90 } | 90 } |
91 | 91 |
92 MemoryPressureListener::MemoryPressureLevel | 92 MemoryPressureListener::MemoryPressureLevel |
93 MemoryPressureMonitor::GetCurrentPressureLevel() const { | 93 MemoryPressureMonitor::GetCurrentPressureLevel() { |
94 return current_memory_pressure_level_; | 94 return current_memory_pressure_level_; |
95 } | 95 } |
96 | 96 |
97 void MemoryPressureMonitor::InferThresholds() { | 97 void MemoryPressureMonitor::InferThresholds() { |
98 // Default to a 'high' memory situation, which uses more conservative | 98 // Default to a 'high' memory situation, which uses more conservative |
99 // thresholds. | 99 // thresholds. |
100 bool high_memory = true; | 100 bool high_memory = true; |
101 MEMORYSTATUSEX mem_status = {}; | 101 MEMORYSTATUSEX mem_status = {}; |
102 if (GetSystemMemoryStatus(&mem_status)) { | 102 if (GetSystemMemoryStatus(&mem_status)) { |
103 static const DWORDLONG kLargeMemoryThresholdBytes = | 103 static const DWORDLONG kLargeMemoryThresholdBytes = |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 return true; | 224 return true; |
225 } | 225 } |
226 | 226 |
227 void MemoryPressureMonitor::SetDispatchCallback( | 227 void MemoryPressureMonitor::SetDispatchCallback( |
228 const DispatchCallback& callback) { | 228 const DispatchCallback& callback) { |
229 dispatch_callback_ = callback; | 229 dispatch_callback_ = callback; |
230 } | 230 } |
231 | 231 |
232 } // namespace win | 232 } // namespace win |
233 } // namespace base | 233 } // namespace base |
OLD | NEW |