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

Unified Diff: base/memory/discardable_shared_memory.cc

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_shared_memory.h ('k') | base/memory/discardable_shared_memory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/discardable_shared_memory.cc
diff --git a/base/memory/discardable_shared_memory.cc b/base/memory/discardable_shared_memory.cc
index e04377ee3337a1732d491043481723ffa9cc2afb..3805bedccf1b6bcad2595ba6344241458679fb5f 100644
--- a/base/memory/discardable_shared_memory.cc
+++ b/base/memory/discardable_shared_memory.cc
@@ -157,7 +157,8 @@ bool DiscardableSharedMemory::Map(size_t size) {
return true;
}
-bool DiscardableSharedMemory::Lock(size_t offset, size_t length) {
+DiscardableSharedMemory::LockResult DiscardableSharedMemory::Lock(
+ size_t offset, size_t length) {
DCHECK_EQ(AlignToPageSize(offset), offset);
DCHECK_EQ(AlignToPageSize(length), length);
@@ -167,7 +168,7 @@ bool DiscardableSharedMemory::Lock(size_t offset, size_t length) {
// Return false when instance has been purged or not initialized properly by
// checking if |last_known_usage_| is NULL.
if (last_known_usage_.is_null())
- return false;
+ return FAILED;
DCHECK(shared_memory_.memory());
@@ -184,7 +185,7 @@ bool DiscardableSharedMemory::Lock(size_t offset, size_t length) {
// Update |last_known_usage_| in case the above CAS failed because of
// an incorrect timestamp.
last_known_usage_ = result.GetTimestamp();
- return false;
+ return FAILED;
}
}
@@ -214,11 +215,11 @@ bool DiscardableSharedMemory::Lock(size_t offset, size_t length) {
DCHECK(SharedMemory::IsHandleValid(handle));
if (ashmem_pin_region(
handle.fd, AlignToPageSize(sizeof(SharedState)) + offset, length)) {
- return false;
+ return PURGED;
}
#endif
- return true;
+ return SUCCESS;
}
void DiscardableSharedMemory::Unlock(size_t offset, size_t length) {
« no previous file with comments | « base/memory/discardable_shared_memory.h ('k') | base/memory/discardable_shared_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698