Add method for suppressing MemoryPressureListener notifications
This patch adds a new static method to MemoryPressureListener which can
be used to start/stop suppressing memory pressure notifications:
// Start suppressing memory pressure notifications.
MemoryPressureListener::SetNotificationsSuppressed(true);
// Stop suppressing memory pressure notifications.
MemoryPressureListener::SetNotificationsSuppressed(false);
This patch represents the first step towards implementing a DevTools API
for suppressing and simulating memory pressure signals in Chrome. The
main use case for this feature is to enforce consistent conditions
across memory measurements. See https://goo.gl/cZFdH3 for more details.
BUG=516776
Review URL: https://codereview.chromium.org/1312163003
Cr-Commit-Position: refs/heads/master@{#347622}
CrOS-Libchrome-Original-Commit: da4982addfa8b6a5e25b794565c6c7158c1ec8cc
diff --git a/base/memory/memory_pressure_listener.h b/base/memory/memory_pressure_listener.h
index 6adaeee..83d47d7 100644
--- a/base/memory/memory_pressure_listener.h
+++ b/base/memory/memory_pressure_listener.h
@@ -72,6 +72,12 @@
// Intended for use by the platform specific implementation.
static void NotifyMemoryPressure(MemoryPressureLevel memory_pressure_level);
+ // These methods should not be used anywhere else but in memory measurement
+ // code, where they are intended to maintain stable conditions across
+ // measurements.
+ static bool AreNotificationsSuppressed();
+ static void SetNotificationsSuppressed(bool suppressed);
+
private:
void Notify(MemoryPressureLevel memory_pressure_level);