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

Unified Diff: third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc

Issue 2637463002: Add an idle task to periodically sweep canceled delayed tasks (Closed)
Patch Set: Clarify test Created 3 years, 11 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
Index: third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc b/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc
index e3a3b584141c459239a86ca823e8fc6cfa87e211..aadd9b1923c23b84af3ce7b89e685a2261456f84 100644
--- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc
+++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc
@@ -814,6 +814,28 @@ TaskQueueImpl::CreateQueueEnabledVoter() {
return base::MakeUnique<QueueEnabledVoterImpl>(this);
}
+void TaskQueueImpl::SweepCanceledDelayedTasks(base::TimeTicks now) {
+ if (main_thread_only().delayed_incoming_queue.empty())
+ return;
+
+ base::TimeTicks first_task_runtime =
+ main_thread_only().delayed_incoming_queue.top().delayed_run_time;
+
+ // TODO(alexclarke): Let this remove all tasks once the DoWork refactor has
+ // landed.
+ std::priority_queue<Task> swept;
Sami 2017/01/13 19:00:30 nit: How about |remaining_tasks| since the others
alex clarke (OOO till 29th) 2017/01/13 19:04:40 Done.
+ while (!main_thread_only().delayed_incoming_queue.empty()) {
+ if (!main_thread_only().delayed_incoming_queue.top().task.IsCancelled() ||
+ main_thread_only().delayed_incoming_queue.top().delayed_run_time ==
+ first_task_runtime) {
+ swept.push(std::move(
+ const_cast<Task&>(main_thread_only().delayed_incoming_queue.top())));
+ }
+ main_thread_only().delayed_incoming_queue.pop();
+ }
+ main_thread_only().delayed_incoming_queue = std::move(swept);
+}
+
} // namespace internal
} // namespace scheduler
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698