| 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/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 virtual ~MemoryPressureMonitor(); | 29 virtual ~MemoryPressureMonitor(); |
| 30 | 30 |
| 31 // Return the singleton MemoryPressureMonitor. | 31 // Return the singleton MemoryPressureMonitor. |
| 32 static MemoryPressureMonitor* Get(); | 32 static MemoryPressureMonitor* Get(); |
| 33 | 33 |
| 34 // Record memory pressure UMA statistic. A tick is 5 seconds. | 34 // Record memory pressure UMA statistic. A tick is 5 seconds. |
| 35 static void RecordMemoryPressure(MemoryPressureLevel level, int ticks); | 35 static void RecordMemoryPressure(MemoryPressureLevel level, int ticks); |
| 36 | 36 |
| 37 // Returns the currently observed memory pressure. | 37 // Returns the currently observed memory pressure. |
| 38 virtual MemoryPressureLevel GetCurrentPressureLevel() const = 0; | 38 virtual MemoryPressureLevel GetCurrentPressureLevel() = 0; |
| 39 | 39 |
| 40 // Sets a notification callback. The default callback invokes | 40 // Sets a notification callback. The default callback invokes |
| 41 // base::MemoryPressureListener::NotifyMemoryPressure. | 41 // base::MemoryPressureListener::NotifyMemoryPressure. |
| 42 virtual void SetDispatchCallback(const DispatchCallback& callback) = 0; | 42 virtual void SetDispatchCallback(const DispatchCallback& callback) = 0; |
| 43 | 43 |
| 44 protected: | 44 protected: |
| 45 MemoryPressureMonitor(); | 45 MemoryPressureMonitor(); |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); | 48 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 } // namespace base | 51 } // namespace base |
| 52 | 52 |
| 53 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_H_ | 53 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_H_ |
| OLD | NEW |