| 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 "components/metrics/profiler/tracking_synchronizer.h" | 5 #include "components/metrics/profiler/tracking_synchronizer.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 switch (attributes.profiling_phase) { | 62 switch (attributes.profiling_phase) { |
| 63 case 0: | 63 case 0: |
| 64 EXPECT_FALSE(got_phase_0_); | 64 EXPECT_FALSE(got_phase_0_); |
| 65 got_phase_0_ = true; | 65 got_phase_0_ = true; |
| 66 | 66 |
| 67 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMilliseconds(111), | 67 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMilliseconds(111), |
| 68 attributes.phase_start); | 68 attributes.phase_start); |
| 69 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMilliseconds(333), | 69 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMilliseconds(333), |
| 70 attributes.phase_finish); | 70 attributes.phase_finish); |
| 71 | 71 |
| 72 EXPECT_EQ("death_thread0", | 72 EXPECT_EQ("death_threadA", |
| 73 process_data_phase.tasks[0].death_thread_name); | 73 process_data_phase.tasks[0].death_sanitized_thread_name); |
| 74 EXPECT_EQ(0u, past_events.size()); | 74 EXPECT_EQ(0u, past_events.size()); |
| 75 break; | 75 break; |
| 76 | 76 |
| 77 case 1: | 77 case 1: |
| 78 EXPECT_FALSE(got_phase_1_); | 78 EXPECT_FALSE(got_phase_1_); |
| 79 got_phase_1_ = true; | 79 got_phase_1_ = true; |
| 80 | 80 |
| 81 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMilliseconds(333), | 81 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMilliseconds(333), |
| 82 attributes.phase_start); | 82 attributes.phase_start); |
| 83 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMilliseconds(777), | 83 EXPECT_EQ(base::TimeTicks() + base::TimeDelta::FromMilliseconds(777), |
| 84 attributes.phase_finish); | 84 attributes.phase_finish); |
| 85 | 85 |
| 86 EXPECT_EQ("death_thread1", | 86 EXPECT_EQ("death_threadB", |
| 87 process_data_phase.tasks[0].death_thread_name); | 87 process_data_phase.tasks[0].death_sanitized_thread_name); |
| 88 ASSERT_EQ(1u, past_events.size()); | 88 ASSERT_EQ(1u, past_events.size()); |
| 89 EXPECT_EQ(ProfilerEventProto::EVENT_FIRST_NONEMPTY_PAINT, | 89 EXPECT_EQ(ProfilerEventProto::EVENT_FIRST_NONEMPTY_PAINT, |
| 90 past_events[0]); | 90 past_events[0]); |
| 91 break; | 91 break; |
| 92 | 92 |
| 93 default: | 93 default: |
| 94 bool profiling_phase_is_neither_0_nor_1 = true; | 94 bool profiling_phase_is_neither_0_nor_1 = true; |
| 95 EXPECT_FALSE(profiling_phase_is_neither_0_nor_1); | 95 EXPECT_FALSE(profiling_phase_is_neither_0_nor_1); |
| 96 } | 96 } |
| 97 } | 97 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 128 new TestTrackingSynchronizer(base::WrapUnique(clock)); | 128 new TestTrackingSynchronizer(base::WrapUnique(clock)); |
| 129 | 129 |
| 130 clock->Advance(base::TimeDelta::FromMilliseconds(222)); | 130 clock->Advance(base::TimeDelta::FromMilliseconds(222)); |
| 131 | 131 |
| 132 tracking_synchronizer->RegisterPhaseCompletion( | 132 tracking_synchronizer->RegisterPhaseCompletion( |
| 133 ProfilerEventProto::EVENT_FIRST_NONEMPTY_PAINT); | 133 ProfilerEventProto::EVENT_FIRST_NONEMPTY_PAINT); |
| 134 | 134 |
| 135 tracked_objects::ProcessDataSnapshot profiler_data; | 135 tracked_objects::ProcessDataSnapshot profiler_data; |
| 136 ProcessDataPhaseSnapshot snapshot0; | 136 ProcessDataPhaseSnapshot snapshot0; |
| 137 tracked_objects::TaskSnapshot task_snapshot0; | 137 tracked_objects::TaskSnapshot task_snapshot0; |
| 138 task_snapshot0.death_thread_name = "death_thread0"; | 138 task_snapshot0.death_sanitized_thread_name = "death_threadA"; |
| 139 snapshot0.tasks.push_back(task_snapshot0); | 139 snapshot0.tasks.push_back(task_snapshot0); |
| 140 ProcessDataPhaseSnapshot snapshot1; | 140 ProcessDataPhaseSnapshot snapshot1; |
| 141 profiler_data.phased_snapshots[0] = snapshot0; | 141 profiler_data.phased_snapshots[0] = snapshot0; |
| 142 tracked_objects::TaskSnapshot task_snapshot1; | 142 tracked_objects::TaskSnapshot task_snapshot1; |
| 143 task_snapshot1.death_thread_name = "death_thread1"; | 143 task_snapshot1.death_sanitized_thread_name = "death_threadB"; |
| 144 snapshot1.tasks.push_back(task_snapshot1); | 144 snapshot1.tasks.push_back(task_snapshot1); |
| 145 profiler_data.phased_snapshots[1] = snapshot1; | 145 profiler_data.phased_snapshots[1] = snapshot1; |
| 146 profiler_data.process_id = 239; | 146 profiler_data.process_id = 239; |
| 147 | 147 |
| 148 clock->Advance(base::TimeDelta::FromMilliseconds(444)); | 148 clock->Advance(base::TimeDelta::FromMilliseconds(444)); |
| 149 TestObserver test_observer; | 149 TestObserver test_observer; |
| 150 tracking_synchronizer->SendData( | 150 tracking_synchronizer->SendData( |
| 151 profiler_data, ProfilerEventProto::TrackedObject::PPAPI_PLUGIN, | 151 profiler_data, ProfilerEventProto::TrackedObject::PPAPI_PLUGIN, |
| 152 &test_observer); | 152 &test_observer); |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace metrics | 155 } // namespace metrics |
| OLD | NEW |