Commit 2f811807 authored by Alex Clarke's avatar Alex Clarke Committed by Commit Bot

SequenceManager: Cross thread delayed task calls WillQueueTask once

Bug: 826902
Change-Id: Ic79292edea1d7d92935797103ded169cb114e1cf
Reviewed-on: https://chromium-review.googlesource.com/1254542
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595848}
parent 7ce2712a
...@@ -44,10 +44,8 @@ void TaskAnnotator::WillQueueTask(const char* queue_function, ...@@ -44,10 +44,8 @@ void TaskAnnotator::WillQueueTask(const char* queue_function,
TRACE_EVENT_FLAG_FLOW_OUT); TRACE_EVENT_FLAG_FLOW_OUT);
} }
// TODO(https://crbug.com/826902): Fix callers that invoke WillQueueTask() DCHECK(!pending_task->task_backtrace[0])
// twice for the same PendingTask. << "Task backtrace was already set, task posted twice??";
// DCHECK(!pending_task.task_backtrace[0])
// << "Task backtrace was already set, task posted twice??";
if (!pending_task->task_backtrace[0]) { if (!pending_task->task_backtrace[0]) {
const PendingTask* parent_task = GetTLSForCurrentPendingTask()->Get(); const PendingTask* parent_task = GetTLSForCurrentPendingTask()->Get();
if (parent_task) { if (parent_task) {
......
...@@ -204,7 +204,7 @@ void TaskQueueImpl::PostDelayedTaskImpl(PostedTask task) { ...@@ -204,7 +204,7 @@ void TaskQueueImpl::PostDelayedTaskImpl(PostedTask task) {
TimeTicks time_domain_delayed_run_time = time_domain_now + task.delay; TimeTicks time_domain_delayed_run_time = time_domain_now + task.delay;
PushOntoDelayedIncomingQueueFromMainThread( PushOntoDelayedIncomingQueueFromMainThread(
Task(std::move(task), time_domain_delayed_run_time, sequence_number), Task(std::move(task), time_domain_delayed_run_time, sequence_number),
time_domain_now); time_domain_now, /* notify_task_annotator */ true);
} else { } else {
// NOTE posting a delayed task from a different thread is not expected to // NOTE posting a delayed task from a different thread is not expected to
// be common. This pathway is less optimal than perhaps it could be // be common. This pathway is less optimal than perhaps it could be
...@@ -225,8 +225,10 @@ void TaskQueueImpl::PostDelayedTaskImpl(PostedTask task) { ...@@ -225,8 +225,10 @@ void TaskQueueImpl::PostDelayedTaskImpl(PostedTask task) {
void TaskQueueImpl::PushOntoDelayedIncomingQueueFromMainThread( void TaskQueueImpl::PushOntoDelayedIncomingQueueFromMainThread(
Task pending_task, Task pending_task,
TimeTicks now) { TimeTicks now,
main_thread_only().sequence_manager->WillQueueTask(&pending_task); bool notify_task_annotator) {
if (notify_task_annotator)
main_thread_only().sequence_manager->WillQueueTask(&pending_task);
main_thread_only().delayed_incoming_queue.push(std::move(pending_task)); main_thread_only().delayed_incoming_queue.push(std::move(pending_task));
LazyNow lazy_now(now); LazyNow lazy_now(now);
...@@ -266,7 +268,7 @@ void TaskQueueImpl::ScheduleDelayedWorkTask(Task pending_task) { ...@@ -266,7 +268,7 @@ void TaskQueueImpl::ScheduleDelayedWorkTask(Task pending_task) {
} else { } else {
// If |delayed_run_time| is in the future we can queue it as normal. // If |delayed_run_time| is in the future we can queue it as normal.
PushOntoDelayedIncomingQueueFromMainThread(std::move(pending_task), PushOntoDelayedIncomingQueueFromMainThread(std::move(pending_task),
time_domain_now); time_domain_now, false);
} }
TraceQueueSize(); TraceQueueSize();
} }
......
...@@ -296,7 +296,8 @@ class BASE_EXPORT TaskQueueImpl { ...@@ -296,7 +296,8 @@ class BASE_EXPORT TaskQueueImpl {
// Push the task onto the |delayed_incoming_queue|. Lock-free main thread // Push the task onto the |delayed_incoming_queue|. Lock-free main thread
// only fast path. // only fast path.
void PushOntoDelayedIncomingQueueFromMainThread(Task pending_task, void PushOntoDelayedIncomingQueueFromMainThread(Task pending_task,
TimeTicks now); TimeTicks now,
bool notify_task_annotator);
// Push the task onto the |delayed_incoming_queue|. Slow path from other // Push the task onto the |delayed_incoming_queue|. Slow path from other
// threads. // threads.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment