Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: base/memory/memory_pressure_monitor_win.cc

Issue 2097753002: Make memory pressure notifier configurable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/memory_pressure_monitor_win.h ('k') | chromecast/browser/cast_memory_pressure_monitor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/memory_pressure_monitor_win.cc
diff --git a/base/memory/memory_pressure_monitor_win.cc b/base/memory/memory_pressure_monitor_win.cc
index 8ac66cec0880248cdea7107cd2c6b33806e4cdf4..a93b425e8228fbdd44e54899e96e6be53dd8db7e 100644
--- a/base/memory/memory_pressure_monitor_win.cc
+++ b/base/memory/memory_pressure_monitor_win.cc
@@ -82,6 +82,8 @@ MemoryPressureMonitor::MemoryPressureMonitor()
current_memory_pressure_level_(
MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE),
moderate_pressure_repeat_count_(0),
+ dispatch_callback_(
+ base::Bind(&MemoryPressureListener::NotifyMemoryPressure)),
weak_ptr_factory_(this) {
InferThresholds();
StartObserving();
@@ -94,6 +96,8 @@ MemoryPressureMonitor::MemoryPressureMonitor(int moderate_threshold_mb,
current_memory_pressure_level_(
MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE),
moderate_pressure_repeat_count_(0),
+ dispatch_callback_(
+ base::Bind(&MemoryPressureListener::NotifyMemoryPressure)),
weak_ptr_factory_(this) {
DCHECK_GE(moderate_threshold_mb_, critical_threshold_mb_);
DCHECK_LE(0, critical_threshold_mb_);
@@ -198,7 +202,7 @@ void MemoryPressureMonitor::CheckMemoryPressure() {
// happen for moderate and critical pressure levels.
DCHECK_NE(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE,
current_memory_pressure_level_);
- MemoryPressureListener::NotifyMemoryPressure(current_memory_pressure_level_);
+ dispatch_callback_.Run(current_memory_pressure_level_);
}
void MemoryPressureMonitor::CheckMemoryPressureAndRecordStatistics() {
@@ -250,5 +254,10 @@ bool MemoryPressureMonitor::GetSystemMemoryStatus(
return true;
}
+void MemoryPressureMonitor::SetDispatchCallback(
+ const DispatchCallback& callback) {
+ dispatch_callback_ = callback;
+}
+
} // namespace win
} // namespace base
« no previous file with comments | « base/memory/memory_pressure_monitor_win.h ('k') | chromecast/browser/cast_memory_pressure_monitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698