| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 using TrackingSynchronizer::SendData; | 112 using TrackingSynchronizer::SendData; |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 ~TestTrackingSynchronizer() override {} | 115 ~TestTrackingSynchronizer() override {} |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 } // namespace | 118 } // namespace |
| 119 | 119 |
| 120 TEST(TrackingSynchronizerTest, ProfilerData) { | 120 TEST(TrackingSynchronizerTest, ProfilerData) { |
| 121 // Testing how TrackingSynchronizer reports 2 phases of profiling. | 121 // Testing how TrackingSynchronizer reports 2 phases of profiling. |
| 122 auto clock = new base::SimpleTestTickClock(); // Will be owned by | 122 auto clock = new base::SimpleTestTickClock( |
| 123 // |tracking_synchronizer|. | 123 base::TimeTicks() + |
| 124 clock->Advance(base::TimeDelta::FromMilliseconds(111)); | 124 base::TimeDelta::FromMilliseconds( |
| 125 111)); // Will be owned by |tracking_synchronizer|. |
| 125 | 126 |
| 126 scoped_refptr<TestTrackingSynchronizer> tracking_synchronizer = | 127 scoped_refptr<TestTrackingSynchronizer> tracking_synchronizer = |
| 127 new TestTrackingSynchronizer(make_scoped_ptr(clock)); | 128 new TestTrackingSynchronizer(make_scoped_ptr(clock)); |
| 128 | 129 |
| 129 clock->Advance(base::TimeDelta::FromMilliseconds(222)); | 130 clock->Advance(base::TimeDelta::FromMilliseconds(222)); |
| 130 | 131 |
| 131 tracking_synchronizer->RegisterPhaseCompletion( | 132 tracking_synchronizer->RegisterPhaseCompletion( |
| 132 ProfilerEventProto::EVENT_FIRST_NONEMPTY_PAINT); | 133 ProfilerEventProto::EVENT_FIRST_NONEMPTY_PAINT); |
| 133 | 134 |
| 134 tracked_objects::ProcessDataSnapshot profiler_data; | 135 tracked_objects::ProcessDataSnapshot profiler_data; |
| 135 ProcessDataPhaseSnapshot snapshot0; | 136 ProcessDataPhaseSnapshot snapshot0; |
| 136 tracked_objects::TaskSnapshot task_snapshot0; | 137 tracked_objects::TaskSnapshot task_snapshot0; |
| 137 task_snapshot0.death_thread_name = "death_thread0"; | 138 task_snapshot0.death_thread_name = "death_thread0"; |
| 138 snapshot0.tasks.push_back(task_snapshot0); | 139 snapshot0.tasks.push_back(task_snapshot0); |
| 139 ProcessDataPhaseSnapshot snapshot1; | 140 ProcessDataPhaseSnapshot snapshot1; |
| 140 profiler_data.phased_snapshots[0] = snapshot0; | 141 profiler_data.phased_snapshots[0] = snapshot0; |
| 141 tracked_objects::TaskSnapshot task_snapshot1; | 142 tracked_objects::TaskSnapshot task_snapshot1; |
| 142 task_snapshot1.death_thread_name = "death_thread1"; | 143 task_snapshot1.death_thread_name = "death_thread1"; |
| 143 snapshot1.tasks.push_back(task_snapshot1); | 144 snapshot1.tasks.push_back(task_snapshot1); |
| 144 profiler_data.phased_snapshots[1] = snapshot1; | 145 profiler_data.phased_snapshots[1] = snapshot1; |
| 145 profiler_data.process_id = 239; | 146 profiler_data.process_id = 239; |
| 146 | 147 |
| 147 clock->Advance(base::TimeDelta::FromMilliseconds(444)); | 148 clock->Advance(base::TimeDelta::FromMilliseconds(444)); |
| 148 TestObserver test_observer; | 149 TestObserver test_observer; |
| 149 tracking_synchronizer->SendData( | 150 tracking_synchronizer->SendData( |
| 150 profiler_data, ProfilerEventProto::TrackedObject::PLUGIN, &test_observer); | 151 profiler_data, ProfilerEventProto::TrackedObject::PLUGIN, &test_observer); |
| 151 } | 152 } |
| 152 | 153 |
| 153 } // namespace metrics | 154 } // namespace metrics |
| OLD | NEW |