| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_DISCARDABLE_MEMORY_MANAGER_H_ | 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_ |
| 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_ | 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
| 9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/containers/mru_cache.h" | 10 #include "base/containers/mru_cache.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // amount of allocated memory (in case this forces a purge). When memory usage | 60 // amount of allocated memory (in case this forces a purge). When memory usage |
| 61 // reaches the limit, the manager purges the LRU memory. | 61 // reaches the limit, the manager purges the LRU memory. |
| 62 // | 62 // |
| 63 // When notified of memory pressure, the manager either purges the LRU memory -- | 63 // When notified of memory pressure, the manager either purges the LRU memory -- |
| 64 // if the pressure is moderate -- or all discardable memory if the pressure is | 64 // if the pressure is moderate -- or all discardable memory if the pressure is |
| 65 // critical. | 65 // critical. |
| 66 class BASE_EXPORT_PRIVATE DiscardableMemoryManager { | 66 class BASE_EXPORT_PRIVATE DiscardableMemoryManager { |
| 67 public: | 67 public: |
| 68 typedef DiscardableMemoryManagerAllocation Allocation; | 68 typedef DiscardableMemoryManagerAllocation Allocation; |
| 69 | 69 |
| 70 DiscardableMemoryManager(); | 70 DiscardableMemoryManager(size_t memory_limit, |
| 71 size_t bytes_to_keep_under_moderate_pressure); |
| 71 ~DiscardableMemoryManager(); | 72 ~DiscardableMemoryManager(); |
| 72 | 73 |
| 73 // Call this to register memory pressure listener. Must be called on a thread | 74 // Call this to register memory pressure listener. Must be called on a thread |
| 74 // with a MessageLoop current. | 75 // with a MessageLoop current. |
| 75 void RegisterMemoryPressureListener(); | 76 void RegisterMemoryPressureListener(); |
| 76 | 77 |
| 77 // Call this to unregister memory pressure listener. | 78 // Call this to unregister memory pressure listener. |
| 78 void UnregisterMemoryPressureListener(); | 79 void UnregisterMemoryPressureListener(); |
| 79 | 80 |
| 80 // The maximum number of bytes of memory that may be allocated before we force | 81 // The maximum number of bytes of memory that may be allocated before we force |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // pressure. | 164 // pressure. |
| 164 scoped_ptr<MemoryPressureListener> memory_pressure_listener_; | 165 scoped_ptr<MemoryPressureListener> memory_pressure_listener_; |
| 165 | 166 |
| 166 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryManager); | 167 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryManager); |
| 167 }; | 168 }; |
| 168 | 169 |
| 169 } // namespace internal | 170 } // namespace internal |
| 170 } // namespace base | 171 } // namespace base |
| 171 | 172 |
| 172 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_ | 173 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_ |
| OLD | NEW |