Chromium Code Reviews| 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..70542f5ebc24fb3ec02eb57b64b03eb15e91edeb 100644 |
| --- a/base/memory/memory_pressure_monitor.h |
| +++ b/base/memory/memory_pressure_monitor.h |
| @@ -6,6 +6,7 @@ |
| #define BASE_MEMORY_MEMORY_PRESSURE_MONITOR_H_ |
| #include "base/base_export.h" |
| +#include "base/callback.h" |
| #include "base/macros.h" |
| #include "base/memory/memory_pressure_listener.h" |
| @@ -32,10 +33,20 @@ class BASE_EXPORT MemoryPressureMonitor { |
| // Returns the currently observed memory pressure. |
| virtual MemoryPressureLevel GetCurrentPressureLevel() const = 0; |
| + // Sets a notification callback. Once a callback is set, |
|
danakj
2016/06/30 18:48:05
I tried to get this from the doc, but I think mayb
bashi
2016/06/30 23:33:10
We are implementing MemoryCoordinator which will r
danakj
2016/07/01 20:49:28
A virtual interface would do the same, where Memor
bashi
2016/07/03 23:54:47
That makes sense. Done.
|
| + // MemoryPressureMonitor pushes memory pressure notifications to the callback |
| + // instead of base::MemoryPressureListener::NotifyMemoryPressure. |
| + using Notifier = base::Callback<void(MemoryPressureLevel level)>; |
|
danakj
2016/06/30 18:48:05
"Notifier" is the wrong direction here. The notifi
bashi
2016/06/30 23:33:10
The callback replaces MemoryPressureListener::Noti
danakj
2016/07/01 20:49:28
Yes, and the monitor notifies it by that, so it *i
|
| + void SetNotifier(const Notifier& notifier) { notifier_ = notifier; } |
|
danakj
2016/07/01 20:49:28
Can we DCHECK that this is only set once? Or only
bashi
2016/07/03 23:54:47
Added DCHECK.
|
| + |
| + void Notify(MemoryPressureLevel level); |
|
bashi
2016/06/27 03:47:54
public because this is called by a static method (
|
| + |
| protected: |
| MemoryPressureMonitor(); |
| private: |
| + Notifier notifier_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); |
| }; |