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

Unified Diff: base/memory/memory_pressure_monitor_chromeos.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_chromeos.h ('k') | base/memory/memory_pressure_monitor_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/memory_pressure_monitor_chromeos.cc
diff --git a/base/memory/memory_pressure_monitor_chromeos.cc b/base/memory/memory_pressure_monitor_chromeos.cc
index 2d0b0a62fc6d7c1dbbb77aa98f06132d5f93a966..5138d01c57605615c27a32d600fe57e143e0e0d5 100644
--- a/base/memory/memory_pressure_monitor_chromeos.cc
+++ b/base/memory/memory_pressure_monitor_chromeos.cc
@@ -113,6 +113,8 @@ MemoryPressureMonitor::MemoryPressureMonitor(
critical_pressure_threshold_percent_(
GetCriticalMemoryThresholdInPercent(thresholds)),
low_mem_file_(HANDLE_EINTR(::open(kLowMemFile, O_RDONLY))),
+ dispatch_callback_(
+ base::Bind(&MemoryPressureListener::NotifyMemoryPressure)),
weak_ptr_factory_(this) {
StartObserving();
LOG_IF(ERROR,
@@ -230,7 +232,7 @@ void MemoryPressureMonitor::CheckMemoryPressure() {
return;
}
moderate_pressure_repeat_count_ = 0;
- MemoryPressureListener::NotifyMemoryPressure(current_memory_pressure_level_);
+ dispatch_callback_.Run(current_memory_pressure_level_);
}
// Gets the used ChromeOS memory in percent.
@@ -271,5 +273,10 @@ int MemoryPressureMonitor::GetUsedMemoryInPercent() {
return percentage;
}
+void MemoryPressureMonitor::SetDispatchCallback(
+ const DispatchCallback& callback) {
+ dispatch_callback_ = callback;
+}
+
} // namespace chromeos
} // namespace base
« no previous file with comments | « base/memory/memory_pressure_monitor_chromeos.h ('k') | base/memory/memory_pressure_monitor_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698