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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 const char kGingerbread[] = "Gingerbread"; | 27 const char kGingerbread[] = "Gingerbread"; |
28 | 28 |
29 // Asserts that the fixed-size array |expected_backtrace| matches the backtrace | 29 // Asserts that the fixed-size array |expected_backtrace| matches the backtrace |
30 // in |AllocationContextTracker::GetContextSnapshot|. | 30 // in |AllocationContextTracker::GetContextSnapshot|. |
31 template <size_t N> | 31 template <size_t N> |
32 void AssertBacktraceEquals(const StackFrame(&expected_backtrace)[N]) { | 32 void AssertBacktraceEquals(const StackFrame(&expected_backtrace)[N]) { |
33 AllocationContext ctx = | 33 AllocationContext ctx = |
34 AllocationContextTracker::GetInstanceForCurrentThread() | 34 AllocationContextTracker::GetInstanceForCurrentThread() |
35 ->GetContextSnapshot(); | 35 ->GetContextSnapshot(); |
36 | 36 |
37 auto actual = std::begin(ctx.backtrace.frames); | 37 auto* actual = std::begin(ctx.backtrace.frames); |
38 auto actual_bottom = actual + ctx.backtrace.frame_count; | 38 auto* actual_bottom = actual + ctx.backtrace.frame_count; |
39 auto expected = std::begin(expected_backtrace); | 39 auto expected = std::begin(expected_backtrace); |
40 auto expected_bottom = std::end(expected_backtrace); | 40 auto expected_bottom = std::end(expected_backtrace); |
41 | 41 |
42 // Note that this requires the pointers to be equal, this is not doing a deep | 42 // Note that this requires the pointers to be equal, this is not doing a deep |
43 // string comparison. | 43 // string comparison. |
44 for (; actual != actual_bottom && expected != expected_bottom; | 44 for (; actual != actual_bottom && expected != expected_bottom; |
45 actual++, expected++) | 45 actual++, expected++) |
46 ASSERT_EQ(*expected, *actual); | 46 ASSERT_EQ(*expected, *actual); |
47 | 47 |
48 // Ensure that the height of the stacks is the same. | 48 // Ensure that the height of the stacks is the same. |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 AllocationContextTracker::GetInstanceForCurrentThread() | 276 AllocationContextTracker::GetInstanceForCurrentThread() |
277 ->GetContextSnapshot(); | 277 ->GetContextSnapshot(); |
278 const StringPiece kTracingOverhead("tracing_overhead"); | 278 const StringPiece kTracingOverhead("tracing_overhead"); |
279 ASSERT_EQ(kTracingOverhead, | 279 ASSERT_EQ(kTracingOverhead, |
280 static_cast<const char*>(ctx.backtrace.frames[0].value)); | 280 static_cast<const char*>(ctx.backtrace.frames[0].value)); |
281 ASSERT_EQ(1u, ctx.backtrace.frame_count); | 281 ASSERT_EQ(1u, ctx.backtrace.frame_count); |
282 } | 282 } |
283 | 283 |
284 } // namespace trace_event | 284 } // namespace trace_event |
285 } // namespace base | 285 } // namespace base |
OLD | NEW |