OLD | NEW |
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& name) { | 24 const std::string& allocator_name, |
25 return CreateAllocatorDump(name, nullptr); | 25 const std::string& heap_name) { |
26 } | 26 MemoryAllocatorDump* mad = |
27 | 27 new MemoryAllocatorDump(allocator_name, heap_name, this); |
28 MemoryAllocatorDump* ProcessMemoryDump::CreateAllocatorDump( | 28 DCHECK_EQ(0ul, allocator_dumps_.count(mad->GetAbsoluteName())); |
29 const std::string& name, | |
30 MemoryAllocatorDump* parent) { | |
31 DCHECK_EQ(0ul, allocator_dumps_.count(name)); | |
32 MemoryAllocatorDump* mad = new MemoryAllocatorDump(name, parent); | |
33 allocator_dumps_storage_.push_back(mad); | 29 allocator_dumps_storage_.push_back(mad); |
34 allocator_dumps_[name] = mad; | 30 allocator_dumps_[mad->GetAbsoluteName()] = mad; |
35 return mad; | 31 return mad; |
36 } | 32 } |
37 | 33 |
38 MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump( | 34 MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump( |
39 const std::string& name) const { | 35 const std::string& allocator_name, |
40 auto it = allocator_dumps_.find(name); | 36 const std::string& heap_name) const { |
| 37 auto it = allocator_dumps_.find( |
| 38 MemoryAllocatorDump::GetAbsoluteName(allocator_name, heap_name)); |
41 return it == allocator_dumps_.end() ? nullptr : it->second; | 39 return it == allocator_dumps_.end() ? nullptr : it->second; |
42 } | 40 } |
43 | 41 |
44 void ProcessMemoryDump::AsValueInto(TracedValue* value) const { | 42 void ProcessMemoryDump::AsValueInto(TracedValue* value) const { |
45 // Build up the [dumper name] -> [value] dictionary. | 43 // Build up the [dumper name] -> [value] dictionary. |
46 if (has_process_totals_) { | 44 if (has_process_totals_) { |
47 value->BeginDictionary("process_totals"); | 45 value->BeginDictionary("process_totals"); |
48 process_totals_.AsValueInto(value); | 46 process_totals_.AsValueInto(value); |
49 value->EndDictionary(); | 47 value->EndDictionary(); |
50 } | 48 } |
51 if (has_process_mmaps_) { | 49 if (has_process_mmaps_) { |
52 value->BeginDictionary("process_mmaps"); | 50 value->BeginDictionary("process_mmaps"); |
53 process_mmaps_.AsValueInto(value); | 51 process_mmaps_.AsValueInto(value); |
54 value->EndDictionary(); | 52 value->EndDictionary(); |
55 } | 53 } |
56 if (allocator_dumps_storage_.size() > 0) { | 54 if (allocator_dumps_storage_.size() > 0) { |
57 value->BeginDictionary("allocators"); | 55 value->BeginDictionary("allocators"); |
58 for (const MemoryAllocatorDump* allocator_dump : allocator_dumps_storage_) | 56 for (const MemoryAllocatorDump* allocator_dump : allocator_dumps_storage_) |
59 allocator_dump->AsValueInto(value); | 57 allocator_dump->AsValueInto(value); |
60 value->EndDictionary(); | 58 value->EndDictionary(); |
61 } | 59 } |
62 } | 60 } |
63 | 61 |
64 } // namespace trace_event | 62 } // namespace trace_event |
65 } // namespace base | 63 } // namespace base |
OLD | NEW |