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

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

Issue 2101263003: base: Change auto to not deduce raw pointers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/malloc_dump_provider.h" 5 #include "base/trace_event/malloc_dump_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/allocator/allocator_extension.h" 9 #include "base/allocator/allocator_extension.h"
10 #include "base/allocator/allocator_shim.h" 10 #include "base/allocator/allocator_shim.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // CurrentId() can be a slow operation (crbug.com/497226). This apparently 222 // CurrentId() can be a slow operation (crbug.com/497226). This apparently
223 // redundant condition short circuits the CurrentID() calls when unnecessary. 223 // redundant condition short circuits the CurrentID() calls when unnecessary.
224 if (tid_dumping_heap_ != kInvalidThreadId && 224 if (tid_dumping_heap_ != kInvalidThreadId &&
225 tid_dumping_heap_ == PlatformThread::CurrentId()) 225 tid_dumping_heap_ == PlatformThread::CurrentId())
226 return; 226 return;
227 227
228 // AllocationContextTracker will return nullptr when called re-reentrantly. 228 // AllocationContextTracker will return nullptr when called re-reentrantly.
229 // This is the case of GetInstanceForCurrentThread() being called for the 229 // This is the case of GetInstanceForCurrentThread() being called for the
230 // first time, which causes a new() inside the tracker which re-enters the 230 // first time, which causes a new() inside the tracker which re-enters the
231 // heap profiler, in which case we just want to early out. 231 // heap profiler, in which case we just want to early out.
232 auto tracker = AllocationContextTracker::GetInstanceForCurrentThread(); 232 auto* tracker = AllocationContextTracker::GetInstanceForCurrentThread();
233 if (!tracker) 233 if (!tracker)
234 return; 234 return;
235 AllocationContext context = tracker->GetContextSnapshot(); 235 AllocationContext context = tracker->GetContextSnapshot();
236 236
237 AutoLock lock(allocation_register_lock_); 237 AutoLock lock(allocation_register_lock_);
238 if (!allocation_register_) 238 if (!allocation_register_)
239 return; 239 return;
240 240
241 allocation_register_->Insert(address, size, context); 241 allocation_register_->Insert(address, size, context);
242 } 242 }
243 243
244 void MallocDumpProvider::RemoveAllocation(void* address) { 244 void MallocDumpProvider::RemoveAllocation(void* address) {
245 // No re-entrancy is expected here as none of the calls below should 245 // No re-entrancy is expected here as none of the calls below should
246 // cause a free()-s (|allocation_register_| does its own heap management). 246 // cause a free()-s (|allocation_register_| does its own heap management).
247 if (tid_dumping_heap_ != kInvalidThreadId && 247 if (tid_dumping_heap_ != kInvalidThreadId &&
248 tid_dumping_heap_ == PlatformThread::CurrentId()) 248 tid_dumping_heap_ == PlatformThread::CurrentId())
249 return; 249 return;
250 AutoLock lock(allocation_register_lock_); 250 AutoLock lock(allocation_register_lock_);
251 if (!allocation_register_) 251 if (!allocation_register_)
252 return; 252 return;
253 allocation_register_->Remove(address); 253 allocation_register_->Remove(address);
254 } 254 }
255 255
256 } // namespace trace_event 256 } // namespace trace_event
257 } // namespace base 257 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc ('k') | base/trace_event/memory_dump_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698