OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/debug/task_annotator.h" | 5 #include "base/debug/task_annotator.h" |
6 | 6 |
7 #include "base/debug/alias.h" | 7 #include "base/debug/alias.h" |
8 #include "base/pending_task.h" | 8 #include "base/pending_task.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "base/tracked_objects.h" | 10 #include "base/tracked_objects.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 void TaskAnnotator::DidQueueTask(const char* queue_function, | 21 void TaskAnnotator::DidQueueTask(const char* queue_function, |
22 const PendingTask& pending_task) { | 22 const PendingTask& pending_task) { |
23 TRACE_EVENT_FLOW_BEGIN0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), | 23 TRACE_EVENT_FLOW_BEGIN0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), |
24 queue_function, | 24 queue_function, |
25 TRACE_ID_MANGLE(GetTaskTraceID(pending_task))); | 25 TRACE_ID_MANGLE(GetTaskTraceID(pending_task))); |
26 } | 26 } |
27 | 27 |
28 void TaskAnnotator::RunTask(const char* queue_function, | 28 void TaskAnnotator::RunTask(const char* queue_function, |
29 const char* run_function, | 29 const char* run_function, |
30 const PendingTask& pending_task) { | 30 const PendingTask& pending_task) { |
31 tracked_objects::ThreadData::PrepareForStartOfRun(pending_task.birth_tally); | |
32 tracked_objects::TaskStopwatch stopwatch; | 31 tracked_objects::TaskStopwatch stopwatch; |
33 stopwatch.Start(); | 32 stopwatch.Start(); |
34 tracked_objects::Duration queue_duration = | 33 tracked_objects::Duration queue_duration = |
35 stopwatch.StartTime() - pending_task.EffectiveTimePosted(); | 34 stopwatch.StartTime() - pending_task.EffectiveTimePosted(); |
36 | 35 |
37 TRACE_EVENT_FLOW_END1(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), | 36 TRACE_EVENT_FLOW_END1(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), |
38 queue_function, | 37 queue_function, |
39 TRACE_ID_MANGLE(GetTaskTraceID(pending_task)), | 38 TRACE_ID_MANGLE(GetTaskTraceID(pending_task)), |
40 "queue_duration", | 39 "queue_duration", |
41 queue_duration.InMilliseconds()); | 40 queue_duration.InMilliseconds()); |
(...skipping 25 matching lines...) Expand all Loading... |
67 pending_task, stopwatch); | 66 pending_task, stopwatch); |
68 } | 67 } |
69 | 68 |
70 uint64 TaskAnnotator::GetTaskTraceID(const PendingTask& task) const { | 69 uint64 TaskAnnotator::GetTaskTraceID(const PendingTask& task) const { |
71 return (static_cast<uint64>(task.sequence_num) << 32) | | 70 return (static_cast<uint64>(task.sequence_num) << 32) | |
72 ((static_cast<uint64>(reinterpret_cast<intptr_t>(this)) << 32) >> 32); | 71 ((static_cast<uint64>(reinterpret_cast<intptr_t>(this)) << 32) >> 32); |
73 } | 72 } |
74 | 73 |
75 } // namespace debug | 74 } // namespace debug |
76 } // namespace base | 75 } // namespace base |
OLD | NEW |