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 <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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 MemoryAllocatorDump* ProcessMemoryDump::GetOrCreateAllocatorDump( | 128 MemoryAllocatorDump* ProcessMemoryDump::GetOrCreateAllocatorDump( |
129 const std::string& absolute_name) { | 129 const std::string& absolute_name) { |
130 MemoryAllocatorDump* mad = GetAllocatorDump(absolute_name); | 130 MemoryAllocatorDump* mad = GetAllocatorDump(absolute_name); |
131 return mad ? mad : CreateAllocatorDump(absolute_name); | 131 return mad ? mad : CreateAllocatorDump(absolute_name); |
132 } | 132 } |
133 | 133 |
134 MemoryAllocatorDump* ProcessMemoryDump::CreateSharedGlobalAllocatorDump( | 134 MemoryAllocatorDump* ProcessMemoryDump::CreateSharedGlobalAllocatorDump( |
135 const MemoryAllocatorDumpGuid& guid) { | 135 const MemoryAllocatorDumpGuid& guid) { |
136 // A shared allocator dump can be shared within a process and the guid could | 136 // A shared allocator dump can be shared within a process and the guid could |
137 // have been created already. | 137 // have been created already. |
138 MemoryAllocatorDump* allocator_dump = GetSharedGlobalAllocatorDump(guid); | 138 MemoryAllocatorDump* mad = GetSharedGlobalAllocatorDump(guid); |
139 return allocator_dump ? allocator_dump | 139 if (mad) { |
140 : CreateAllocatorDump( | 140 // The weak flag is unset because this method should create a non-weak dump. |
Primiano Tucci (use gerrit)
2016/01/19 17:07:11
s/unset/cleared/
ssid
2016/01/20 18:58:34
Done.
| |
141 GetSharedGlobalAllocatorDumpName(guid), guid); | 141 mad->unset_flags(MemoryAllocatorDump::Flag::WEAK); |
142 return mad; | |
143 } | |
144 return CreateAllocatorDump(GetSharedGlobalAllocatorDumpName(guid), guid); | |
145 } | |
146 | |
147 MemoryAllocatorDump* ProcessMemoryDump::CreateWeakSharedGlobalAllocatorDump( | |
148 const MemoryAllocatorDumpGuid& guid) { | |
149 MemoryAllocatorDump* mad = GetSharedGlobalAllocatorDump(guid); | |
150 if (mad) | |
151 return mad; | |
152 mad = CreateAllocatorDump(GetSharedGlobalAllocatorDumpName(guid), guid); | |
153 mad->set_flags(MemoryAllocatorDump::Flag::WEAK); | |
154 return mad; | |
142 } | 155 } |
143 | 156 |
144 MemoryAllocatorDump* ProcessMemoryDump::GetSharedGlobalAllocatorDump( | 157 MemoryAllocatorDump* ProcessMemoryDump::GetSharedGlobalAllocatorDump( |
145 const MemoryAllocatorDumpGuid& guid) const { | 158 const MemoryAllocatorDumpGuid& guid) const { |
146 return GetAllocatorDump(GetSharedGlobalAllocatorDumpName(guid)); | 159 return GetAllocatorDump(GetSharedGlobalAllocatorDumpName(guid)); |
147 } | 160 } |
148 | 161 |
149 void ProcessMemoryDump::AddHeapDump(const std::string& absolute_name, | 162 void ProcessMemoryDump::AddHeapDump(const std::string& absolute_name, |
150 scoped_refptr<TracedValue> heap_dump) { | 163 scoped_refptr<TracedValue> heap_dump) { |
151 DCHECK_EQ(0ul, heap_dumps_.count(absolute_name)); | 164 DCHECK_EQ(0ul, heap_dumps_.count(absolute_name)); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 | 260 |
248 void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source, | 261 void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source, |
249 const std::string& target_node_name) { | 262 const std::string& target_node_name) { |
250 std::string child_mad_name = target_node_name + "/__" + source.ToString(); | 263 std::string child_mad_name = target_node_name + "/__" + source.ToString(); |
251 MemoryAllocatorDump* target_child_mad = CreateAllocatorDump(child_mad_name); | 264 MemoryAllocatorDump* target_child_mad = CreateAllocatorDump(child_mad_name); |
252 AddOwnershipEdge(source, target_child_mad->guid()); | 265 AddOwnershipEdge(source, target_child_mad->guid()); |
253 } | 266 } |
254 | 267 |
255 } // namespace trace_event | 268 } // namespace trace_event |
256 } // namespace base | 269 } // namespace base |
OLD | NEW |