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

Side by Side Diff: base/trace_event/process_memory_dump.cc

Issue 1910253003: PartitionAllocMemoryDumpProvider can directly inherit from MemoryDumpProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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
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 "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 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/process/process_metrics.h" 12 #include "base/process/process_metrics.h"
13 #include "base/strings/stringprintf.h"
14 #include "base/trace_event/heap_profiler_heap_dump_writer.h"
13 #include "base/trace_event/process_memory_totals.h" 15 #include "base/trace_event/process_memory_totals.h"
14 #include "base/trace_event/trace_event_argument.h" 16 #include "base/trace_event/trace_event_argument.h"
15 #include "build/build_config.h" 17 #include "build/build_config.h"
16 18
17 #if defined(OS_IOS) 19 #if defined(OS_IOS)
18 #include <sys/sysctl.h> 20 #include <sys/sysctl.h>
19 #endif 21 #endif
20 22
21 #if defined(OS_POSIX) 23 #if defined(OS_POSIX)
22 #include <sys/mman.h> 24 #include <sys/mman.h>
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 const MemoryAllocatorDumpGuid& guid) const { 218 const MemoryAllocatorDumpGuid& guid) const {
217 return GetAllocatorDump(GetSharedGlobalAllocatorDumpName(guid)); 219 return GetAllocatorDump(GetSharedGlobalAllocatorDumpName(guid));
218 } 220 }
219 221
220 void ProcessMemoryDump::AddHeapDump(const std::string& absolute_name, 222 void ProcessMemoryDump::AddHeapDump(const std::string& absolute_name,
221 std::unique_ptr<TracedValue> heap_dump) { 223 std::unique_ptr<TracedValue> heap_dump) {
222 DCHECK_EQ(0ul, heap_dumps_.count(absolute_name)); 224 DCHECK_EQ(0ul, heap_dumps_.count(absolute_name));
223 heap_dumps_[absolute_name] = std::move(heap_dump); 225 heap_dumps_[absolute_name] = std::move(heap_dump);
224 } 226 }
225 227
228 void ProcessMemoryDump::DumpHeapUsage(
229 const base::hash_map<base::trace_event::AllocationContext,
230 base::trace_event::AllocationMetrics>& metrics_by_context,
231 base::trace_event::TraceEventMemoryOverhead& overhead,
232 const char* allocator_name) {
233 if (!metrics_by_context.empty()) {
234 std::unique_ptr<TracedValue> heap_dump = ExportHeapDump(
235 metrics_by_context, *session_state());
236 AddHeapDump(allocator_name, std::move(heap_dump));
237 }
238
239 std::string base_name = base::StringPrintf("tracing/heap_profiler_%s",
240 allocator_name);
241 overhead.DumpInto(base_name.c_str(), this);
242 }
243
226 void ProcessMemoryDump::Clear() { 244 void ProcessMemoryDump::Clear() {
227 if (has_process_totals_) { 245 if (has_process_totals_) {
228 process_totals_.Clear(); 246 process_totals_.Clear();
229 has_process_totals_ = false; 247 has_process_totals_ = false;
230 } 248 }
231 249
232 if (has_process_mmaps_) { 250 if (has_process_mmaps_) {
233 process_mmaps_.Clear(); 251 process_mmaps_.Clear();
234 has_process_mmaps_ = false; 252 has_process_mmaps_ = false;
235 } 253 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 333
316 void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source, 334 void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source,
317 const std::string& target_node_name) { 335 const std::string& target_node_name) {
318 std::string child_mad_name = target_node_name + "/__" + source.ToString(); 336 std::string child_mad_name = target_node_name + "/__" + source.ToString();
319 MemoryAllocatorDump* target_child_mad = CreateAllocatorDump(child_mad_name); 337 MemoryAllocatorDump* target_child_mad = CreateAllocatorDump(child_mad_name);
320 AddOwnershipEdge(source, target_child_mad->guid()); 338 AddOwnershipEdge(source, target_child_mad->guid());
321 } 339 }
322 340
323 } // namespace trace_event 341 } // namespace trace_event
324 } // namespace base 342 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/process_memory_dump.h ('k') | third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698