Index: base/trace_event/process_memory_dump.cc |
diff --git a/base/trace_event/process_memory_dump.cc b/base/trace_event/process_memory_dump.cc |
index 9f710936e1405f2b4215761ab0d357d75b7dbd8d..13b3835f9a48855e7c7899e0fd52b410e7d9be36 100644 |
--- a/base/trace_event/process_memory_dump.cc |
+++ b/base/trace_event/process_memory_dump.cc |
@@ -286,8 +286,7 @@ void ProcessMemoryDump::TakeAllDumpsFrom(ProcessMemoryDump* other) { |
other->allocator_dumps_.clear(); |
// Move all the edges. |
- allocator_dumps_edges_.insert(allocator_dumps_edges_.end(), |
- other->allocator_dumps_edges_.begin(), |
+ allocator_dumps_edges_.insert(other->allocator_dumps_edges_.begin(), |
other->allocator_dumps_edges_.end()); |
other->allocator_dumps_edges_.clear(); |
@@ -326,7 +325,8 @@ void ProcessMemoryDump::AsValueInto(TracedValue* value) const { |
} |
value->BeginArray("allocators_graph"); |
- for (const MemoryAllocatorDumpEdge& edge : allocator_dumps_edges_) { |
+ for (const auto& it : allocator_dumps_edges_) { |
+ const MemoryAllocatorDumpEdge& edge = it.second; |
value->BeginDictionary(); |
value->SetString("source", edge.source.ToString()); |
value->SetString("target", edge.target.ToString()); |
@@ -340,8 +340,10 @@ void ProcessMemoryDump::AsValueInto(TracedValue* value) const { |
void ProcessMemoryDump::AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, |
const MemoryAllocatorDumpGuid& target, |
int importance) { |
- allocator_dumps_edges_.push_back( |
- {source, target, importance, kEdgeTypeOwnership}); |
+ DCHECK(allocator_dumps_edges_.count(source) == 0 || |
+ allocator_dumps_edges_[source].overridable); |
+ allocator_dumps_edges_[source] = { |
+ source, target, importance, kEdgeTypeOwnership, false /* overridable */}; |
} |
void ProcessMemoryDump::AddOwnershipEdge( |
@@ -350,6 +352,21 @@ void ProcessMemoryDump::AddOwnershipEdge( |
AddOwnershipEdge(source, target, 0 /* importance */); |
} |
+void ProcessMemoryDump::AddOverridableOwnershipEdge( |
+ const MemoryAllocatorDumpGuid& source, |
+ const MemoryAllocatorDumpGuid& target, |
+ int importance) { |
+ if (allocator_dumps_edges_.count(source) == 0) { |
+ allocator_dumps_edges_[source] = { |
+ source, target, importance, kEdgeTypeOwnership, true /* overridable */}; |
+ } else { |
+ // An edge between the source and target already exits. So, do nothing here |
+ // since the new overridable edge is implicitly overridden by a strong edge |
+ // which was created earlier. |
+ DCHECK(!allocator_dumps_edges_[source].overridable); |
+ } |
+} |
+ |
void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source, |
const std::string& target_node_name) { |
// Do not create new dumps for suballocations in background mode. |