| OLD | NEW |
| 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" |
| 11 #include "base/trace_event/heap_profiler.h" |
| 11 #include "base/trace_event/heap_profiler_allocation_context.h" | 12 #include "base/trace_event/heap_profiler_allocation_context.h" |
| 12 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" | 13 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
| 13 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 namespace trace_event { | 18 namespace trace_event { |
| 18 | 19 |
| 19 // Define all strings once, because the pseudo stack requires pointer equality, | 20 // Define all strings once, because the pseudo stack requires pointer equality, |
| 20 // and string interning is unreliable. | 21 // and string interning is unreliable. |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 ASSERT_EQ(kContext2, ctx2.type_name); | 272 ASSERT_EQ(kContext2, ctx2.type_name); |
| 272 } | 273 } |
| 273 | 274 |
| 274 // Type should be nullptr without task event. | 275 // Type should be nullptr without task event. |
| 275 AllocationContext ctx = | 276 AllocationContext ctx = |
| 276 AllocationContextTracker::GetInstanceForCurrentThread() | 277 AllocationContextTracker::GetInstanceForCurrentThread() |
| 277 ->GetContextSnapshot(); | 278 ->GetContextSnapshot(); |
| 278 ASSERT_FALSE(ctx.type_name); | 279 ASSERT_FALSE(ctx.type_name); |
| 279 } | 280 } |
| 280 | 281 |
| 282 TEST_F(AllocationContextTrackerTest, IgnoreAllocationTest) { |
| 283 TRACE_EVENT0("Testing", kCupcake); |
| 284 TRACE_EVENT0("Testing", kDonut); |
| 285 HEAP_PROFILER_SCOPED_IGNORE; |
| 286 AllocationContext ctx = |
| 287 AllocationContextTracker::GetInstanceForCurrentThread() |
| 288 ->GetContextSnapshot(); |
| 289 const StringPiece kTracingOverhead("tracing_overhead"); |
| 290 ASSERT_EQ(kTracingOverhead, |
| 291 static_cast<const char*>(ctx.backtrace.frames[0].value)); |
| 292 ASSERT_EQ(1u, ctx.backtrace.frame_count); |
| 293 } |
| 294 |
| 281 } // namespace trace_event | 295 } // namespace trace_event |
| 282 } // namespace base | 296 } // namespace base |
| OLD | NEW |