| 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_ |
| 11 #define BASE_MEMORY_MEMORY_PRESSURE_LISTENER_H_ | 11 #define BASE_MEMORY_MEMORY_PRESSURE_LISTENER_H_ |
| 12 | 12 |
| 13 #include "base/base_export.h" | 13 #include "base/base_export.h" |
| 14 #include "base/basictypes.h" | |
| 15 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 | 18 |
| 19 // To start listening, create a new instance, passing a callback to a | 19 // To start listening, create a new instance, passing a callback to a |
| 20 // function that takes a MemoryPressureLevel parameter. To stop listening, | 20 // function that takes a MemoryPressureLevel parameter. To stop listening, |
| 21 // simply delete the listener object. The implementation guarantees | 21 // simply delete the listener object. The implementation guarantees |
| 22 // that the callback will always be called on the thread that created | 22 // that the callback will always be called on the thread that created |
| 23 // the listener. | 23 // the listener. |
| 24 // Note that even on the same thread, the callback is not guaranteed to be | 24 // Note that even on the same thread, the callback is not guaranteed to be |
| 25 // called synchronously within the system memory pressure broadcast. | 25 // called synchronously within the system memory pressure broadcast. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 static void DoNotifyMemoryPressure(MemoryPressureLevel memory_pressure_level); | 86 static void DoNotifyMemoryPressure(MemoryPressureLevel memory_pressure_level); |
| 87 | 87 |
| 88 MemoryPressureCallback callback_; | 88 MemoryPressureCallback callback_; |
| 89 | 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(MemoryPressureListener); | 90 DISALLOW_COPY_AND_ASSIGN(MemoryPressureListener); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 } // namespace base | 93 } // namespace base |
| 94 | 94 |
| 95 #endif // BASE_MEMORY_MEMORY_PRESSURE_LISTENER_H_ | 95 #endif // BASE_MEMORY_MEMORY_PRESSURE_LISTENER_H_ |
| OLD | NEW |