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

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

Issue 1583483002: [tracing] Add method to create "weak" global dumps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit. Created 4 years, 11 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 #include <vector> 8 #include <vector>
9 9
10 #include "base/process/process_metrics.h" 10 #include "base/process/process_metrics.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 MemoryAllocatorDump* ProcessMemoryDump::GetOrCreateAllocatorDump( 128 MemoryAllocatorDump* ProcessMemoryDump::GetOrCreateAllocatorDump(
129 const std::string& absolute_name) { 129 const std::string& absolute_name) {
130 MemoryAllocatorDump* mad = GetAllocatorDump(absolute_name); 130 MemoryAllocatorDump* mad = GetAllocatorDump(absolute_name);
131 return mad ? mad : CreateAllocatorDump(absolute_name); 131 return mad ? mad : CreateAllocatorDump(absolute_name);
132 } 132 }
133 133
134 MemoryAllocatorDump* ProcessMemoryDump::CreateSharedGlobalAllocatorDump( 134 MemoryAllocatorDump* ProcessMemoryDump::CreateSharedGlobalAllocatorDump(
135 const MemoryAllocatorDumpGuid& guid) { 135 const MemoryAllocatorDumpGuid& guid) {
136 // A shared allocator dump can be shared within a process and the guid could 136 // A shared allocator dump can be shared within a process and the guid could
137 // have been created already. 137 // have been created already.
138 MemoryAllocatorDump* allocator_dump = GetSharedGlobalAllocatorDump(guid); 138 MemoryAllocatorDump* mad = GetSharedGlobalAllocatorDump(guid);
139 return allocator_dump ? allocator_dump 139 // The weak flag is unset because this method should create non-weak dump.
petrcermak 2016/01/18 11:23:46 nit: s/non-weak/a non-weak/
ssid 2016/01/18 16:28:36 Done.
140 : CreateAllocatorDump( 140 if (mad)
petrcermak 2016/01/18 11:23:46 I think that the following would be more readable:
ssid 2016/01/18 16:28:36 Done.
141 GetSharedGlobalAllocatorDumpName(guid), guid); 141 mad->unset_flags(MemoryAllocatorDump::Flag::WEAK);
142 else
143 mad = CreateAllocatorDump(GetSharedGlobalAllocatorDumpName(guid), guid);
144 return mad;
145 }
146
147 MemoryAllocatorDump* ProcessMemoryDump::CreateWeakSharedGlobalAllocatorDump(
148 const MemoryAllocatorDumpGuid& guid) {
149 MemoryAllocatorDump* mad = GetSharedGlobalAllocatorDump(guid);
150 if (!mad) {
151 mad = new MemoryAllocatorDump(GetSharedGlobalAllocatorDumpName(guid), this,
petrcermak 2016/01/18 11:23:46 At this point, I wonder whether it wouldn't make m
ssid 2016/01/18 16:28:36 Hm not sure if one line method is really needed. U
petrcermak 2016/01/18 17:18:12 Acknowledged.
152 guid, MemoryAllocatorDump::Flag::WEAK);
153 AddAllocatorDumpInternal(mad); // Takes ownership of |mad|.
154 }
155 return mad;
142 } 156 }
143 157
144 MemoryAllocatorDump* ProcessMemoryDump::GetSharedGlobalAllocatorDump( 158 MemoryAllocatorDump* ProcessMemoryDump::GetSharedGlobalAllocatorDump(
145 const MemoryAllocatorDumpGuid& guid) const { 159 const MemoryAllocatorDumpGuid& guid) const {
146 return GetAllocatorDump(GetSharedGlobalAllocatorDumpName(guid)); 160 return GetAllocatorDump(GetSharedGlobalAllocatorDumpName(guid));
147 } 161 }
148 162
149 void ProcessMemoryDump::AddHeapDump(const std::string& absolute_name, 163 void ProcessMemoryDump::AddHeapDump(const std::string& absolute_name,
150 scoped_refptr<TracedValue> heap_dump) { 164 scoped_refptr<TracedValue> heap_dump) {
151 DCHECK_EQ(0ul, heap_dumps_.count(absolute_name)); 165 DCHECK_EQ(0ul, heap_dumps_.count(absolute_name));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 261
248 void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source, 262 void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source,
249 const std::string& target_node_name) { 263 const std::string& target_node_name) {
250 std::string child_mad_name = target_node_name + "/__" + source.ToString(); 264 std::string child_mad_name = target_node_name + "/__" + source.ToString();
251 MemoryAllocatorDump* target_child_mad = CreateAllocatorDump(child_mad_name); 265 MemoryAllocatorDump* target_child_mad = CreateAllocatorDump(child_mad_name);
252 AddOwnershipEdge(source, target_child_mad->guid()); 266 AddOwnershipEdge(source, target_child_mad->guid());
253 } 267 }
254 268
255 } // namespace trace_event 269 } // namespace trace_event
256 } // namespace base 270 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698