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

Side by Side Diff: base/memory/discardable_memory_shmem.cc

Issue 822713002: Update from https://crrev.com/309415 (Closed) Base URL: https://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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/discardable_memory_shmem.h" 5 #include "base/memory/discardable_memory_shmem.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/discardable_memory_shmem_allocator.h" 8 #include "base/memory/discardable_memory_shmem_allocator.h"
9 #include "base/memory/discardable_shared_memory.h" 9 #include "base/memory/discardable_shared_memory.h"
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 is_locked_ = false; 86 is_locked_ = false;
87 } 87 }
88 88
89 void* DiscardableMemoryShmem::Memory() const { 89 void* DiscardableMemoryShmem::Memory() const {
90 DCHECK(is_locked_); 90 DCHECK(is_locked_);
91 DCHECK(shared_memory_); 91 DCHECK(shared_memory_);
92 return shared_memory_->memory(); 92 return shared_memory_->memory();
93 } 93 }
94 94
95 bool DiscardableMemoryShmem::AllocateAndAcquireLock() { 95 bool DiscardableMemoryShmem::AllocateAndAcquireLock() {
96 if (shared_memory_ && shared_memory_->Lock()) 96 if (shared_memory_ && shared_memory_->Lock(0, 0))
97 return true; 97 return true;
98 98
99 // TODO(reveman): Allocate fixed size memory segments and use a free list to 99 // TODO(reveman): Allocate fixed size memory segments and use a free list to
100 // improve performance and limit the number of file descriptors used. 100 // improve performance and limit the number of file descriptors used.
101 shared_memory_ = DiscardableMemoryShmemAllocator::GetInstance() 101 shared_memory_ = DiscardableMemoryShmemAllocator::GetInstance()
102 ->AllocateLockedDiscardableSharedMemory(bytes_); 102 ->AllocateLockedDiscardableSharedMemory(bytes_);
103 DCHECK(shared_memory_); 103 DCHECK(shared_memory_);
104 return false; 104 return false;
105 } 105 }
106 106
107 void DiscardableMemoryShmem::ReleaseLock() { 107 void DiscardableMemoryShmem::ReleaseLock() {
108 shared_memory_->Unlock(); 108 shared_memory_->Unlock(0, 0);
109 } 109 }
110 110
111 void DiscardableMemoryShmem::Purge() { 111 void DiscardableMemoryShmem::Purge() {
112 shared_memory_->Purge(Time()); 112 shared_memory_->Purge(Time());
113 shared_memory_.reset(); 113 shared_memory_.reset();
114 } 114 }
115 115
116 bool DiscardableMemoryShmem::IsMemoryResident() const { 116 bool DiscardableMemoryShmem::IsMemoryResident() const {
117 return shared_memory_->IsMemoryResident(); 117 return shared_memory_->IsMemoryResident();
118 } 118 }
119 119
120 } // namespace internal 120 } // namespace internal
121 } // namespace base 121 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698