| OLD | NEW |
| 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/memory/memory_pressure_listener.h" | 9 #include "base/memory/memory_pressure_listener.h" |
| 10 | 10 |
| 11 namespace base { | 11 namespace base { |
| 12 | 12 |
| 13 // TODO(chrisha): Make this a concrete class with per-OS implementations rather |
| 14 // than an abstract base class. |
| 15 |
| 13 // Declares the interface for a MemoryPressureMonitor. There are multiple | 16 // Declares the interface for a MemoryPressureMonitor. There are multiple |
| 14 // OS specific implementations of this class. An instance of the memory | 17 // OS specific implementations of this class. An instance of the memory |
| 15 // pressure observer is created at the process level, tracks memory usage, and | 18 // pressure observer is created at the process level, tracks memory usage, and |
| 16 // pushes memory state change notifications to the static function | 19 // pushes memory state change notifications to the static function |
| 17 // base::MemoryPressureListener::NotifyMemoryPressure. This is turn notifies | 20 // base::MemoryPressureListener::NotifyMemoryPressure. This is turn notifies |
| 18 // all MemoryPressureListener instances via a callback. | 21 // all MemoryPressureListener instances via a callback. |
| 19 class BASE_EXPORT MemoryPressureMonitor { | 22 class BASE_EXPORT MemoryPressureMonitor { |
| 20 public: | 23 public: |
| 21 using MemoryPressureLevel = base::MemoryPressureListener::MemoryPressureLevel; | 24 using MemoryPressureLevel = base::MemoryPressureListener::MemoryPressureLevel; |
| 22 | 25 |
| 23 virtual ~MemoryPressureMonitor(); | 26 virtual ~MemoryPressureMonitor(); |
| 24 | 27 |
| 25 // Return the singleton MemoryPressureMonitor. | 28 // Return the singleton MemoryPressureMonitor. |
| 26 static MemoryPressureMonitor* Get(); | 29 static MemoryPressureMonitor* Get(); |
| 27 | 30 |
| 28 // Returns the currently observed memory pressure. | 31 // Returns the currently observed memory pressure. |
| 29 virtual MemoryPressureLevel GetCurrentPressureLevel() const = 0; | 32 virtual MemoryPressureLevel GetCurrentPressureLevel() const = 0; |
| 30 | 33 |
| 31 protected: | 34 protected: |
| 32 MemoryPressureMonitor(); | 35 MemoryPressureMonitor(); |
| 33 | 36 |
| 34 private: | 37 private: |
| 35 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); | 38 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); |
| 36 }; | 39 }; |
| 37 | 40 |
| 38 } // namespace base | 41 } // namespace base |
| 39 | 42 |
| 40 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_H_ | 43 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_H_ |
| OLD | NEW |