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

Unified Diff: base/memory/discardable_memory_shmem_allocator.cc

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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_mac.cc ('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 761204f31220d043e526f6cb35e3548e6eca237f..a87c58d415d480d2cac8b7dc30389222d78e557f 100644
--- a/base/memory/discardable_memory_shmem_allocator.cc
+++ b/base/memory/discardable_memory_shmem_allocator.cc
@@ -11,45 +11,6 @@
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 false; }
- void Unlock() override {
- shared_memory_->Unlock(0, 0);
- shared_memory_.reset();
- }
- void* Memory() const override { return shared_memory_->memory(); }
-
- 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:
- scoped_ptr<DiscardableMemoryShmemChunk>
- AllocateLockedDiscardableMemory(size_t size) override {
- scoped_ptr<DiscardableSharedMemory> memory(new DiscardableSharedMemory);
- if (!memory->CreateAndMap(size))
- return nullptr;
-
- return make_scoped_ptr(new DiscardableMemoryShmemChunkImpl(memory.Pass()));
- }
-};
-
-LazyInstance<DiscardableMemoryShmemAllocatorImpl>::Leaky g_default_allocator =
- LAZY_INSTANCE_INITIALIZER;
-
DiscardableMemoryShmemAllocator* g_allocator = nullptr;
} // namespace
@@ -69,9 +30,7 @@ void DiscardableMemoryShmemAllocator::SetInstance(
// static
DiscardableMemoryShmemAllocator*
DiscardableMemoryShmemAllocator::GetInstance() {
- if (!g_allocator)
- g_allocator = g_default_allocator.Pointer();
-
+ DCHECK(g_allocator);
return g_allocator;
}
« no previous file with comments | « base/memory/discardable_memory_mac.cc ('k') | base/memory/discardable_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698