Chromium Code Reviews| Index: base/debug/task_annotator.h |
| diff --git a/base/debug/task_annotator.h b/base/debug/task_annotator.h |
| index 443c71bf30169ded3042c90d07343710b4cdab42..e641c11c25e5aa5b1cd44ab6f00f862577fa050e 100644 |
| --- a/base/debug/task_annotator.h |
| +++ b/base/debug/task_annotator.h |
| @@ -9,6 +9,7 @@ |
| #include "base/base_export.h" |
| #include "base/macros.h" |
| +#include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
| namespace base { |
| struct PendingTask; |
| @@ -39,10 +40,37 @@ class BASE_EXPORT TaskAnnotator { |
| DISALLOW_COPY_AND_ASSIGN(TaskAnnotator); |
| }; |
| +class ScopedTaskExecutionEvent { |
| + public: |
| + ScopedTaskExecutionEvent(const char* file_name, const char* function_name) |
| + : function_name_(function_name) { |
| + if (base::trace_event::AllocationContextTracker::capture_enabled()) { |
|
Dmitry Skiba
2016/03/15 19:38:31
BTW, since this is inside base too, you can omit b
ssid
2016/03/17 00:11:46
Done.
|
| + base::trace_event::AllocationContextTracker::SetCurrentTaskFileName( |
|
Primiano Tucci (use gerrit)
2016/03/15 16:44:33
why are these inline? Is it for perf reasons?
Tas
ssid
2016/03/17 00:11:46
See TRACE_TASK_EXECUTION below.
TRACE_TASK_EXECUT
|
| + file_name); |
| + base::trace_event::AllocationContextTracker::PushPseudoStackFrame( |
|
Primiano Tucci (use gerrit)
2016/03/15 16:44:33
Hmm I think that this will screw the pseudo-stack,
ssid
2016/03/17 00:11:47
What I was imagining was, The function that posted
|
| + function_name_); |
| + } |
| + } |
| + |
| + ~ScopedTaskExecutionEvent() { |
| + if (base::trace_event::AllocationContextTracker::capture_enabled()) { |
| + base::trace_event::AllocationContextTracker::PopPseudoStackFrame( |
| + function_name_); |
| + base::trace_event::AllocationContextTracker::SetCurrentTaskFileName( |
| + nullptr); |
| + } |
| + } |
| + |
| + private: |
| + const char* function_name_; |
| +}; |
| + |
| #define TRACE_TASK_EXECUTION(run_function, task) \ |
| TRACE_EVENT2("toplevel", (run_function), "src_file", \ |
| (task).posted_from.file_name(), "src_func", \ |
| - (task).posted_from.function_name()); |
| + (task).posted_from.function_name()); \ |
| + base::debug::ScopedTaskExecutionEvent scoped_task_event( \ |
| + (task).posted_from.file_name(), (task).posted_from.function_name()); |
| } // namespace debug |
| } // namespace base |