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 #ifndef BASE_DEBUG_TASK_ANNOTATOR_H_ | 5 #ifndef BASE_DEBUG_TASK_ANNOTATOR_H_ |
| 6 #define BASE_DEBUG_TASK_ANNOTATOR_H_ | 6 #define BASE_DEBUG_TASK_ANNOTATOR_H_ |
| 7 | 7 |
| 8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 | 10 |
| 11 namespace base { | 11 namespace base { |
| 12 struct PendingTask; | 12 struct PendingTask; |
| 13 namespace debug { | 13 namespace debug { |
| 14 | 14 |
| 15 // Implements common debug annotations for posted tasks. This includes data | 15 // Implements common debug annotations for posted tasks. This includes data |
| 16 // such as task origins, queueing durations and memory usage. | 16 // such as task origins, queueing durations and memory usage. |
| 17 class BASE_EXPORT TaskAnnotator { | 17 class BASE_EXPORT TaskAnnotator { |
| 18 public: | 18 public: |
| 19 TaskAnnotator(); | 19 TaskAnnotator(); |
| 20 ~TaskAnnotator(); | 20 ~TaskAnnotator(); |
| 21 | 21 |
| 22 // Called to indicate that a task has been queued to run in the future. | 22 // Called to indicate that a task has been queued to run in the future. |
| 23 // |queue_function| is used as the trace flow event name. | 23 // |queue_function| is used as the trace flow event name. |
| 24 void DidQueueTask(const char* queue_function, | 24 void DidQueueTask(const char* queue_function, |
| 25 const PendingTask& pending_task); | 25 const PendingTask& pending_task); |
| 26 | 26 |
| 27 // Run a previously queued task. |queue_function| should match what was | 27 // Run a previously queued task. |queue_function| should match what was |
| 28 // passed into |DidQueueTask| for this task. |run_function| is used as the | 28 // passed into |DidQueueTask| for this task. |run_function| is used as the |
|
Sami
2015/07/15 17:44:00
Please update this comment.
| |
| 29 // name for the trace event that surrounds the task's execution. | 29 // name for the trace event that surrounds the task's execution. |
| 30 void RunTask(const char* queue_function, | 30 void RunTask(const char* queue_function, |
| 31 const char* run_function, | |
| 32 const PendingTask& pending_task); | 31 const PendingTask& pending_task); |
| 33 | 32 |
| 34 private: | 33 private: |
| 35 // Creates a process-wide unique ID to represent this task in trace events. | 34 // Creates a process-wide unique ID to represent this task in trace events. |
| 36 // This will be mangled with a Process ID hash to reduce the likelyhood of | 35 // This will be mangled with a Process ID hash to reduce the likelyhood of |
| 37 // colliding with TaskAnnotator pointers on other processes. | 36 // colliding with TaskAnnotator pointers on other processes. |
| 38 uint64 GetTaskTraceID(const PendingTask& task) const; | 37 uint64 GetTaskTraceID(const PendingTask& task) const; |
| 39 | 38 |
| 40 DISALLOW_COPY_AND_ASSIGN(TaskAnnotator); | 39 DISALLOW_COPY_AND_ASSIGN(TaskAnnotator); |
| 41 }; | 40 }; |
| 42 | 41 |
| 43 } // namespace debug | 42 } // namespace debug |
| 44 } // namespace base | 43 } // namespace base |
| 45 | 44 |
| 46 #endif // BASE_DEBUG_TASK_ANNOTATOR_H_ | 45 #endif // BASE_DEBUG_TASK_ANNOTATOR_H_ |
| OLD | NEW |