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

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

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest Created 5 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 "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 const scoped_refptr<MemoryDumpSessionState>& session_state)
15 : has_process_totals_(false),
16 has_process_mmaps_(false),
17 session_state_(session_state) {
15 } 18 }
16 19
17 ProcessMemoryDump::~ProcessMemoryDump() { 20 ProcessMemoryDump::~ProcessMemoryDump() {
18 } 21 }
19 22
20 MemoryAllocatorDump* ProcessMemoryDump::CreateAllocatorDump( 23 MemoryAllocatorDump* ProcessMemoryDump::CreateAllocatorDump(
21 const std::string& name) { 24 const std::string& allocator_name,
22 return CreateAllocatorDump(name, nullptr); 25 const std::string& heap_name) {
23 } 26 MemoryAllocatorDump* mad =
24 27 new MemoryAllocatorDump(allocator_name, heap_name, this);
25 MemoryAllocatorDump* ProcessMemoryDump::CreateAllocatorDump( 28 DCHECK_EQ(0ul, allocator_dumps_.count(mad->GetAbsoluteName()));
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); 29 allocator_dumps_storage_.push_back(mad);
31 allocator_dumps_[name] = mad; 30 allocator_dumps_[mad->GetAbsoluteName()] = mad;
32 return mad; 31 return mad;
33 } 32 }
34 33
35 MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump( 34 MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump(
36 const std::string& name) const { 35 const std::string& allocator_name,
37 auto it = allocator_dumps_.find(name); 36 const std::string& heap_name) const {
37 auto it = allocator_dumps_.find(
38 MemoryAllocatorDump::GetAbsoluteName(allocator_name, heap_name));
38 return it == allocator_dumps_.end() ? nullptr : it->second; 39 return it == allocator_dumps_.end() ? nullptr : it->second;
39 } 40 }
40 41
41 void ProcessMemoryDump::AsValueInto(TracedValue* value) const { 42 void ProcessMemoryDump::AsValueInto(TracedValue* value) const {
42 // Build up the [dumper name] -> [value] dictionary. 43 // Build up the [dumper name] -> [value] dictionary.
43 if (has_process_totals_) { 44 if (has_process_totals_) {
44 value->BeginDictionary("process_totals"); 45 value->BeginDictionary("process_totals");
45 process_totals_.AsValueInto(value); 46 process_totals_.AsValueInto(value);
46 value->EndDictionary(); 47 value->EndDictionary();
47 } 48 }
48 if (has_process_mmaps_) { 49 if (has_process_mmaps_) {
49 value->BeginDictionary("process_mmaps"); 50 value->BeginDictionary("process_mmaps");
50 process_mmaps_.AsValueInto(value); 51 process_mmaps_.AsValueInto(value);
51 value->EndDictionary(); 52 value->EndDictionary();
52 } 53 }
53 if (allocator_dumps_storage_.size() > 0) { 54 if (allocator_dumps_storage_.size() > 0) {
54 value->BeginDictionary("allocators"); 55 value->BeginDictionary("allocators");
55 for (const MemoryAllocatorDump* allocator_dump : allocator_dumps_storage_) 56 for (const MemoryAllocatorDump* allocator_dump : allocator_dumps_storage_)
56 allocator_dump->AsValueInto(value); 57 allocator_dump->AsValueInto(value);
57 value->EndDictionary(); 58 value->EndDictionary();
58 } 59 }
59 } 60 }
60 61
61 } // namespace trace_event 62 } // namespace trace_event
62 } // namespace base 63 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698