Index: third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc |
diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc |
index f44ee457a87e5189ddb438b495d6db1920f95be9..7d1ffda8d72983e0d51f923bc25f0f910c8ca177 100644 |
--- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc |
+++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc |
@@ -275,19 +275,24 @@ TaskQueueManager::ProcessTaskResult TaskQueueManager::ProcessTaskFromWorkQueue( |
internal::WorkQueue* work_queue) { |
DCHECK(main_thread_checker_.CalledOnValidThread()); |
scoped_refptr<DeletionSentinel> protect(deletion_sentinel_); |
- internal::TaskQueueImpl* queue = work_queue->task_queue(); |
+ internal::TaskQueueImpl::Task pending_task = |
+ work_queue->TakeTaskFromWorkQueue(); |
+ |
+ // It's possible the task was canceled, if so bail out. |
+ if (pending_task.task.IsCancelled()) |
+ return ProcessTaskResult::EXECUTED; |
+ internal::TaskQueueImpl* queue = work_queue->task_queue(); |
if (queue->GetQuiescenceMonitored()) |
task_was_run_on_quiescence_monitored_queue_ = true; |
- internal::TaskQueueImpl::Task pending_task = |
- work_queue->TakeTaskFromWorkQueue(); |
if (!pending_task.nestable && delegate_->IsNested()) { |
// Defer non-nestable work to the main task runner. NOTE these tasks can be |
// arbitrarily delayed so the additional delay should not be a problem. |
// TODO(skyostil): Figure out a way to not forget which task queue the |
// task is associated with. See http://crbug.com/522843. |
- delegate_->PostNonNestableTask(pending_task.posted_from, pending_task.task); |
+ delegate_->PostNonNestableTask(pending_task.posted_from, |
+ std::move(pending_task.task)); |
return ProcessTaskResult::DEFERRED; |
} |