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

Unified Diff: base/memory/discardable_memory.h

Issue 15650016: [Not for review] Discardable memory emulation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 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
« no previous file with comments | « no previous file | base/memory/discardable_memory.cc » ('j') | base/memory/discardable_memory.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/discardable_memory.h
diff --git a/base/memory/discardable_memory.h b/base/memory/discardable_memory.h
index d6e91b979d5a46fdd50e6ef07ab4f52a904bc042..4d3fbec3654b0ccd7e3a0381572b32b17cab1c9e 100644
--- a/base/memory/discardable_memory.h
+++ b/base/memory/discardable_memory.h
@@ -17,6 +17,11 @@ enum LockDiscardableMemoryStatus {
DISCARDABLE_MEMORY_SUCCESS = 1
};
+#if !defined(OS_ANDROID) && !defined(OS_MACOSX)
nduca 2013/05/29 13:57:00 so, on windows 8, we have discardable memory but p
Ian Vollick 2013/06/06 00:21:47 I *think* this is done, but please let me know if
+// Used to emulate discardable memory on unsupported platforms.
+class DiscardableMemoryProvider;
+#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
@@ -54,6 +59,11 @@ class BASE_EXPORT DiscardableMemory {
// Check whether the system supports discardable memory.
static bool Supported();
+#if !defined(OS_ANDROID) && !defined(OS_MACOSX)
+ // Installs a provider to emulate discardable memory on unsupported platforms.
+ static void SetProvider(DiscardableMemoryProvider* provider);
+#endif
+
// Initialize the DiscardableMemory object. On success, this function returns
// true and the memory is locked. This should only be called once.
// This call could fail because of platform-specific limitations and the user
@@ -103,16 +113,31 @@ class BASE_EXPORT DiscardableMemory {
void ReleaseFileDescriptor();
#endif // OS_ANDROID
+#if defined(OS_ANDROID) || defined(OS_MACOSX)
jonathan.backer 2013/05/29 14:02:54 Maybe a #define DISCARDABLE_MEMORY_SUPPORTED defin
Ian Vollick 2013/06/06 00:21:47 Done.
void* memory_;
size_t size_;
bool is_locked_;
#if defined(OS_ANDROID)
int fd_;
#endif // OS_ANDROID
+#endif // OS_ANDROID || OS_MACOSX
DISALLOW_COPY_AND_ASSIGN(DiscardableMemory);
};
+#if !defined(OS_ANDROID) && !defined(OS_MACOSX)
+class BASE_EXPORT DiscardableMemoryProvider {
+ public:
+ virtual bool Register(const DiscardableMemory*, size_t size) = 0;
+ virtual void Unregister(const DiscardableMemory*) = 0;
+ virtual LockDiscardableMemoryStatus Lock(const DiscardableMemory*) = 0;
+ virtual void Unlock(const DiscardableMemory*) = 0;
+ virtual void* Memory(const DiscardableMemory*) const = 0;
+ virtual bool PurgeForTestingSupported() const = 0;
+ virtual void PurgeForTesting() = 0;
+};
+#endif
+
} // namespace base
#endif // BASE_MEMORY_DISCARDABLE_MEMORY_H_
« no previous file with comments | « no previous file | base/memory/discardable_memory.cc » ('j') | base/memory/discardable_memory.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698