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

Unified Diff: base/memory/discardable_memory_shmem.cc

Issue 817653003: Update from https://crrev.com/309717 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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
« no previous file with comments | « base/memory/discardable_memory_shmem.h ('k') | base/memory/discardable_memory_shmem_allocator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/discardable_memory_shmem.cc
diff --git a/base/memory/discardable_memory_shmem.cc b/base/memory/discardable_memory_shmem.cc
index 42824813f8452bb51462d311d932ac49cd47fc48..416fcf2aa9fede8388c4895ec4084307d84c75ae 100644
--- a/base/memory/discardable_memory_shmem.cc
+++ b/base/memory/discardable_memory_shmem.cc
@@ -88,33 +88,31 @@ void DiscardableMemoryShmem::Unlock() {
void* DiscardableMemoryShmem::Memory() const {
DCHECK(is_locked_);
- DCHECK(shared_memory_);
- return shared_memory_->memory();
+ DCHECK(chunk_);
+ return chunk_->Memory();
}
bool DiscardableMemoryShmem::AllocateAndAcquireLock() {
- if (shared_memory_ && shared_memory_->Lock(0, 0))
+ if (chunk_ && chunk_->Lock())
return true;
- // TODO(reveman): Allocate fixed size memory segments and use a free list to
- // improve performance and limit the number of file descriptors used.
- shared_memory_ = DiscardableMemoryShmemAllocator::GetInstance()
- ->AllocateLockedDiscardableSharedMemory(bytes_);
- DCHECK(shared_memory_);
+ chunk_ = DiscardableMemoryShmemAllocator::GetInstance()
+ ->AllocateLockedDiscardableMemory(bytes_);
+ DCHECK(chunk_);
return false;
}
void DiscardableMemoryShmem::ReleaseLock() {
- shared_memory_->Unlock(0, 0);
+ chunk_->Unlock();
}
void DiscardableMemoryShmem::Purge() {
- shared_memory_->Purge(Time());
- shared_memory_.reset();
+ DCHECK(!is_locked_);
+ chunk_.reset();
}
bool DiscardableMemoryShmem::IsMemoryResident() const {
- return shared_memory_->IsMemoryResident();
+ return chunk_->IsMemoryResident();
}
} // namespace internal
« no previous file with comments | « base/memory/discardable_memory_shmem.h ('k') | base/memory/discardable_memory_shmem_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698