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

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: Fix issue with tracked_objects::Location spotted by asan 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..a0bc14200139e176ee03b6dccefa0d8a29270d67 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> remaining_tasks;
+ 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) {
+ remaining_tasks.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(remaining_tasks);
+}
+
} // namespace internal
} // namespace scheduler
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698