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

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

Issue 1028333002: Chromium -> Mojo roll. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « base/trace_event/process_memory_dump.h ('k') | base/trace_event/process_memory_maps.h » ('j') | 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 "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 {
11 namespace trace_event { 11 namespace trace_event {
12 12
13 ProcessMemoryDump::ProcessMemoryDump() 13 ProcessMemoryDump::ProcessMemoryDump()
14 : has_process_totals_(false), has_process_mmaps_(false) { 14 : has_process_totals_(false), has_process_mmaps_(false) {
15 } 15 }
16 16
17 ProcessMemoryDump::~ProcessMemoryDump() { 17 ProcessMemoryDump::~ProcessMemoryDump() {
18 } 18 }
19 19
20 MemoryAllocatorDump* ProcessMemoryDump::CreateAllocatorDump(
21 const std::string& name) {
22 return CreateAllocatorDump(name, nullptr);
23 }
24
25 MemoryAllocatorDump* ProcessMemoryDump::CreateAllocatorDump(
26 const std::string& name,
27 MemoryAllocatorDump* parent) {
28 DCHECK_EQ(0ul, allocator_dumps_.count(name));
29 MemoryAllocatorDump* mad = new MemoryAllocatorDump(name, parent);
30 allocator_dumps_storage_.push_back(mad);
31 allocator_dumps_[name] = mad;
32 return mad;
33 }
34
35 MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump(
36 const std::string& name) const {
37 auto it = allocator_dumps_.find(name);
38 return it == allocator_dumps_.end() ? nullptr : it->second;
39 }
40
20 void ProcessMemoryDump::AsValueInto(TracedValue* value) const { 41 void ProcessMemoryDump::AsValueInto(TracedValue* value) const {
21 // Build up the [dumper name] -> [value] dictionary. 42 // Build up the [dumper name] -> [value] dictionary.
22 if (has_process_totals_) { 43 if (has_process_totals_) {
23 value->BeginDictionary("process_totals"); 44 value->BeginDictionary("process_totals");
24 process_totals_.AsValueInto(value); 45 process_totals_.AsValueInto(value);
25 value->EndDictionary(); 46 value->EndDictionary();
26 } 47 }
27 if (has_process_mmaps_) { 48 if (has_process_mmaps_) {
28 value->BeginDictionary("process_mmaps"); 49 value->BeginDictionary("process_mmaps");
29 process_mmaps_.AsValueInto(value); 50 process_mmaps_.AsValueInto(value);
30 value->EndDictionary(); 51 value->EndDictionary();
31 } 52 }
53 if (allocator_dumps_storage_.size() > 0) {
54 value->BeginDictionary("allocators");
55 for (const MemoryAllocatorDump* allocator_dump : allocator_dumps_storage_)
56 allocator_dump->AsValueInto(value);
57 value->EndDictionary();
58 }
32 } 59 }
33 60
34 } // namespace trace_event 61 } // namespace trace_event
35 } // namespace base 62 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/process_memory_dump.h ('k') | base/trace_event/process_memory_maps.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698