Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: content/child/web_memory_dump_provider_adapter.cc

Issue 1494293005: [Tracing] Enable heap dumps with both type info and backtraces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sfdedup-iter
Patch Set: Rename _all_ occurrences Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/trace_event/heap_profiler_heap_dump_writer_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/child/web_memory_dump_provider_adapter.h" 5 #include "content/child/web_memory_dump_provider_adapter.h"
6 6
7 #include "base/containers/hash_tables.h"
7 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
8 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
9 #include "base/trace_event/heap_profiler_allocation_context.h" 10 #include "base/trace_event/heap_profiler_allocation_context.h"
10 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" 11 #include "base/trace_event/heap_profiler_allocation_context_tracker.h"
11 #include "base/trace_event/heap_profiler_allocation_register.h" 12 #include "base/trace_event/heap_profiler_allocation_register.h"
12 #include "base/trace_event/heap_profiler_heap_dump_writer.h" 13 #include "base/trace_event/heap_profiler_heap_dump_writer.h"
13 #include "base/trace_event/process_memory_dump.h" 14 #include "base/trace_event/process_memory_dump.h"
14 #include "base/trace_event/trace_event_argument.h" 15 #include "base/trace_event/trace_event_argument.h"
15 #include "base/trace_event/trace_event_memory_overhead.h" 16 #include "base/trace_event/trace_event_memory_overhead.h"
16 #include "content/child/web_process_memory_dump_impl.h" 17 #include "content/child/web_process_memory_dump_impl.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 break; 71 break;
71 default: 72 default:
72 NOTREACHED(); 73 NOTREACHED();
73 return false; 74 return false;
74 } 75 }
75 WebProcessMemoryDumpImpl web_pmd_impl(args.level_of_detail, pmd); 76 WebProcessMemoryDumpImpl web_pmd_impl(args.level_of_detail, pmd);
76 77
77 if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED && 78 if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED &&
78 web_memory_dump_provider_->supportsHeapProfiling() && 79 web_memory_dump_provider_->supportsHeapProfiling() &&
79 g_heap_profiling_enabled) { 80 g_heap_profiling_enabled) {
80 HeapDumpWriter writer(pmd->session_state()->stack_frame_deduplicator(),
81 pmd->session_state()->type_name_deduplicator());
82 TraceEventMemoryOverhead overhead; 81 TraceEventMemoryOverhead overhead;
83 82 hash_map<AllocationContext, size_t> bytes_by_context;
84 { 83 {
85 AutoLock lock(g_allocation_register_lock.Get()); 84 AutoLock lock(g_allocation_register_lock.Get());
86 for (const auto& alloc_size : *g_allocation_register) 85 for (const auto& alloc_size : *g_allocation_register)
87 writer.InsertAllocation(alloc_size.context, alloc_size.size); 86 bytes_by_context[alloc_size.context] += alloc_size.size;
88 87
89 g_allocation_register->EstimateTraceMemoryOverhead(&overhead); 88 g_allocation_register->EstimateTraceMemoryOverhead(&overhead);
90 } 89 }
91 90
92 pmd->AddHeapDump("partition_alloc", writer.WriteHeapDump()); 91 scoped_refptr<TracedValue> heap_dump = ExportHeapDump(
92 bytes_by_context, pmd->session_state()->stack_frame_deduplicator(),
93 pmd->session_state()->type_name_deduplicator());
94 pmd->AddHeapDump("partition_alloc", heap_dump);
93 overhead.DumpInto("tracing/heap_profiler", pmd); 95 overhead.DumpInto("tracing/heap_profiler", pmd);
94 } 96 }
95 97
96 return web_memory_dump_provider_->onMemoryDump(level, &web_pmd_impl); 98 return web_memory_dump_provider_->onMemoryDump(level, &web_pmd_impl);
97 } 99 }
98 100
99 void WebMemoryDumpProviderAdapter::OnHeapProfilingEnabled(bool enabled) { 101 void WebMemoryDumpProviderAdapter::OnHeapProfilingEnabled(bool enabled) {
100 if (!web_memory_dump_provider_->supportsHeapProfiling()) 102 if (!web_memory_dump_provider_->supportsHeapProfiling())
101 return; 103 return;
102 104
(...skipping 15 matching lines...) Expand all
118 web_memory_dump_provider_->onHeapProfilingEnabled(ReportAllocation, 120 web_memory_dump_provider_->onHeapProfilingEnabled(ReportAllocation,
119 ReportFree); 121 ReportFree);
120 } else { 122 } else {
121 web_memory_dump_provider_->onHeapProfilingEnabled(nullptr, nullptr); 123 web_memory_dump_provider_->onHeapProfilingEnabled(nullptr, nullptr);
122 } 124 }
123 125
124 g_heap_profiling_enabled = enabled; 126 g_heap_profiling_enabled = enabled;
125 } 127 }
126 128
127 } // namespace content 129 } // namespace content
OLDNEW
« no previous file with comments | « base/trace_event/heap_profiler_heap_dump_writer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698