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

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

Issue 1814083002: [tracing] Add thread name to the pseudo stack of heap profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@profiler
Patch Set: Add comment. Created 4 years, 8 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/trace_event/heap_profiler_allocation_context.h" 10 #include "base/trace_event/heap_profiler_allocation_context.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 { 223 {
224 AllocationContext ctx = 224 AllocationContext ctx =
225 AllocationContextTracker::GetInstanceForCurrentThread() 225 AllocationContextTracker::GetInstanceForCurrentThread()
226 ->GetContextSnapshot(); 226 ->GetContextSnapshot();
227 ASSERT_EQ(kCupcake, ctx.backtrace.frames[0]); 227 ASSERT_EQ(kCupcake, ctx.backtrace.frames[0]);
228 ASSERT_EQ(kFroyo, ctx.backtrace.frames[11]); 228 ASSERT_EQ(kFroyo, ctx.backtrace.frames[11]);
229 } 229 }
230 } 230 }
231 231
232 TEST_F(AllocationContextTrackerTest, SetCurrentThreadName) {
233 TRACE_EVENT0("Testing", kCupcake);
234
235 // Test if the thread name is inserted into backtrace.
236 const char kThread1[] = "thread1";
237 AllocationContextTracker::SetCurrentThreadName(kThread1);
238 AllocationContext ctx1 =
239 AllocationContextTracker::GetInstanceForCurrentThread()
240 ->GetContextSnapshot();
241 ASSERT_EQ(kThread1, ctx1.backtrace.frames[0]);
242 ASSERT_EQ(kCupcake, ctx1.backtrace.frames[1]);
243
244 // Test if the thread name is reset.
245 const char kThread2[] = "thread2";
246 AllocationContextTracker::SetCurrentThreadName(kThread2);
247 AllocationContext ctx2 =
248 AllocationContextTracker::GetInstanceForCurrentThread()
249 ->GetContextSnapshot();
250 ASSERT_EQ(kThread2, ctx2.backtrace.frames[0]);
251 ASSERT_EQ(kCupcake, ctx2.backtrace.frames[1]);
252 }
253
232 } // namespace trace_event 254 } // namespace trace_event
233 } // namespace base 255 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/heap_profiler_allocation_context_tracker.cc ('k') | content/browser/browser_main_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698