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