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 CONTENT_PUBLIC_COMMON_MEMORY_PRESSURE_MONITOR_H_ |
| 6 #define CONTENT_PUBLIC_COMMON_MEMORY_PRESSURE_MONITOR_H_ |
| 7 |
| 8 #include "base/memory/memory_pressure_listener.h" |
| 9 #include "content/common/content_export.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 // Declares the interface for a MemoryPressureMonitor. There are multiple |
| 14 // OS specific implementations of this class. An instance of the memory |
| 15 // pressure observer is created at the process level, tracks memory usage, and |
| 16 // pushes memory state change notifications to the static function |
| 17 // base::MemoryPressureListener::NotifyMemoryPressure. This is turn notifies |
| 18 // all MemoryPressureListener instances via a callback. |
| 19 class CONTENT_EXPORT MemoryPressureMonitor { |
| 20 public: |
| 21 using MemoryPressureLevel = base::MemoryPressureListener::MemoryPressureLevel; |
| 22 |
| 23 // Return the singleton MemoryPressureMonitor. |
| 24 static MemoryPressureMonitor* Get(); |
| 25 |
| 26 // Returns the currently observed memory pressure. |
| 27 virtual MemoryPressureLevel GetCurrentPressureLevel() const = 0; |
| 28 |
| 29 // If the implementation is polling based forces an early evaluation of the |
| 30 // memory pressure level. This allows for a tighter feedback loop when under |
| 31 // critical memory pressure. If the implementation is not polling based this |
| 32 // is a nop. |
| 33 virtual void ScheduleEarlyCheck() = 0; |
| 34 |
| 35 protected: |
| 36 MemoryPressureMonitor(); |
| 37 virtual ~MemoryPressureMonitor(); |
| 38 |
| 39 private: |
| 40 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); |
| 41 }; |
| 42 |
| 43 } // namespace content |
| 44 |
| 45 #endif // CONTENT_PUBLIC_COMMON_MEMORY_PRESSURE_MONITOR_H_ |
OLD | NEW |