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

Side by Side Diff: blimp/client/app/blimp_discardable_memory_allocator.cc

Issue 2233763002: blimp: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 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
« no previous file with comments | « no previous file | blimp/net/blob_channel/blob_channel_sender_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "blimp/client/app/blimp_discardable_memory_allocator.h" 5 #include "blimp/client/app/blimp_discardable_memory_allocator.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/discardable_memory.h" 8 #include "base/memory/discardable_memory.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/trace_event/memory_allocator_dump.h" 10 #include "base/trace_event/memory_allocator_dump.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 BlimpDiscardableMemoryAllocator::BlimpDiscardableMemoryAllocator( 111 BlimpDiscardableMemoryAllocator::BlimpDiscardableMemoryAllocator(
112 size_t desired_max_memory) 112 size_t desired_max_memory)
113 : desired_max_memory_(desired_max_memory), 113 : desired_max_memory_(desired_max_memory),
114 total_live_memory_(0u), 114 total_live_memory_(0u),
115 locked_chunks_(0) { 115 locked_chunks_(0) {
116 } 116 }
117 117
118 BlimpDiscardableMemoryAllocator::~BlimpDiscardableMemoryAllocator() { 118 BlimpDiscardableMemoryAllocator::~BlimpDiscardableMemoryAllocator() {
119 DCHECK_EQ(0, locked_chunks_); 119 DCHECK_EQ(0, locked_chunks_);
120 STLDeleteElements(&live_unlocked_chunks_); 120 base::STLDeleteElements(&live_unlocked_chunks_);
121 } 121 }
122 122
123 std::unique_ptr<base::DiscardableMemory> 123 std::unique_ptr<base::DiscardableMemory>
124 BlimpDiscardableMemoryAllocator::AllocateLockedDiscardableMemory(size_t size) { 124 BlimpDiscardableMemoryAllocator::AllocateLockedDiscardableMemory(size_t size) {
125 base::AutoLock lock(lock_); 125 base::AutoLock lock(lock_);
126 std::unique_ptr<DiscardableMemoryChunkImpl> chunk( 126 std::unique_ptr<DiscardableMemoryChunkImpl> chunk(
127 new DiscardableMemoryChunkImpl(size, this)); 127 new DiscardableMemoryChunkImpl(size, this));
128 total_live_memory_ += size; 128 total_live_memory_ += size;
129 locked_chunks_++; 129 locked_chunks_++;
130 130
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 while (total_live_memory_ > desired_max_memory_ && 164 while (total_live_memory_ > desired_max_memory_ &&
165 it != live_unlocked_chunks_.end()) { 165 it != live_unlocked_chunks_.end()) {
166 total_live_memory_ -= (*it)->size(); 166 total_live_memory_ -= (*it)->size();
167 (*it)->Discard(); 167 (*it)->Discard();
168 it = live_unlocked_chunks_.erase(it); 168 it = live_unlocked_chunks_.erase(it);
169 } 169 }
170 } 170 }
171 171
172 } // namespace client 172 } // namespace client
173 } // namespace blimp 173 } // namespace blimp
OLDNEW
« no previous file with comments | « no previous file | blimp/net/blob_channel/blob_channel_sender_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698