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

Unified Diff: base/pending_task.cc

Issue 1044413002: Record async "task backtraces" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More wording fixes. Created 3 years, 10 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 | « base/pending_task.h ('k') | base/pending_task_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/pending_task.cc
diff --git a/base/pending_task.cc b/base/pending_task.cc
index cca9ebfbff3d43bc1c840ce9493e372864e9e0d1..b2f95b4c451bad6cf461e2db50e812579b3c265e 100644
--- a/base/pending_task.cc
+++ b/base/pending_task.cc
@@ -4,18 +4,14 @@
#include "base/pending_task.h"
+#include "base/message_loop/message_loop.h"
#include "base/tracked_objects.h"
namespace base {
PendingTask::PendingTask(const tracked_objects::Location& posted_from,
OnceClosure task)
- : base::TrackingInfo(posted_from, TimeTicks()),
- task(std::move(task)),
- posted_from(posted_from),
- sequence_num(0),
- nestable(true),
- is_high_res(false) {}
+ : PendingTask(posted_from, std::move(task), TimeTicks(), true) {}
PendingTask::PendingTask(const tracked_objects::Location& posted_from,
OnceClosure task,
@@ -26,7 +22,19 @@ PendingTask::PendingTask(const tracked_objects::Location& posted_from,
posted_from(posted_from),
sequence_num(0),
nestable(nestable),
- is_high_res(false) {}
+ is_high_res(false) {
+ const PendingTask* parent_task =
+ MessageLoop::current() ? MessageLoop::current()->current_pending_task_
+ : nullptr;
+ if (parent_task) {
+ task_backtrace[0] = parent_task->posted_from.program_counter();
+ std::copy(parent_task->task_backtrace.begin(),
+ parent_task->task_backtrace.end() - 1,
+ task_backtrace.begin() + 1);
+ } else {
+ task_backtrace.fill(nullptr);
+ }
+}
PendingTask::PendingTask(PendingTask&& other) = default;
« no previous file with comments | « base/pending_task.h ('k') | base/pending_task_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698