OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_H_ | 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_H_ |
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_H_ | 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 // Gets the preferred discardable memory type. | 90 // Gets the preferred discardable memory type. |
91 static DiscardableMemoryType GetPreferredType(); | 91 static DiscardableMemoryType GetPreferredType(); |
92 | 92 |
93 // Create a DiscardableMemory instance with specified |type| and |size|. | 93 // Create a DiscardableMemory instance with specified |type| and |size|. |
94 static scoped_ptr<DiscardableMemory> CreateLockedMemoryWithType( | 94 static scoped_ptr<DiscardableMemory> CreateLockedMemoryWithType( |
95 DiscardableMemoryType type, size_t size); | 95 DiscardableMemoryType type, size_t size); |
96 | 96 |
97 // Create a DiscardableMemory instance with preferred type and |size|. | 97 // Create a DiscardableMemory instance with preferred type and |size|. |
98 static scoped_ptr<DiscardableMemory> CreateLockedMemory(size_t size); | 98 static scoped_ptr<DiscardableMemory> CreateLockedMemory(size_t size); |
99 | 99 |
100 // Call this when idle. Discardable memory implementations might use this | |
willchan no longer on Chromium
2014/06/27 14:12:56
I'd give more guidance on "idle". Specifically, di
reveman
2014/06/27 20:38:02
Correct. I've updated the comment.
| |
101 // to reduce memory footprint. Returns true if there's no need to call this | |
102 // again until memory instances have been used. This indicates that all | |
103 // discardable memory implementations have done as much cleanup as they | |
104 // will be able to do. | |
105 static bool IdleNotification(); | |
106 | |
100 // Locks the memory so that it will not be purged by the system. Returns | 107 // Locks the memory so that it will not be purged by the system. Returns |
101 // DISCARDABLE_MEMORY_LOCK_STATUS_SUCCESS on success. If the return value is | 108 // DISCARDABLE_MEMORY_LOCK_STATUS_SUCCESS on success. If the return value is |
102 // DISCARDABLE_MEMORY_LOCK_STATUS_FAILED then this object should be | 109 // DISCARDABLE_MEMORY_LOCK_STATUS_FAILED then this object should be |
103 // discarded and a new one should be created. If the return value is | 110 // discarded and a new one should be created. If the return value is |
104 // DISCARDABLE_MEMORY_LOCK_STATUS_PURGED then the memory is present but any | 111 // DISCARDABLE_MEMORY_LOCK_STATUS_PURGED then the memory is present but any |
105 // data that was in it is gone. | 112 // data that was in it is gone. |
106 virtual DiscardableMemoryLockStatus Lock() WARN_UNUSED_RESULT = 0; | 113 virtual DiscardableMemoryLockStatus Lock() WARN_UNUSED_RESULT = 0; |
107 | 114 |
108 // Unlocks the memory so that it can be purged by the system. Must be called | 115 // Unlocks the memory so that it can be purged by the system. Must be called |
109 // after every successful lock call. | 116 // after every successful lock call. |
110 virtual void Unlock() = 0; | 117 virtual void Unlock() = 0; |
111 | 118 |
112 // Returns the memory address held by this object. The object must be locked | 119 // Returns the memory address held by this object. The object must be locked |
113 // before calling this. Otherwise, this will cause a DCHECK error. | 120 // before calling this. Otherwise, this will cause a DCHECK error. |
114 virtual void* Memory() const = 0; | 121 virtual void* Memory() const = 0; |
115 | 122 |
116 // Testing utility calls. | 123 // Testing utility calls. |
117 | 124 |
118 // Purge all discardable memory in the system. This call has global effects | 125 // Purge all discardable memory in the system. This call has global effects |
119 // across all running processes, so it should only be used for testing! | 126 // across all running processes, so it should only be used for testing! |
120 static void PurgeForTesting(); | 127 static void PurgeForTesting(); |
121 }; | 128 }; |
122 | 129 |
123 } // namespace base | 130 } // namespace base |
124 | 131 |
125 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ | 132 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ |
OLD | NEW |