Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1742)

Unified Diff: base/debug/task_annotator.h

Issue 1784133002: [tracing] Adding task information to heap profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use ThreadIdNameManager Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/threading/sequenced_worker_pool.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/task_annotator.h
diff --git a/base/debug/task_annotator.h b/base/debug/task_annotator.h
index 443c71bf30169ded3042c90d07343710b4cdab42..777bc23c63009f7ddb56d577f9c64a157eda0a12 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,35 @@ 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 (trace_event::AllocationContextTracker::capture_enabled()) {
Sami 2016/03/17 17:06:26 Might want to add a throw an UNLIKELY() around thi
+ trace_event::AllocationContextTracker::SetCurrentTaskFileName(file_name);
Sami 2016/03/17 17:06:26 Why isn't the file name also part of the pseudo st
+ trace_event::AllocationContextTracker::PushPseudoStackFrame(
+ function_name_);
+ }
+ }
+
+ ~ScopedTaskExecutionEvent() {
+ if (trace_event::AllocationContextTracker::capture_enabled()) {
+ trace_event::AllocationContextTracker::PopPseudoStackFrame(
+ function_name_);
+ 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
« no previous file with comments | « no previous file | base/threading/sequenced_worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698