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

Side by Side Diff: base/trace_event/process_memory_dump.cc

Issue 1717283003: tracing: Make ConvertableToTraceFormat move-only scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/trace_event/process_memory_dump.h" 5 #include "base/trace_event/process_memory_dump.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/process/process_metrics.h" 10 #include "base/process/process_metrics.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 mad->set_flags(MemoryAllocatorDump::Flags::WEAK); 184 mad->set_flags(MemoryAllocatorDump::Flags::WEAK);
185 return mad; 185 return mad;
186 } 186 }
187 187
188 MemoryAllocatorDump* ProcessMemoryDump::GetSharedGlobalAllocatorDump( 188 MemoryAllocatorDump* ProcessMemoryDump::GetSharedGlobalAllocatorDump(
189 const MemoryAllocatorDumpGuid& guid) const { 189 const MemoryAllocatorDumpGuid& guid) const {
190 return GetAllocatorDump(GetSharedGlobalAllocatorDumpName(guid)); 190 return GetAllocatorDump(GetSharedGlobalAllocatorDumpName(guid));
191 } 191 }
192 192
193 void ProcessMemoryDump::AddHeapDump(const std::string& absolute_name, 193 void ProcessMemoryDump::AddHeapDump(const std::string& absolute_name,
194 scoped_refptr<TracedValue> heap_dump) { 194 scoped_ptr<TracedValue> heap_dump) {
195 DCHECK_EQ(0ul, heap_dumps_.count(absolute_name)); 195 DCHECK_EQ(0ul, heap_dumps_.count(absolute_name));
196 heap_dumps_[absolute_name] = heap_dump; 196 heap_dumps_[absolute_name] = std::move(heap_dump);
197 } 197 }
198 198
199 void ProcessMemoryDump::Clear() { 199 void ProcessMemoryDump::Clear() {
200 if (has_process_totals_) { 200 if (has_process_totals_) {
201 process_totals_.Clear(); 201 process_totals_.Clear();
202 has_process_totals_ = false; 202 has_process_totals_ = false;
203 } 203 }
204 204
205 if (has_process_mmaps_) { 205 if (has_process_mmaps_) {
206 process_mmaps_.Clear(); 206 process_mmaps_.Clear();
(...skipping 13 matching lines...) Expand all
220 for (auto& it : other->allocator_dumps_) 220 for (auto& it : other->allocator_dumps_)
221 AddAllocatorDumpInternal(std::move(it.second)); 221 AddAllocatorDumpInternal(std::move(it.second));
222 other->allocator_dumps_.clear(); 222 other->allocator_dumps_.clear();
223 223
224 // Move all the edges. 224 // Move all the edges.
225 allocator_dumps_edges_.insert(allocator_dumps_edges_.end(), 225 allocator_dumps_edges_.insert(allocator_dumps_edges_.end(),
226 other->allocator_dumps_edges_.begin(), 226 other->allocator_dumps_edges_.begin(),
227 other->allocator_dumps_edges_.end()); 227 other->allocator_dumps_edges_.end());
228 other->allocator_dumps_edges_.clear(); 228 other->allocator_dumps_edges_.clear();
229 229
230 heap_dumps_.insert(other->heap_dumps_.begin(), other->heap_dumps_.end()); 230 for (auto& it : other->heap_dumps_) {
231 DCHECK_EQ(0ul, heap_dumps_.count(it.first));
232 heap_dumps_.insert(std::make_pair(it.first, std::move(it.second)));
233 }
231 other->heap_dumps_.clear(); 234 other->heap_dumps_.clear();
232 } 235 }
233 236
234 void ProcessMemoryDump::AsValueInto(TracedValue* value) const { 237 void ProcessMemoryDump::AsValueInto(TracedValue* value) const {
235 if (has_process_totals_) { 238 if (has_process_totals_) {
236 value->BeginDictionary("process_totals"); 239 value->BeginDictionary("process_totals");
237 process_totals_.AsValueInto(value); 240 process_totals_.AsValueInto(value);
238 value->EndDictionary(); 241 value->EndDictionary();
239 } 242 }
240 243
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 288
286 void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source, 289 void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source,
287 const std::string& target_node_name) { 290 const std::string& target_node_name) {
288 std::string child_mad_name = target_node_name + "/__" + source.ToString(); 291 std::string child_mad_name = target_node_name + "/__" + source.ToString();
289 MemoryAllocatorDump* target_child_mad = CreateAllocatorDump(child_mad_name); 292 MemoryAllocatorDump* target_child_mad = CreateAllocatorDump(child_mad_name);
290 AddOwnershipEdge(source, target_child_mad->guid()); 293 AddOwnershipEdge(source, target_child_mad->guid());
291 } 294 }
292 295
293 } // namespace trace_event 296 } // namespace trace_event
294 } // namespace base 297 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698