OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // MemoryPressure provides static APIs for handling memory pressure on | 5 // MemoryPressure provides static APIs for handling memory pressure on |
6 // platforms that have such signals, such as Android and ChromeOS. | 6 // platforms that have such signals, such as Android and ChromeOS. |
7 // The app will try to discard buffers that aren't deemed essential (individual | 7 // The app will try to discard buffers that aren't deemed essential (individual |
8 // modules will implement their own policy). | 8 // modules will implement their own policy). |
9 | 9 |
10 #ifndef BASE_MEMORY_MEMORY_PRESSURE_LISTENER_H_ | 10 #ifndef BASE_MEMORY_MEMORY_PRESSURE_LISTENER_H_ |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 typedef base::Callback<void(MemoryPressureLevel)> MemoryPressureCallback; | 66 typedef base::Callback<void(MemoryPressureLevel)> MemoryPressureCallback; |
67 | 67 |
68 explicit MemoryPressureListener( | 68 explicit MemoryPressureListener( |
69 const MemoryPressureCallback& memory_pressure_callback); | 69 const MemoryPressureCallback& memory_pressure_callback); |
70 ~MemoryPressureListener(); | 70 ~MemoryPressureListener(); |
71 | 71 |
72 // Intended for use by the platform specific implementation. | 72 // Intended for use by the platform specific implementation. |
73 static void NotifyMemoryPressure(MemoryPressureLevel memory_pressure_level); | 73 static void NotifyMemoryPressure(MemoryPressureLevel memory_pressure_level); |
74 | 74 |
| 75 // These methods should not be used anywhere else but in memory measurement |
| 76 // code, where they are intended to maintain stable conditions across |
| 77 // measurements. |
| 78 static bool AreNotificationsSuppressed(); |
| 79 static void SetNotificationsSuppressed(bool suppressed); |
| 80 |
75 private: | 81 private: |
76 void Notify(MemoryPressureLevel memory_pressure_level); | 82 void Notify(MemoryPressureLevel memory_pressure_level); |
77 | 83 |
78 MemoryPressureCallback callback_; | 84 MemoryPressureCallback callback_; |
79 | 85 |
80 DISALLOW_COPY_AND_ASSIGN(MemoryPressureListener); | 86 DISALLOW_COPY_AND_ASSIGN(MemoryPressureListener); |
81 }; | 87 }; |
82 | 88 |
83 } // namespace base | 89 } // namespace base |
84 | 90 |
85 #endif // BASE_MEMORY_MEMORY_PRESSURE_LISTENER_H_ | 91 #endif // BASE_MEMORY_MEMORY_PRESSURE_LISTENER_H_ |
OLD | NEW |