| 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 cleared because this method should create a non-weak |
| 141 GetSharedGlobalAllocatorDumpName(guid), guid); | 141 // dump. |
| 142 mad->clear_flags(MemoryAllocatorDump::Flags::WEAK); |
| 143 return mad; |
| 144 } |
| 145 return CreateAllocatorDump(GetSharedGlobalAllocatorDumpName(guid), guid); |
| 146 } |
| 147 |
| 148 MemoryAllocatorDump* ProcessMemoryDump::CreateWeakSharedGlobalAllocatorDump( |
| 149 const MemoryAllocatorDumpGuid& guid) { |
| 150 MemoryAllocatorDump* mad = GetSharedGlobalAllocatorDump(guid); |
| 151 if (mad) |
| 152 return mad; |
| 153 mad = CreateAllocatorDump(GetSharedGlobalAllocatorDumpName(guid), guid); |
| 154 mad->set_flags(MemoryAllocatorDump::Flags::WEAK); |
| 155 return mad; |
| 142 } | 156 } |
| 143 | 157 |
| 144 MemoryAllocatorDump* ProcessMemoryDump::GetSharedGlobalAllocatorDump( | 158 MemoryAllocatorDump* ProcessMemoryDump::GetSharedGlobalAllocatorDump( |
| 145 const MemoryAllocatorDumpGuid& guid) const { | 159 const MemoryAllocatorDumpGuid& guid) const { |
| 146 return GetAllocatorDump(GetSharedGlobalAllocatorDumpName(guid)); | 160 return GetAllocatorDump(GetSharedGlobalAllocatorDumpName(guid)); |
| 147 } | 161 } |
| 148 | 162 |
| 149 void ProcessMemoryDump::AddHeapDump(const std::string& absolute_name, | 163 void ProcessMemoryDump::AddHeapDump(const std::string& absolute_name, |
| 150 scoped_refptr<TracedValue> heap_dump) { | 164 scoped_refptr<TracedValue> heap_dump) { |
| 151 DCHECK_EQ(0ul, heap_dumps_.count(absolute_name)); | 165 DCHECK_EQ(0ul, heap_dumps_.count(absolute_name)); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 261 |
| 248 void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source, | 262 void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source, |
| 249 const std::string& target_node_name) { | 263 const std::string& target_node_name) { |
| 250 std::string child_mad_name = target_node_name + "/__" + source.ToString(); | 264 std::string child_mad_name = target_node_name + "/__" + source.ToString(); |
| 251 MemoryAllocatorDump* target_child_mad = CreateAllocatorDump(child_mad_name); | 265 MemoryAllocatorDump* target_child_mad = CreateAllocatorDump(child_mad_name); |
| 252 AddOwnershipEdge(source, target_child_mad->guid()); | 266 AddOwnershipEdge(source, target_child_mad->guid()); |
| 253 } | 267 } |
| 254 | 268 |
| 255 } // namespace trace_event | 269 } // namespace trace_event |
| 256 } // namespace base | 270 } // namespace base |
| OLD | NEW |