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

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

Issue 1151603004: [tracing] Add support to pre-load and merge ProcessMemoryDump(s). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test 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 {
(...skipping 17 matching lines...) Expand all
28 allocator_dumps_[absolute_name] = mad; 28 allocator_dumps_[absolute_name] = mad;
29 return mad; 29 return mad;
30 } 30 }
31 31
32 MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump( 32 MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump(
33 const std::string& absolute_name) const { 33 const std::string& absolute_name) const {
34 auto it = allocator_dumps_.find(absolute_name); 34 auto it = allocator_dumps_.find(absolute_name);
35 return it == allocator_dumps_.end() ? nullptr : it->second; 35 return it == allocator_dumps_.end() ? nullptr : it->second;
36 } 36 }
37 37
38 void ProcessMemoryDump::TakeAllDumpsFrom(ProcessMemoryDump* other) {
39 // We support only merging of MemoryAllocatorDumps. The special process_totals
40 // and mmaps case are not relevant, let's just prevent clients to accidentally
petrcermak 2015/05/21 08:17:37 s/case/cases/, s/to/from/
Primiano Tucci (use gerrit) 2015/05/21 08:33:46 Done.
41 // try doing that.
petrcermak 2015/05/21 08:17:38 "try" doesn't belong here (it would have to be "tr
Primiano Tucci (use gerrit) 2015/05/21 08:33:46 Reworded as "trying from doing it" (and I saved on
42 DCHECK(!other->has_process_totals() && !other->has_process_mmaps());
43
44 // Moves the ownership of all the MemoryAllocatorDump(s) contained in |other|
petrcermak 2015/05/21 08:17:37 nit: I don't think you need "the" in front of "Mem
Primiano Tucci (use gerrit) 2015/05/21 08:33:46 Done.
45 // into this ProcessMemoryDump.
46 for (MemoryAllocatorDump* mad : other->allocator_dumps_storage_) {
47 // Check that we don't merge duplicates.
48 DCHECK_EQ(0ul, allocator_dumps_.count(mad->absolute_name()));
49 allocator_dumps_storage_.push_back(mad);
50 allocator_dumps_[mad->absolute_name()] = mad;
51 }
52 other->allocator_dumps_storage_.weak_clear();
53 other->allocator_dumps_.clear();
54 }
55
38 void ProcessMemoryDump::AsValueInto(TracedValue* value) const { 56 void ProcessMemoryDump::AsValueInto(TracedValue* value) const {
39 // Build up the [dumper name] -> [value] dictionary. 57 // Build up the [dumper name] -> [value] dictionary.
40 if (has_process_totals_) { 58 if (has_process_totals_) {
41 value->BeginDictionary("process_totals"); 59 value->BeginDictionary("process_totals");
42 process_totals_.AsValueInto(value); 60 process_totals_.AsValueInto(value);
43 value->EndDictionary(); 61 value->EndDictionary();
44 } 62 }
45 if (has_process_mmaps_) { 63 if (has_process_mmaps_) {
46 value->BeginDictionary("process_mmaps"); 64 value->BeginDictionary("process_mmaps");
47 process_mmaps_.AsValueInto(value); 65 process_mmaps_.AsValueInto(value);
48 value->EndDictionary(); 66 value->EndDictionary();
49 } 67 }
50 if (allocator_dumps_storage_.size() > 0) { 68 if (allocator_dumps_storage_.size() > 0) {
51 value->BeginDictionary("allocators"); 69 value->BeginDictionary("allocators");
52 for (const MemoryAllocatorDump* allocator_dump : allocator_dumps_storage_) 70 for (const MemoryAllocatorDump* allocator_dump : allocator_dumps_storage_)
53 allocator_dump->AsValueInto(value); 71 allocator_dump->AsValueInto(value);
54 value->EndDictionary(); 72 value->EndDictionary();
55 } 73 }
56 } 74 }
57 75
58 } // namespace trace_event 76 } // namespace trace_event
59 } // namespace base 77 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698