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

Unified Diff: base/memory/memory_pressure_monitor.h

Issue 2097753002: Make memory pressure notifier configurable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment 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 | « no previous file | base/memory/memory_pressure_monitor_chromeos.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/memory_pressure_monitor.h
diff --git a/base/memory/memory_pressure_monitor.h b/base/memory/memory_pressure_monitor.h
index 6073bd3f44ca8f26b953a31967406c747e35bb58..3ef578ec7951657b5b186e13ba6b12d85ebaaf81 100644
--- a/base/memory/memory_pressure_monitor.h
+++ b/base/memory/memory_pressure_monitor.h
@@ -11,6 +11,7 @@
namespace base {
+class MemoryPressureMonitorObserver;
// TODO(chrisha): Make this a concrete class with per-OS implementations rather
// than an abstract base class.
@@ -32,6 +33,11 @@ class BASE_EXPORT MemoryPressureMonitor {
// Returns the currently observed memory pressure.
virtual MemoryPressureLevel GetCurrentPressureLevel() const = 0;
+ // Sets a notification observer. Does not take the ownership. Once a observer
+ // is set, MemoryPressureMonitor pushes memory pressure notifications to the
+ // observer instead of base::MemoryPressureListener::NotifyMemoryPressure.
+ virtual void SetObserver(MemoryPressureMonitorObserver* observer) = 0;
chrisha 2016/07/07 03:09:19 This is more than just an observer. It actually ta
bashi 2016/07/07 03:32:32 Makes sense. Will do that if danakj@ is fine.
danakj 2016/07/07 23:12:06 Ya that sounds good to me, and is a good reason fo
bashi 2016/07/07 23:57:19 Done.
+
protected:
MemoryPressureMonitor();
@@ -39,6 +45,17 @@ class BASE_EXPORT MemoryPressureMonitor {
DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor);
};
+// An interface to observe memory pressure level.
+class BASE_EXPORT MemoryPressureMonitorObserver {
+public:
+ virtual ~MemoryPressureMonitorObserver() {}
+
+ // Called when MemoryPressureMonitor detects changes in memory pressure
+ // level.
+ virtual void OnMemoryPressure(
+ MemoryPressureMonitor::MemoryPressureLevel level) = 0;
+};
+
} // namespace base
#endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_H_
« no previous file with comments | « no previous file | base/memory/memory_pressure_monitor_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698