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 |
11 #include "base/base_export.h" | 11 #include "base/base_export.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 | 17 |
18 enum DiscardableMemoryType { | 18 enum DiscardableMemoryType { |
19 DISCARDABLE_MEMORY_TYPE_NONE, | 19 DISCARDABLE_MEMORY_TYPE_NONE, |
20 DISCARDABLE_MEMORY_TYPE_ANDROID, | 20 DISCARDABLE_MEMORY_TYPE_ASHMEM, |
21 DISCARDABLE_MEMORY_TYPE_MAC, | 21 DISCARDABLE_MEMORY_TYPE_MAC, |
22 DISCARDABLE_MEMORY_TYPE_EMULATED, | 22 DISCARDABLE_MEMORY_TYPE_EMULATED, |
23 DISCARDABLE_MEMORY_TYPE_MALLOC | 23 DISCARDABLE_MEMORY_TYPE_MALLOC |
24 }; | 24 }; |
25 | 25 |
26 enum DiscardableMemoryLockStatus { | 26 enum DiscardableMemoryLockStatus { |
27 DISCARDABLE_MEMORY_LOCK_STATUS_FAILED, | 27 DISCARDABLE_MEMORY_LOCK_STATUS_FAILED, |
28 DISCARDABLE_MEMORY_LOCK_STATUS_PURGED, | 28 DISCARDABLE_MEMORY_LOCK_STATUS_PURGED, |
29 DISCARDABLE_MEMORY_LOCK_STATUS_SUCCESS | 29 DISCARDABLE_MEMORY_LOCK_STATUS_SUCCESS |
30 }; | 30 }; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 virtual void Unlock() = 0; | 110 virtual void Unlock() = 0; |
111 | 111 |
112 // Returns the memory address held by this object. The object must be locked | 112 // Returns the memory address held by this object. The object must be locked |
113 // before calling this. Otherwise, this will cause a DCHECK error. | 113 // before calling this. Otherwise, this will cause a DCHECK error. |
114 virtual void* Memory() const = 0; | 114 virtual void* Memory() const = 0; |
115 | 115 |
116 // Testing utility calls. | 116 // Testing utility calls. |
117 | 117 |
118 // Check whether a purge of all discardable memory in the system is supported. | 118 // Check whether a purge of all discardable memory in the system is supported. |
119 // Use only for testing! | 119 // Use only for testing! |
120 static bool PurgeForTestingSupported(); | 120 static bool PurgeForTestingSupported(DiscardableMemoryType type); |
reveman
2014/04/28 15:39:16
How about we just remove PurgeForTestingSupported
Philippe
2014/04/28 15:53:45
I would be happy to do that but unfortunately the
reveman
2014/04/28 16:02:24
I think purging in the case of the malloc type is
| |
121 | 121 |
122 // Purge all discardable memory in the system. This call has global effects | 122 // Purge all discardable memory in the system. This call has global effects |
123 // across all running processes, so it should only be used for testing! | 123 // across all running processes, so it should only be used for testing! |
124 static void PurgeForTesting(); | 124 static void PurgeForTesting(DiscardableMemoryType type); |
reveman
2014/04/28 15:39:16
Can you explain why we need to pass a type here in
Philippe
2014/04/28 15:53:45
Just to clarify, I was initially overriding the pr
reveman
2014/04/28 16:02:24
I agree that we shouldn't mess with preferred type
Philippe
2014/04/28 16:31:21
Yeah, good idea. I got rid of PurgeForTestingSuppo
| |
125 }; | 125 }; |
126 | 126 |
127 } // namespace base | 127 } // namespace base |
128 | 128 |
129 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ | 129 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ |
OLD | NEW |