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

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

Issue 1839503002: [tracing] Add native allocation tracing mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments 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/pending_task.h" 10 #include "base/pending_task.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ->GetContextSnapshot(); 54 ->GetContextSnapshot();
55 55
56 ASSERT_EQ(0u, ctx.backtrace.frame_count); 56 ASSERT_EQ(0u, ctx.backtrace.frame_count);
57 } 57 }
58 58
59 class AllocationContextTrackerTest : public testing::Test { 59 class AllocationContextTrackerTest : public testing::Test {
60 public: 60 public:
61 void SetUp() override { 61 void SetUp() override {
62 TraceConfig config(""); 62 TraceConfig config("");
63 TraceLog::GetInstance()->SetEnabled(config, TraceLog::RECORDING_MODE); 63 TraceLog::GetInstance()->SetEnabled(config, TraceLog::RECORDING_MODE);
64 AllocationContextTracker::SetCaptureEnabled(true); 64 AllocationContextTracker::SetCaptureMode(
65 AllocationContextTracker::CaptureMode::PSEUDO_STACK);
65 } 66 }
66 67
67 void TearDown() override { 68 void TearDown() override {
68 AllocationContextTracker::SetCaptureEnabled(false); 69 AllocationContextTracker::SetCaptureMode(
70 AllocationContextTracker::CaptureMode::DISABLED);
69 TraceLog::GetInstance()->SetDisabled(); 71 TraceLog::GetInstance()->SetDisabled();
70 } 72 }
71 }; 73 };
72 74
73 // Check that |TRACE_EVENT| macros push and pop to the pseudo stack correctly. 75 // Check that |TRACE_EVENT| macros push and pop to the pseudo stack correctly.
74 TEST_F(AllocationContextTrackerTest, PseudoStackScopedTrace) { 76 TEST_F(AllocationContextTrackerTest, PseudoStackScopedTrace) {
75 StackFrame c = StackFrame::FromTraceEventName(kCupcake); 77 StackFrame c = StackFrame::FromTraceEventName(kCupcake);
76 StackFrame d = StackFrame::FromTraceEventName(kDonut); 78 StackFrame d = StackFrame::FromTraceEventName(kDonut);
77 StackFrame e = StackFrame::FromTraceEventName(kEclair); 79 StackFrame e = StackFrame::FromTraceEventName(kEclair);
78 StackFrame f = StackFrame::FromTraceEventName(kFroyo); 80 StackFrame f = StackFrame::FromTraceEventName(kFroyo);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 275
274 // Type should be nullptr without task event. 276 // Type should be nullptr without task event.
275 AllocationContext ctx = 277 AllocationContext ctx =
276 AllocationContextTracker::GetInstanceForCurrentThread() 278 AllocationContextTracker::GetInstanceForCurrentThread()
277 ->GetContextSnapshot(); 279 ->GetContextSnapshot();
278 ASSERT_FALSE(ctx.type_name); 280 ASSERT_FALSE(ctx.type_name);
279 } 281 }
280 282
281 } // namespace trace_event 283 } // namespace trace_event
282 } // namespace base 284 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698