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" |
11 #include "base/memory/memory_pressure_listener.h" | 11 #include "base/memory/memory_pressure_listener.h" |
12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 // This interface is used by the DiscardableMemoryManager class to provide some | 17 // This interface is used by the DiscardableMemoryManager class to provide some |
18 // level of userspace control over discardable memory allocations. | 18 // level of userspace control over discardable memory allocations. |
19 class DiscardableMemoryManagerAllocation { | 19 class DiscardableMemoryManagerAllocation { |
20 public: | 20 public: |
21 // Allocate and acquire a lock that prevents the allocation from being purged | 21 // Allocate and acquire a lock that prevents the allocation from being purged |
22 // by the system. Returns true if memory was previously allocated and is still | 22 // by the system. Returns true if memory was previously allocated and is still |
23 // resident. | 23 // resident. |
24 virtual bool AllocateAndAcquireLock() = 0; | 24 virtual bool AllocateAndAcquireLock(size_t bytes) = 0; |
25 | 25 |
26 // Release a previously acquired lock on the allocation so that it can be | 26 // Release a previously acquired lock on the allocation so that it can be |
27 // purged by the system. | 27 // purged by the system. |
28 virtual void ReleaseLock() = 0; | 28 virtual void ReleaseLock() = 0; |
29 | 29 |
30 // Explicitly purge this allocation. It is illegal to call this while a lock | 30 // Explicitly purge this allocation. It is illegal to call this while a lock |
31 // is acquired on the allocation. | 31 // is acquired on the allocation. |
32 virtual void Purge() = 0; | 32 virtual void Purge() = 0; |
33 | 33 |
34 protected: | 34 protected: |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // pressure. | 163 // pressure. |
164 scoped_ptr<MemoryPressureListener> memory_pressure_listener_; | 164 scoped_ptr<MemoryPressureListener> memory_pressure_listener_; |
165 | 165 |
166 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryManager); | 166 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryManager); |
167 }; | 167 }; |
168 | 168 |
169 } // namespace internal | 169 } // namespace internal |
170 } // namespace base | 170 } // namespace base |
171 | 171 |
172 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_ | 172 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_ |
OLD | NEW |