Chromium Code Reviews| Index: base/memory/discardable_memory.h |
| diff --git a/base/memory/discardable_memory.h b/base/memory/discardable_memory.h |
| index cbc2db630a86f6e5a7b5483723cd52f75fecf380..0842fac2d32f8976f657a11159812f1b4c0dc834 100644 |
| --- a/base/memory/discardable_memory.h |
| +++ b/base/memory/discardable_memory.h |
| @@ -5,6 +5,9 @@ |
| #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_H_ |
| #define BASE_MEMORY_DISCARDABLE_MEMORY_H_ |
| +#include <string> |
| +#include <vector> |
| + |
| #include "base/base_export.h" |
| #include "base/basictypes.h" |
| #include "base/compiler_specific.h" |
| @@ -12,10 +15,17 @@ |
| namespace base { |
| -enum LockDiscardableMemoryStatus { |
| - DISCARDABLE_MEMORY_FAILED = -1, |
| - DISCARDABLE_MEMORY_PURGED = 0, |
| - DISCARDABLE_MEMORY_SUCCESS = 1 |
| +enum DiscardableMemoryType { |
| + DISCARDABLE_MEMORY_TYPE_NONE, |
| + DISCARDABLE_MEMORY_TYPE_ANDROID, |
|
willchan no longer on Chromium
2013/12/24 01:21:06
My inclination is to say we should guard these pla
reveman
2013/12/26 11:46:08
My plan here is to turn TYPE_ANDROID into TYPE_ASH
willchan no longer on Chromium
2013/12/26 18:25:54
This isn't a big deal and is mostly stylistic pref
reveman
2013/12/26 21:53:35
I'll keep it in mind and re-evaluate as I land mor
|
| + DISCARDABLE_MEMORY_TYPE_MAC, |
| + DISCARDABLE_MEMORY_TYPE_EMULATED |
| +}; |
| + |
| +enum DiscardableMemoryLockStatus { |
| + DISCARDABLE_MEMORY_LOCK_STATUS_FAILED, |
| + DISCARDABLE_MEMORY_LOCK_STATUS_PURGED, |
| + DISCARDABLE_MEMORY_LOCK_STATUS_SUCCESS |
| }; |
| // Platform abstraction for discardable memory. DiscardableMemory is used to |
| @@ -53,19 +63,31 @@ class BASE_EXPORT DiscardableMemory { |
| public: |
| virtual ~DiscardableMemory() {} |
| - // Check whether the system supports discardable memory natively. Returns |
| - // false if the support is emulated. |
| - static bool SupportedNatively(); |
| + // Gets the discardable memory type with a given name. |
| + static DiscardableMemoryType GetNamedType(const std::string& name); |
| + |
| + // Gets the name of a discardable memory type. |
| + static const char* GetTypeName(DiscardableMemoryType type); |
| + |
| + // Gets system supported discardable memory types. Preferred type at the |
| + // front of vector. |
| + static void GetSupportedTypes(std::vector<DiscardableMemoryType>* types); |
| + |
| + // Sets the current discardable memory type. |
| + static void SetType(DiscardableMemoryType type); |
| + |
| + // Gets the current discardable memory type. |
| + static DiscardableMemoryType GetType(); |
| static scoped_ptr<DiscardableMemory> CreateLockedMemory(size_t size); |
| // Locks the memory so that it will not be purged by the system. Returns |
| - // DISCARDABLE_MEMORY_SUCCESS on success. If the return value is |
| - // DISCARDABLE_MEMORY_FAILED then this object should be discarded and |
| - // a new one should be created. If the return value is |
| - // DISCARDABLE_MEMORY_PURGED then the memory is present but any data that |
| - // was in it is gone. |
| - virtual LockDiscardableMemoryStatus Lock() WARN_UNUSED_RESULT = 0; |
| + // DISCARDABLE_MEMORY_LOCK_STATUS_SUCCESS on success. If the return value is |
| + // DISCARDABLE_MEMORY_LOCK_STATUS_FAILED then this object should be |
| + // discarded and a new one should be created. If the return value is |
| + // DISCARDABLE_MEMORY_LOCK_STATUS_PURGED then the memory is present but any |
| + // data that was in it is gone. |
| + virtual DiscardableMemoryLockStatus Lock() WARN_UNUSED_RESULT = 0; |
| // Unlocks the memory so that it can be purged by the system. Must be called |
| // after every successful lock call. |