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

Unified Diff: base/memory/memory_pressure_listener.cc

Issue 1370713002: Add method for simulating MemoryPressureListener notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Lei Zhang's comment Created 5 years, 3 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_listener.h ('k') | base/memory/memory_pressure_listener_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/memory_pressure_listener.cc
diff --git a/base/memory/memory_pressure_listener.cc b/base/memory/memory_pressure_listener.cc
index 8071d378ec00a2d4176c60b8d12a87a138f01a58..9fd675aa4e52a0dd679c0d26456da990c31589d3 100644
--- a/base/memory/memory_pressure_listener.cc
+++ b/base/memory/memory_pressure_listener.cc
@@ -60,8 +60,7 @@ void MemoryPressureListener::NotifyMemoryPressure(
"level", memory_pressure_level);
if (AreNotificationsSuppressed())
return;
- g_observers.Get().Notify(FROM_HERE, &MemoryPressureListener::Notify,
- memory_pressure_level);
+ DoNotifyMemoryPressure(memory_pressure_level);
}
// static
@@ -74,4 +73,19 @@ void MemoryPressureListener::SetNotificationsSuppressed(bool suppress) {
subtle::Release_Store(&g_notifications_suppressed, suppress ? 1 : 0);
}
+// static
+void MemoryPressureListener::SimulatePressureNotification(
+ MemoryPressureLevel memory_pressure_level) {
+ // Notify all listeners even if regular pressure notifications are suppressed.
+ DoNotifyMemoryPressure(memory_pressure_level);
+}
+
+// static
+void MemoryPressureListener::DoNotifyMemoryPressure(
+ MemoryPressureLevel memory_pressure_level) {
+ DCHECK_NE(memory_pressure_level, MEMORY_PRESSURE_LEVEL_NONE);
+ g_observers.Get().Notify(FROM_HERE, &MemoryPressureListener::Notify,
+ memory_pressure_level);
+}
+
} // namespace base
« no previous file with comments | « base/memory/memory_pressure_listener.h ('k') | base/memory/memory_pressure_listener_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698