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 d8a51ef4fe1e193415b3933a6c1e947b62303998..7d720c4ed798eae9d70942577e1050a87b8315b9 100644 |
--- a/base/trace_event/process_memory_dump.cc |
+++ b/base/trace_event/process_memory_dump.cc |
@@ -11,8 +11,8 @@ |
#include "base/memory/ptr_util.h" |
#include "base/process/process_metrics.h" |
#include "base/strings/stringprintf.h" |
-#include "base/trace_event/heap_profiler_heap_dump_writer.h" |
-#include "base/trace_event/heap_profiler_serialization_state.h" |
+#include "base/trace_event/heap_profiler_allocation_register.h" |
+#include "base/trace_event/heap_profiler_event_writer.h" |
#include "base/trace_event/memory_infra_background_whitelist.h" |
#include "base/trace_event/process_memory_totals.h" |
#include "base/trace_event/trace_event_argument.h" |
@@ -247,12 +247,9 @@ MemoryAllocatorDump* ProcessMemoryDump::GetSharedGlobalAllocatorDump( |
} |
void ProcessMemoryDump::DumpHeapUsage( |
- const std::unordered_map<base::trace_event::AllocationContext, |
- base::trace_event::AllocationMetrics>& |
- metrics_by_context, |
- base::trace_event::TraceEventMemoryOverhead& overhead, |
+ const AllocationRegister& allocation_register, |
const char* allocator_name) { |
- if (!metrics_by_context.empty()) { |
+ if (allocation_register.begin() != allocation_register.end()) { |
// We shouldn't end up here unless we're doing a detailed dump with |
// heap profiling enabled and if that is the case tracing should be |
// enabled which sets up the heap profiler serialization state. |
@@ -261,11 +258,13 @@ void ProcessMemoryDump::DumpHeapUsage( |
return; |
} |
DCHECK_EQ(0ul, heap_dumps_.count(allocator_name)); |
- std::unique_ptr<TracedValue> heap_dump = ExportHeapDump( |
- metrics_by_context, *heap_profiler_serialization_state()); |
+ std::unique_ptr<TracedValue> heap_dump = SerializeHeapDump( |
+ allocation_register, *heap_profiler_serialization_state()); |
heap_dumps_[allocator_name] = std::move(heap_dump); |
} |
+ TraceEventMemoryOverhead overhead; |
+ allocation_register.EstimateTraceMemoryOverhead(&overhead); |
std::string base_name = base::StringPrintf("tracing/heap_profiler_%s", |
allocator_name); |
overhead.DumpInto(base_name.c_str(), this); |
@@ -330,10 +329,9 @@ void ProcessMemoryDump::AsValueInto(TracedValue* value) const { |
} |
if (heap_dumps_.size() > 0) { |
- value->BeginDictionary("heaps"); |
- for (const auto& name_and_dump : heap_dumps_) |
- value->SetValueWithCopiedName(name_and_dump.first, *name_and_dump.second); |
- value->EndDictionary(); // "heaps" |
+ auto profile_data = SerializeHeapProfileEventData( |
+ heap_dumps_, *heap_profiler_serialization_state_); |
+ value->SetValue("heaps_v2", *profile_data); |
} |
value->BeginArray("allocators_graph"); |