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 13 matching lines...) Expand all Loading... |
24 class BASE_EXPORT MemoryPressureMonitor { | 24 class BASE_EXPORT MemoryPressureMonitor { |
25 public: | 25 public: |
26 using MemoryPressureLevel = base::MemoryPressureListener::MemoryPressureLevel; | 26 using MemoryPressureLevel = base::MemoryPressureListener::MemoryPressureLevel; |
27 using DispatchCallback = base::Callback<void(MemoryPressureLevel level)>; | 27 using DispatchCallback = base::Callback<void(MemoryPressureLevel level)>; |
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. |
| 35 static void RecordMemoryPressure(MemoryPressureLevel level, int ticks); |
| 36 |
34 // Returns the currently observed memory pressure. | 37 // Returns the currently observed memory pressure. |
35 virtual MemoryPressureLevel GetCurrentPressureLevel() const = 0; | 38 virtual MemoryPressureLevel GetCurrentPressureLevel() const = 0; |
36 | 39 |
37 // Sets a notification callback. The default callback invokes | 40 // Sets a notification callback. The default callback invokes |
38 // base::MemoryPressureListener::NotifyMemoryPressure. | 41 // base::MemoryPressureListener::NotifyMemoryPressure. |
39 virtual void SetDispatchCallback(const DispatchCallback& callback) = 0; | 42 virtual void SetDispatchCallback(const DispatchCallback& callback) = 0; |
40 | 43 |
41 protected: | 44 protected: |
42 MemoryPressureMonitor(); | 45 MemoryPressureMonitor(); |
43 | 46 |
44 private: | 47 private: |
45 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); | 48 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); |
46 }; | 49 }; |
47 | 50 |
48 } // namespace base | 51 } // namespace base |
49 | 52 |
50 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_H_ | 53 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_H_ |
OLD | NEW |