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

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

Issue 195863005: Use DiscardableMemoryManager on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use DiscardableMemoryController on Android Created 6 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 unified diff | Download patch | Annotate | Revision Log
« base/base.gypi ('K') | « base/memory/discardable_memory_ashmem.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_manager.h" 5 #include "base/memory/discardable_memory_manager.h"
6 6
7 #include "base/containers/hash_tables.h" 7 #include "base/containers/hash_tables.h"
8 #include "base/containers/mru_cache.h" 8 #include "base/containers/mru_cache.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 void DiscardableMemoryManager::Unlock(AllocationId allocation_id) { 115 void DiscardableMemoryManager::Unlock(AllocationId allocation_id) {
116 AutoLock lock(lock_); 116 AutoLock lock(lock_);
117 // NB: |allocations_| is an MRU cache, and use of |Get| here updates that 117 // NB: |allocations_| is an MRU cache, and use of |Get| here updates that
118 // cache. 118 // cache.
119 AllocationMap::iterator it = allocations_.Get(allocation_id); 119 AllocationMap::iterator it = allocations_.Get(allocation_id);
120 CHECK(it != allocations_.end()); 120 CHECK(it != allocations_.end());
121 121
122 DCHECK(it->second.allocation.get()); 122 DCHECK(it->second.allocation.get());
123 it->second.allocation->Unlock();
Philippe 2014/03/20 17:10:14 FYI: I need to do a rebase here.
123 DCHECK(it->second.locked); 124 DCHECK(it->second.locked);
124 it->second.locked = false; 125 it->second.locked = false;
125 EnforcePolicyWithLockAcquired(); 126 EnforcePolicyWithLockAcquired();
126 } 127 }
127 128
128 void DiscardableMemoryManager::PurgeUntilUsageIsWithin(size_t limit) { 129 void DiscardableMemoryManager::PurgeUntilUsageIsWithin(size_t limit) {
129 AutoLock lock(lock_); 130 AutoLock lock(lock_);
130 PurgeLRUWithLockAcquiredUntilUsageIsWithin(limit); 131 PurgeLRUWithLockAcquiredUntilUsageIsWithin(limit);
131 } 132 }
132 133
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 it->second.allocation.reset(); 175 it->second.allocation.reset();
175 } 176 }
176 } 177 }
177 178
178 void DiscardableMemoryManager::EnforcePolicyWithLockAcquired() { 179 void DiscardableMemoryManager::EnforcePolicyWithLockAcquired() {
179 PurgeLRUWithLockAcquiredUntilUsageIsWithin(discardable_memory_limit_); 180 PurgeLRUWithLockAcquiredUntilUsageIsWithin(discardable_memory_limit_);
180 } 181 }
181 182
182 } // namespace internal 183 } // namespace internal
183 } // namespace base 184 } // namespace base
OLDNEW
« base/base.gypi ('K') | « base/memory/discardable_memory_ashmem.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698