| 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 { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 allocator_dumps_storage_.push_back(mad); | 49 allocator_dumps_storage_.push_back(mad); |
| 50 allocator_dumps_[mad->absolute_name()] = mad; | 50 allocator_dumps_[mad->absolute_name()] = mad; |
| 51 } | 51 } |
| 52 | 52 |
| 53 MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump( | 53 MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump( |
| 54 const std::string& absolute_name) const { | 54 const std::string& absolute_name) const { |
| 55 auto it = allocator_dumps_.find(absolute_name); | 55 auto it = allocator_dumps_.find(absolute_name); |
| 56 return it == allocator_dumps_.end() ? nullptr : it->second; | 56 return it == allocator_dumps_.end() ? nullptr : it->second; |
| 57 } | 57 } |
| 58 | 58 |
| 59 MemoryAllocatorDump* ProcessMemoryDump::GetOrCreateAllocatorDump( |
| 60 const std::string& absolute_name) { |
| 61 MemoryAllocatorDump* mad = GetAllocatorDump(absolute_name); |
| 62 if (mad) |
| 63 return mad; |
| 64 return CreateAllocatorDump(absolute_name); |
| 65 } |
| 66 |
| 59 MemoryAllocatorDump* ProcessMemoryDump::CreateSharedGlobalAllocatorDump( | 67 MemoryAllocatorDump* ProcessMemoryDump::CreateSharedGlobalAllocatorDump( |
| 60 const MemoryAllocatorDumpGuid& guid) { | 68 const MemoryAllocatorDumpGuid& guid) { |
| 61 // A shared allocator dump can be shared within a process and the guid could | 69 // A shared allocator dump can be shared within a process and the guid could |
| 62 // have been created already. | 70 // have been created already. |
| 63 MemoryAllocatorDump* allocator_dump = GetSharedGlobalAllocatorDump(guid); | 71 MemoryAllocatorDump* allocator_dump = GetSharedGlobalAllocatorDump(guid); |
| 64 return allocator_dump ? allocator_dump | 72 return allocator_dump ? allocator_dump |
| 65 : CreateAllocatorDump( | 73 : CreateAllocatorDump( |
| 66 GetSharedGlobalAllocatorDumpName(guid), guid); | 74 GetSharedGlobalAllocatorDumpName(guid), guid); |
| 67 } | 75 } |
| 68 | 76 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 163 |
| 156 void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source, | 164 void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source, |
| 157 const std::string& target_node_name) { | 165 const std::string& target_node_name) { |
| 158 std::string child_mad_name = target_node_name + "/__" + source.ToString(); | 166 std::string child_mad_name = target_node_name + "/__" + source.ToString(); |
| 159 MemoryAllocatorDump* target_child_mad = CreateAllocatorDump(child_mad_name); | 167 MemoryAllocatorDump* target_child_mad = CreateAllocatorDump(child_mad_name); |
| 160 AddOwnershipEdge(source, target_child_mad->guid()); | 168 AddOwnershipEdge(source, target_child_mad->guid()); |
| 161 } | 169 } |
| 162 | 170 |
| 163 } // namespace trace_event | 171 } // namespace trace_event |
| 164 } // namespace base | 172 } // namespace base |
| OLD | NEW |