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_ |