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

Unified Diff: base/memory/discardable_memory.h

Issue 114923005: base: Discardable memory types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review feedback Created 7 years 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 cbc2db630a86f6e5a7b5483723cd52f75fecf380..c8d6afa9cb639ffe9ae31dcd23d554a6048dc4e7 100644
--- a/base/memory/discardable_memory.h
+++ b/base/memory/discardable_memory.h
@@ -5,6 +5,8 @@
#ifndef BASE_MEMORY_DISCARDABLE_MEMORY_H_
#define BASE_MEMORY_DISCARDABLE_MEMORY_H_
+#include <vector>
+
#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
@@ -12,10 +14,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,
+ 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 +62,25 @@ 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();
+ // Get system supported discardable memory types. Preferred type at the front
Philippe 2013/12/18 09:07:47 Tiny nit: I would s/Get/Gets and same below for co
reveman 2013/12/18 19:44:25 Done.
+ // of vector.
+ static void GetSupportedTypes(std::vector<DiscardableMemoryType>* types);
+
+ // Set the current discardable memory type.
+ static void SetType(DiscardableMemoryType type);
+
+ // Get 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.

Powered by Google App Engine
This is Rietveld 408576698