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

Side by Side Diff: base/debug/thread_heap_usage_tracker.cc

Issue 2386123003: Add heap allocator usage to task profiler. (Closed)
Patch Set: Fix remaining clang compile errors. Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/debug/thread_heap_usage_tracker.h" 5 #include "base/debug/thread_heap_usage_tracker.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <type_traits> 9 #include <type_traits>
10 10
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return allocator_usage; 152 return allocator_usage;
153 } 153 }
154 154
155 } // namespace 155 } // namespace
156 156
157 ThreadHeapUsageTracker::ThreadHeapUsageTracker() : thread_usage_(nullptr) { 157 ThreadHeapUsageTracker::ThreadHeapUsageTracker() : thread_usage_(nullptr) {
158 static_assert(std::is_pod<ThreadHeapUsage>::value, "Must be POD."); 158 static_assert(std::is_pod<ThreadHeapUsage>::value, "Must be POD.");
159 } 159 }
160 160
161 ThreadHeapUsageTracker::~ThreadHeapUsageTracker() { 161 ThreadHeapUsageTracker::~ThreadHeapUsageTracker() {
162 DCHECK(thread_checker_.CalledOnValidThread()); 162 // TODO(fdoray): This DCHECK causes inexplicable fallout in Chrome. This
163 // was isolated to a line in CalledOnValidThread reading.
164 // if (task_token_ == TaskToken::GetForCurrentThread())
165 // DCHECK(thread_checker_.CalledOnValidThread());
163 166
164 if (thread_usage_ != nullptr) { 167 if (thread_usage_ != nullptr) {
165 // If this tracker wasn't stopped, make it inclusive so that the 168 // If this tracker wasn't stopped, make it inclusive so that the
166 // usage isn't lost. 169 // usage isn't lost.
167 Stop(false); 170 Stop(false);
168 } 171 }
169 } 172 }
170 173
171 void ThreadHeapUsageTracker::Start() { 174 void ThreadHeapUsageTracker::Start() {
172 DCHECK(thread_checker_.CalledOnValidThread()); 175 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 void ThreadHeapUsageTracker::EnsureTLSInitialized() { 257 void ThreadHeapUsageTracker::EnsureTLSInitialized() {
255 if (!g_thread_allocator_usage.initialized()) { 258 if (!g_thread_allocator_usage.initialized()) {
256 g_thread_allocator_usage.Initialize([](void* allocator_usage) { 259 g_thread_allocator_usage.Initialize([](void* allocator_usage) {
257 delete static_cast<ThreadHeapUsage*>(allocator_usage); 260 delete static_cast<ThreadHeapUsage*>(allocator_usage);
258 }); 261 });
259 } 262 }
260 } 263 }
261 264
262 } // namespace debug 265 } // namespace debug
263 } // namespace base 266 } // namespace base
OLDNEW
« no previous file with comments | « base/BUILD.gn ('k') | base/tracked_objects.h » ('j') | base/tracked_objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698