Chromium Code Reviews

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

Issue 1128733002: Update from https://crrev.com/328418 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 "base/trace_event/process_memory_totals.h" 7 #include "base/trace_event/process_memory_totals.h"
8 #include "base/trace_event/trace_event_argument.h" 8 #include "base/trace_event/trace_event_argument.h"
9 9
10 namespace base { 10 namespace base {
11 namespace trace_event { 11 namespace trace_event {
12 12
13 ProcessMemoryDump::ProcessMemoryDump( 13 ProcessMemoryDump::ProcessMemoryDump(
14 const scoped_refptr<MemoryDumpSessionState>& session_state) 14 const scoped_refptr<MemoryDumpSessionState>& session_state)
15 : has_process_totals_(false), 15 : has_process_totals_(false),
16 has_process_mmaps_(false), 16 has_process_mmaps_(false),
17 session_state_(session_state) { 17 session_state_(session_state) {
18 } 18 }
19 19
20 ProcessMemoryDump::~ProcessMemoryDump() { 20 ProcessMemoryDump::~ProcessMemoryDump() {
21 } 21 }
22 22
23 MemoryAllocatorDump* ProcessMemoryDump::CreateAllocatorDump( 23 MemoryAllocatorDump* ProcessMemoryDump::CreateAllocatorDump(
24 const std::string& allocator_name, 24 const std::string& absolute_name) {
25 const std::string& heap_name) { 25 MemoryAllocatorDump* mad = new MemoryAllocatorDump(absolute_name, this);
26 MemoryAllocatorDump* mad = 26 DCHECK_EQ(0ul, allocator_dumps_.count(absolute_name));
27 new MemoryAllocatorDump(allocator_name, heap_name, this);
28 DCHECK_EQ(0ul, allocator_dumps_.count(mad->GetAbsoluteName()));
29 allocator_dumps_storage_.push_back(mad); 27 allocator_dumps_storage_.push_back(mad);
30 allocator_dumps_[mad->GetAbsoluteName()] = mad; 28 allocator_dumps_[absolute_name] = mad;
31 return mad; 29 return mad;
32 } 30 }
33 31
34 MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump( 32 MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump(
35 const std::string& allocator_name, 33 const std::string& absolute_name) const {
36 const std::string& heap_name) const { 34 auto it = allocator_dumps_.find(absolute_name);
37 auto it = allocator_dumps_.find(
38 MemoryAllocatorDump::GetAbsoluteName(allocator_name, heap_name));
39 return it == allocator_dumps_.end() ? nullptr : it->second; 35 return it == allocator_dumps_.end() ? nullptr : it->second;
40 } 36 }
41 37
42 void ProcessMemoryDump::AsValueInto(TracedValue* value) const { 38 void ProcessMemoryDump::AsValueInto(TracedValue* value) const {
43 // Build up the [dumper name] -> [value] dictionary. 39 // Build up the [dumper name] -> [value] dictionary.
44 if (has_process_totals_) { 40 if (has_process_totals_) {
45 value->BeginDictionary("process_totals"); 41 value->BeginDictionary("process_totals");
46 process_totals_.AsValueInto(value); 42 process_totals_.AsValueInto(value);
47 value->EndDictionary(); 43 value->EndDictionary();
48 } 44 }
49 if (has_process_mmaps_) { 45 if (has_process_mmaps_) {
50 value->BeginDictionary("process_mmaps"); 46 value->BeginDictionary("process_mmaps");
51 process_mmaps_.AsValueInto(value); 47 process_mmaps_.AsValueInto(value);
52 value->EndDictionary(); 48 value->EndDictionary();
53 } 49 }
54 if (allocator_dumps_storage_.size() > 0) { 50 if (allocator_dumps_storage_.size() > 0) {
55 value->BeginDictionary("allocators"); 51 value->BeginDictionary("allocators");
56 for (const MemoryAllocatorDump* allocator_dump : allocator_dumps_storage_) 52 for (const MemoryAllocatorDump* allocator_dump : allocator_dumps_storage_)
57 allocator_dump->AsValueInto(value); 53 allocator_dump->AsValueInto(value);
58 value->EndDictionary(); 54 value->EndDictionary();
59 } 55 }
60 } 56 }
61 57
62 } // namespace trace_event 58 } // namespace trace_event
63 } // namespace base 59 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/process_memory_dump.h ('k') | base/trace_event/process_memory_maps_dump_provider.h » ('j') | no next file with comments »

Powered by Google App Engine