Index: base/memory/discardable_memory.h |
diff --git a/base/memory/discardable_memory.h b/base/memory/discardable_memory.h |
index d6e91b979d5a46fdd50e6ef07ab4f52a904bc042..5145373486915ae119f7b2d42f31b2f31b8b4830 100644 |
--- a/base/memory/discardable_memory.h |
+++ b/base/memory/discardable_memory.h |
@@ -8,9 +8,17 @@ |
#include "base/base_export.h" |
#include "base/basictypes.h" |
#include "base/compiler_specific.h" |
+#if !defined(DISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY) |
+#include "base/memory/scoped_ptr.h" |
+#endif |
+#include "base/threading/non_thread_safe.h" |
namespace base { |
+namespace internal { |
+class DiscardableMemoryProvider; |
+} |
+ |
enum LockDiscardableMemoryStatus { |
DISCARDABLE_MEMORY_FAILED = -1, |
DISCARDABLE_MEMORY_PURGED = 0, |
@@ -37,6 +45,9 @@ enum LockDiscardableMemoryStatus { |
// - Because of memory alignment, the amount of memory allocated can be |
// larger than the requested memory size. It is not very efficient for |
// small allocations. |
+// - A discardable memory instance is not thread safe. It is the |
+// responsibility of users of discardable memory to ensure there are no |
+// races. |
// |
// References: |
// - Linux: http://lwn.net/Articles/452035/ |
@@ -51,8 +62,9 @@ class BASE_EXPORT DiscardableMemory { |
// The opened file will also be closed after this. |
~DiscardableMemory(); |
- // Check whether the system supports discardable memory. |
- static bool Supported(); |
+ // Check whether the system supports discardable memory natively. Returns |
+ // false if the support is emulated. |
+ static bool SupportedNatively(); |
// Initialize the DiscardableMemory object. On success, this function returns |
// true and the memory is locked. This should only be called once. |
@@ -87,6 +99,10 @@ class BASE_EXPORT DiscardableMemory { |
static void PurgeForTesting(); |
private: |
+#if !defined(DISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY) |
+ scoped_ptr<uint8, FreeDeleter> acquired_memory_; |
+#endif |
+ |
#if defined(OS_ANDROID) |
// Maps the discardable memory into the caller's address space. |
// Returns true on success, false otherwise. |