| 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_ASHMEM, | 20 DISCARDABLE_MEMORY_TYPE_ANDROID, |
| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // Unlocks the memory so that it can be purged by the system. Must be called | 108 // Unlocks the memory so that it can be purged by the system. Must be called |
| 109 // after every successful lock call. | 109 // after every successful lock call. |
| 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. |
| 119 // Use only for testing! |
| 120 static bool PurgeForTestingSupported(); |
| 121 |
| 118 // 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 |
| 119 // 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! |
| 120 static void PurgeForTesting(); | 124 static void PurgeForTesting(); |
| 121 }; | 125 }; |
| 122 | 126 |
| 123 } // namespace base | 127 } // namespace base |
| 124 | 128 |
| 125 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ | 129 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_ |
| OLD | NEW |