Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Unified Diff: base/memory/discardable_memory.h

Issue 17106004: Add discardable memory emulation for non-android/mac platforms (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/memory/discardable_memory.h
diff --git a/base/memory/discardable_memory.h b/base/memory/discardable_memory.h
index d6e91b979d5a46fdd50e6ef07ab4f52a904bc042..70294fbb64d11c20db33d8c9a3a1d0206abe8dd9 100644
--- a/base/memory/discardable_memory.h
+++ b/base/memory/discardable_memory.h
@@ -17,6 +17,10 @@ enum LockDiscardableMemoryStatus {
DISCARDABLE_MEMORY_SUCCESS = 1
};
+#if defined(OS_MACOSX) || defined(OS_ANDROID)
+#define DISCARDABLE_MEMORY_SUPPORTED_NATIVELY
+#endif
+
// Platform abstraction for discardable memory. DiscardableMemory is used to
// cache large objects without worrying about blowing out memory, both on mobile
// devices where there is no swap, and desktop devices where unused free memory
@@ -72,6 +76,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 +93,15 @@ class BASE_EXPORT DiscardableMemory {
static void PurgeForTesting();
private:
+#if !defined(DISCARDABLE_MEMORY_SUPPORTED_NATIVELY)
Avi (use Gerrit) 2013/06/18 00:00:46 How will this work on a platform like Win32 where
+ friend class DiscardableMemoryProvider;
+ friend class DiscardableMemoryProviderTest;
+
+ // Used by the DiscardableMemoryProvider to allocate and free memory.
+ bool Allocate();
+ void Deallocate();
+#endif
+
#if defined(OS_ANDROID)
// Maps the discardable memory into the caller's address space.
// Returns true on success, false otherwise.

Powered by Google App Engine
This is Rietveld 408576698