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

Unified Diff: base/memory/discardable_shared_memory.h

Issue 871043003: base: Improve DiscardableSharedMemory support for ashmem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing return statement Created 5 years, 11 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 | « base/memory/discardable_memory_shmem_allocator.cc ('k') | base/memory/discardable_shared_memory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/discardable_shared_memory.h
diff --git a/base/memory/discardable_shared_memory.h b/base/memory/discardable_shared_memory.h
index abee8687a86ee43547057274386244275517d035..59c5d5b54024eef56cd4efbb1a49d3b567548928 100644
--- a/base/memory/discardable_shared_memory.h
+++ b/base/memory/discardable_shared_memory.h
@@ -23,6 +23,8 @@ namespace base {
// access to an instance of this class.
class BASE_EXPORT DiscardableSharedMemory {
public:
+ enum LockResult { SUCCESS, PURGED, FAILED };
+
DiscardableSharedMemory();
// Create a new DiscardableSharedMemory object from an existing, open shared
@@ -47,16 +49,18 @@ class BASE_EXPORT DiscardableSharedMemory {
SharedMemoryHandle handle() const { return shared_memory_.handle(); }
// Locks a range of memory so that it will not be purged by the system.
- // Returns true if successful and the memory is still resident. Locking can
- // fail for three reasons; object might have been purged, our last known usage
- // timestamp might be out of date or memory might already be locked. Last
- // know usage time is updated to the actual last usage timestamp if memory
- // is still resident or 0 if not. The range of memory must be unlocked. The
- // result of trying to lock an already locked range is undefined.
- // |offset| and |length| must both be a multiple of the page size as returned
- // by GetPageSize().
+ // The range of memory must be unlocked. The result of trying to lock an
+ // already locked range is undefined. |offset| and |length| must both be
+ // a multiple of the page size as returned by GetPageSize().
// Passing 0 for |length| means "everything onward".
- bool Lock(size_t offset, size_t length);
+ // Returns SUCCESS if range was successfully locked and the memory is still
+ // resident, PURGED if range was successfully locked but has been purged
+ // since last time it was locked and FAILED if range could not be locked.
+ // Locking can fail for two reasons; object might have been purged, our
+ // last known usage timestamp might be out of date. Last known usage time
+ // is updated to the actual last usage timestamp if memory is still resident
+ // or 0 if not.
+ LockResult Lock(size_t offset, size_t length);
// Unlock a previously successfully locked range of memory. The range of
// memory must be locked. The result of trying to unlock a not
« no previous file with comments | « base/memory/discardable_memory_shmem_allocator.cc ('k') | base/memory/discardable_shared_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698