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

Side by Side Diff: content/common/discardable_shared_memory_heap.cc

Issue 952273005: content: Update crash key and discardable memory usage counter in child process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.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 unified diff | Download patch
« no previous file with comments | « content/common/discardable_shared_memory_heap.h ('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 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 "content/common/discardable_shared_memory_heap.h" 5 #include "content/common/discardable_shared_memory_heap.h"
6 6
7 #include "base/memory/discardable_shared_memory.h" 7 #include "base/memory/discardable_shared_memory.h"
8 8
9 namespace content { 9 namespace content {
10 namespace { 10 namespace {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 if ((span->length_ == best->length_) && (span->start_ > best->start_)) 135 if ((span->length_ == best->length_) && (span->start_ > best->start_))
136 continue; 136 continue;
137 } 137 }
138 138
139 best = span; 139 best = span;
140 } 140 }
141 141
142 return best ? Carve(best, blocks) : nullptr; 142 return best ? Carve(best, blocks) : nullptr;
143 } 143 }
144 144
145 void DiscardableSharedMemoryHeap::ReleaseFreeMemory() { 145 size_t DiscardableSharedMemoryHeap::ReleaseFreeMemory() {
146 size_t bytes_released = 0;
146 size_t i = 0; 147 size_t i = 0;
147 148
148 // Release memory for all non-resident segments. 149 // Release memory for all non-resident segments.
149 while (i < shared_memory_segments_.size()) { 150 while (i < shared_memory_segments_.size()) {
150 base::DiscardableSharedMemory* shared_memory = shared_memory_segments_[i]; 151 base::DiscardableSharedMemory* shared_memory = shared_memory_segments_[i];
151 152
152 // Skip segment if still resident. 153 // Skip segment if still resident.
153 if (shared_memory->IsMemoryResident()) { 154 if (shared_memory->IsMemoryResident()) {
154 ++i; 155 ++i;
155 continue; 156 continue;
156 } 157 }
157 158
159 bytes_released += shared_memory->mapped_size();
160
158 // Release the memory and unregistering all associated spans. 161 // Release the memory and unregistering all associated spans.
159 ReleaseMemory(shared_memory); 162 ReleaseMemory(shared_memory);
160 163
161 std::swap(shared_memory_segments_[i], shared_memory_segments_.back()); 164 std::swap(shared_memory_segments_[i], shared_memory_segments_.back());
162 shared_memory_segments_.pop_back(); 165 shared_memory_segments_.pop_back();
163 } 166 }
167
168 return bytes_released;
164 } 169 }
165 170
166 scoped_ptr<DiscardableSharedMemoryHeap::Span> 171 scoped_ptr<DiscardableSharedMemoryHeap::Span>
167 DiscardableSharedMemoryHeap::RemoveFromFreeList(Span* span) { 172 DiscardableSharedMemoryHeap::RemoveFromFreeList(Span* span) {
168 span->RemoveFromList(); 173 span->RemoveFromList();
169 return make_scoped_ptr(span); 174 return make_scoped_ptr(span);
170 } 175 }
171 176
172 scoped_ptr<DiscardableSharedMemoryHeap::Span> 177 scoped_ptr<DiscardableSharedMemoryHeap::Span>
173 DiscardableSharedMemoryHeap::Carve(Span* span, size_t blocks) { 178 DiscardableSharedMemoryHeap::Carve(Span* span, size_t blocks) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 228
224 offset += span->length_; 229 offset += span->length_;
225 230
226 // If |span| is in the free list, remove it. 231 // If |span| is in the free list, remove it.
227 if (IsInFreeList(span)) 232 if (IsInFreeList(span))
228 RemoveFromFreeList(span); 233 RemoveFromFreeList(span);
229 } 234 }
230 } 235 }
231 236
232 } // namespace content 237 } // namespace content
OLDNEW
« no previous file with comments | « content/common/discardable_shared_memory_heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698