Index: base/memory/discardable_memory.h |
diff --git a/base/memory/discardable_memory.h b/base/memory/discardable_memory.h |
index d6e91b979d5a46fdd50e6ef07ab4f52a904bc042..26570ad40f9ef155a694d4e55b4b4599dedf91d4 100644 |
--- a/base/memory/discardable_memory.h |
+++ b/base/memory/discardable_memory.h |
@@ -8,6 +8,7 @@ |
#include "base/base_export.h" |
#include "base/basictypes.h" |
#include "base/compiler_specific.h" |
+#include "base/threading/non_thread_safe.h" |
namespace base { |
@@ -37,6 +38,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 is no |
+// contention for the instances. |
// |
// References: |
// - Linux: http://lwn.net/Articles/452035/ |
@@ -51,8 +55,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. |
@@ -72,6 +77,8 @@ class BASE_EXPORT DiscardableMemory { |
// after every successful lock call. |
void Unlock(); |
+ bool is_locked() const { return is_locked_; } |
+ |
// Return the memory address held by this object. The object must be locked |
// before calling this. Otherwise, this will cause a DCHECK error. |
void* Memory() const; |
@@ -87,6 +94,15 @@ class BASE_EXPORT DiscardableMemory { |
static void PurgeForTesting(); |
private: |
+#if !defined(DISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY) |
+ friend class DiscardableMemoryProvider; |
+ friend class DiscardableMemoryProviderTest; |
+ |
+ // Used by the DiscardableMemoryProvider to allocate and free memory. |
+ bool Allocate(); |
willchan no longer on Chromium
2013/08/27 03:23:15
Please document the return value.
Ian Vollick
2013/09/24 17:15:25
Done.
|
+ void Deallocate(); |
+#endif |
+ |
#if defined(OS_ANDROID) |
// Maps the discardable memory into the caller's address space. |
// Returns true on success, false otherwise. |