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 // | |
20 // Thread-safety: The methods below are called while the manager's mutex is | |
21 // acquired. This means that subclasses don't need to deal with synchronization | |
22 // as long as they correctly go through the manager's methods (e.g. | |
23 // AcuireLock(), ReleaseLock()...). | |
reveman
2014/04/26 00:13:37
It's really the usage by the manager rather than t
| |
19 class DiscardableMemoryManagerAllocation { | 24 class DiscardableMemoryManagerAllocation { |
20 public: | 25 public: |
21 // Allocate and acquire a lock that prevents the allocation from being purged | 26 // 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 | 27 // by the system. Returns true if memory was previously allocated and is still |
23 // resident. | 28 // resident. |
24 virtual bool AllocateAndAcquireLock(size_t bytes) = 0; | 29 virtual bool AllocateAndAcquireLock(size_t bytes) = 0; |
25 | 30 |
26 // Release a previously acquired lock on the allocation so that it can be | 31 // Release a previously acquired lock on the allocation so that it can be |
27 // purged by the system. | 32 // purged by the system. |
28 virtual void ReleaseLock() = 0; | 33 virtual void ReleaseLock() = 0; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 // pressure. | 168 // pressure. |
164 scoped_ptr<MemoryPressureListener> memory_pressure_listener_; | 169 scoped_ptr<MemoryPressureListener> memory_pressure_listener_; |
165 | 170 |
166 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryManager); | 171 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryManager); |
167 }; | 172 }; |
168 | 173 |
169 } // namespace internal | 174 } // namespace internal |
170 } // namespace base | 175 } // namespace base |
171 | 176 |
172 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_ | 177 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_MANAGER_H_ |
OLD | NEW |