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

Unified Diff: memory/memory_pressure_listener.cc

Issue 2050803003: Update to Chromium //base at Chromium commit e3a753f17bac62738b0dbf0b36510f767b081e4b. (Closed) Base URL: https://github.com/domokit/base.git@master
Patch Set: Created 4 years, 6 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 | « memory/memory_pressure_listener.h ('k') | memory/memory_pressure_listener_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: memory/memory_pressure_listener.cc
diff --git a/memory/memory_pressure_listener.cc b/memory/memory_pressure_listener.cc
index 2a1be74ebb99bfb6eaa00af8005ec44d19c57d6f..8071d378ec00a2d4176c60b8d12a87a138f01a58 100644
--- a/memory/memory_pressure_listener.cc
+++ b/memory/memory_pressure_listener.cc
@@ -32,6 +32,10 @@ LazyInstance<
ObserverListThreadSafe<MemoryPressureListener>,
LeakyLazyObserverListTraits> g_observers = LAZY_INSTANCE_INITIALIZER;
+// All memory pressure notifications within this process will be suppressed if
+// this variable is set to 1.
+subtle::Atomic32 g_notifications_suppressed = 0;
+
} // namespace
MemoryPressureListener::MemoryPressureListener(
@@ -54,8 +58,20 @@ void MemoryPressureListener::NotifyMemoryPressure(
DCHECK_NE(memory_pressure_level, MEMORY_PRESSURE_LEVEL_NONE);
TRACE_EVENT1("memory", "MemoryPressureListener::NotifyMemoryPressure",
"level", memory_pressure_level);
+ if (AreNotificationsSuppressed())
+ return;
g_observers.Get().Notify(FROM_HERE, &MemoryPressureListener::Notify,
memory_pressure_level);
}
+// static
+bool MemoryPressureListener::AreNotificationsSuppressed() {
+ return subtle::Acquire_Load(&g_notifications_suppressed) == 1;
+}
+
+// static
+void MemoryPressureListener::SetNotificationsSuppressed(bool suppress) {
+ subtle::Release_Store(&g_notifications_suppressed, suppress ? 1 : 0);
+}
+
} // namespace base
« no previous file with comments | « memory/memory_pressure_listener.h ('k') | memory/memory_pressure_listener_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698