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

Unified Diff: base/memory/discardable_memory_shmem_allocator.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_allocator.h ('k') | base/memory/discardable_memory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/discardable_memory_shmem_allocator.cc
diff --git a/base/memory/discardable_memory_shmem_allocator.cc b/base/memory/discardable_memory_shmem_allocator.cc
index 78d15c1031e7713bc9e80915dd894942c4d755b6..fdd68673420e84eafe67c5cfc4a90b955eea5714 100644
--- a/base/memory/discardable_memory_shmem_allocator.cc
+++ b/base/memory/discardable_memory_shmem_allocator.cc
@@ -11,19 +11,39 @@
namespace base {
namespace {
+class DiscardableMemoryShmemChunkImpl : public DiscardableMemoryShmemChunk {
+ public:
+ explicit DiscardableMemoryShmemChunkImpl(
+ scoped_ptr<DiscardableSharedMemory> shared_memory)
+ : shared_memory_(shared_memory.Pass()) {}
+
+ // Overridden from DiscardableMemoryShmemChunk:
+ bool Lock() override { return shared_memory_->Lock(0, 0); }
+ void Unlock() override { shared_memory_->Unlock(0, 0); }
+ void* Memory() const override { return shared_memory_->memory(); }
+ bool IsMemoryResident() const override {
+ return shared_memory_->IsMemoryResident();
+ }
+
+ private:
+ scoped_ptr<DiscardableSharedMemory> shared_memory_;
+
+ DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryShmemChunkImpl);
+};
+
// Default allocator implementation that allocates in-process
// DiscardableSharedMemory instances.
class DiscardableMemoryShmemAllocatorImpl
: public DiscardableMemoryShmemAllocator {
public:
// Overridden from DiscardableMemoryShmemAllocator:
- virtual scoped_ptr<DiscardableSharedMemory>
- AllocateLockedDiscardableSharedMemory(size_t size) override {
+ scoped_ptr<DiscardableMemoryShmemChunk>
+ AllocateLockedDiscardableMemory(size_t size) override {
scoped_ptr<DiscardableSharedMemory> memory(new DiscardableSharedMemory);
if (!memory->CreateAndMap(size))
- return scoped_ptr<DiscardableSharedMemory>();
+ return nullptr;
- return memory.Pass();
+ return make_scoped_ptr(new DiscardableMemoryShmemChunkImpl(memory.Pass()));
}
};
« no previous file with comments | « base/memory/discardable_memory_shmem_allocator.h ('k') | base/memory/discardable_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698