Chromium Code Reviews| 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 27 matching lines...) Expand all Loading... | |
| 38 TRACE_ID_MANGLE(GetTaskTraceID(pending_task)), | 38 TRACE_ID_MANGLE(GetTaskTraceID(pending_task)), |
| 39 TRACE_EVENT_FLAG_FLOW_IN, | 39 TRACE_EVENT_FLAG_FLOW_IN, |
| 40 "queue_duration", | 40 "queue_duration", |
| 41 queue_duration.InMilliseconds()); | 41 queue_duration.InMilliseconds()); |
| 42 | 42 |
| 43 // Before running the task, store the program counter where it was posted | 43 // Before running the task, store the program counter where it was posted |
| 44 // and deliberately alias it to ensure it is on the stack if the task | 44 // and deliberately alias it to ensure it is on the stack if the task |
| 45 // crashes. Be careful not to assume that the variable itself will have the | 45 // crashes. Be careful not to assume that the variable itself will have the |
| 46 // expected value when displayed by the optimizer in an optimized build. | 46 // expected value when displayed by the optimizer in an optimized build. |
| 47 // Look at a memory dump of the stack. | 47 // Look at a memory dump of the stack. |
| 48 const void* program_counter = pending_task.posted_from.program_counter(); | 48 const void* const program_counter = |
|
brettw
2015/09/25 04:51:25
This one seems unnecessary. I usually prefer not t
Lei Zhang
2015/09/25 05:35:39
Reverted
| |
| 49 pending_task.posted_from.program_counter(); | |
| 49 debug::Alias(&program_counter); | 50 debug::Alias(&program_counter); |
| 50 | 51 |
| 51 pending_task.task.Run(); | 52 pending_task.task.Run(); |
| 52 | 53 |
| 53 stopwatch.Stop(); | 54 stopwatch.Stop(); |
| 54 tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking( | 55 tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking( |
| 55 pending_task, stopwatch); | 56 pending_task, stopwatch); |
| 56 } | 57 } |
| 57 | 58 |
| 58 uint64 TaskAnnotator::GetTaskTraceID(const PendingTask& task) const { | 59 uint64 TaskAnnotator::GetTaskTraceID(const PendingTask& task) const { |
| 59 return (static_cast<uint64>(task.sequence_num) << 32) | | 60 return (static_cast<uint64>(task.sequence_num) << 32) | |
| 60 ((static_cast<uint64>(reinterpret_cast<intptr_t>(this)) << 32) >> 32); | 61 ((static_cast<uint64>(reinterpret_cast<intptr_t>(this)) << 32) >> 32); |
| 61 } | 62 } |
| 62 | 63 |
| 63 } // namespace debug | 64 } // namespace debug |
| 64 } // namespace base | 65 } // namespace base |
| OLD | NEW |