Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |