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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_MEMORY_MEMORY_PRESSURE_MONITOR_H_ 5 #ifndef BASE_MEMORY_MEMORY_PRESSURE_MONITOR_H_
6 #define BASE_MEMORY_MEMORY_PRESSURE_MONITOR_H_ 6 #define BASE_MEMORY_MEMORY_PRESSURE_MONITOR_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/memory_pressure_listener.h" 10 #include "base/memory/memory_pressure_listener.h"
11 11
12 namespace base { 12 namespace base {
13 13
14 // TODO(chrisha): Make this a concrete class with per-OS implementations rather 14 // TODO(chrisha): Make this a concrete class with per-OS implementations rather
15 // than an abstract base class. 15 // than an abstract base class.
16 16
17 // Declares the interface for a MemoryPressureMonitor. There are multiple 17 // Declares the interface for a MemoryPressureMonitor. There are multiple
18 // OS specific implementations of this class. An instance of the memory 18 // OS specific implementations of this class. An instance of the memory
19 // pressure observer is created at the process level, tracks memory usage, and 19 // pressure observer is created at the process level, tracks memory usage, and
20 // pushes memory state change notifications to the static function 20 // pushes memory state change notifications to the static function
21 // base::MemoryPressureListener::NotifyMemoryPressure. This is turn notifies 21 // base::MemoryPressureListener::NotifyMemoryPressure. This is turn notifies
22 // all MemoryPressureListener instances via a callback. 22 // all MemoryPressureListener instances via a callback.
23 class BASE_EXPORT MemoryPressureMonitor { 23 class BASE_EXPORT MemoryPressureMonitor {
24 public: 24 public:
25 using MemoryPressureLevel = base::MemoryPressureListener::MemoryPressureLevel; 25 using MemoryPressureLevel = base::MemoryPressureListener::MemoryPressureLevel;
26 using DispatchCallback = void(*)(MemoryPressureLevel level);
danakj 2016/07/08 00:03:53 oh I was expecting a base::Callback, but if you do
bashi 2016/07/08 00:13:05 Ah, good point. I have a WIP CL locally and a func
26 27
27 virtual ~MemoryPressureMonitor(); 28 virtual ~MemoryPressureMonitor();
28 29
29 // Return the singleton MemoryPressureMonitor. 30 // Return the singleton MemoryPressureMonitor.
30 static MemoryPressureMonitor* Get(); 31 static MemoryPressureMonitor* Get();
31 32
32 // Returns the currently observed memory pressure. 33 // Returns the currently observed memory pressure.
33 virtual MemoryPressureLevel GetCurrentPressureLevel() const = 0; 34 virtual MemoryPressureLevel GetCurrentPressureLevel() const = 0;
34 35
36 // Sets a notification callback. The default callback invokes
37 // base::MemoryPressureListener::NotifyMemoryPressure.
38 virtual void SetDispatchCallback(DispatchCallback callback) = 0;
39
35 protected: 40 protected:
36 MemoryPressureMonitor(); 41 MemoryPressureMonitor();
37 42
38 private: 43 private:
39 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); 44 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor);
40 }; 45 };
41 46
42 } // namespace base 47 } // namespace base
43 48
44 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_H_ 49 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_H_
OLDNEW
« no previous file with comments | « no previous file | base/memory/memory_pressure_monitor_chromeos.h » ('j') | base/memory/memory_pressure_monitor_chromeos.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698