Index: content/public/common/memory_pressure_monitor.h |
diff --git a/content/public/common/memory_pressure_monitor.h b/content/public/common/memory_pressure_monitor.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e539825fb58071308daa7ef608ad2f506bcda44d |
--- /dev/null |
+++ b/content/public/common/memory_pressure_monitor.h |
@@ -0,0 +1,45 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_PUBLIC_COMMON_MEMORY_PRESSURE_MONITOR_H_ |
+#define CONTENT_PUBLIC_COMMON_MEMORY_PRESSURE_MONITOR_H_ |
+ |
+#include "base/memory/memory_pressure_listener.h" |
+#include "content/common/content_export.h" |
+ |
+namespace content { |
+ |
+// Declares the interface for a MemoryPressureMonitor. There are multiple |
+// OS specific implementations of this class. An instance of the memory |
+// pressure observer is created at the process level, tracks memory usage, and |
+// pushes memory state change notifications to the static function |
+// base::MemoryPressureListener::NotifyMemoryPressure. This is turn notifies |
+// all MemoryPressureListener instances via a callback. |
+class CONTENT_EXPORT MemoryPressureMonitor { |
+ public: |
+ using MemoryPressureLevel = base::MemoryPressureListener::MemoryPressureLevel; |
+ |
+ // Return the singleton MemoryPressureMonitor. |
+ static MemoryPressureMonitor* Get(); |
+ |
+ // Returns the currently observed memory pressure. |
+ virtual MemoryPressureLevel GetCurrentPressureLevel() const = 0; |
+ |
+ // If the implementation is polling based forces an early evaluation of the |
+ // memory pressure level. This allows for a tighter feedback loop when under |
+ // critical memory pressure. If the implementation is not polling based this |
+ // is a nop. |
+ virtual void ScheduleEarlyCheck() = 0; |
+ |
+ protected: |
+ MemoryPressureMonitor(); |
+ virtual ~MemoryPressureMonitor(); |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_PUBLIC_COMMON_MEMORY_PRESSURE_MONITOR_H_ |