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

Unified Diff: components/scheduler/base/task_queue_impl.cc

Issue 2155143002: Fix a bug that could occasionaly cause setInterval to stop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed ThrottledTimeDomain to be based on RealTimeDomain Created 4 years, 5 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: components/scheduler/base/task_queue_impl.cc
diff --git a/components/scheduler/base/task_queue_impl.cc b/components/scheduler/base/task_queue_impl.cc
index c8ce1e9e0c581dac724746694d460047396f708d..7d684fb000c3aac28cd4fa0087eedc8cbb1f1232 100644
--- a/components/scheduler/base/task_queue_impl.cc
+++ b/components/scheduler/base/task_queue_impl.cc
@@ -189,9 +189,7 @@ bool TaskQueueImpl::PostDelayedTaskImpl(
main_thread_only().task_queue_manager->GetNextSequenceNumber();
base::TimeTicks time_domain_now = main_thread_only().time_domain->Now();
- base::TimeTicks time_domain_delayed_run_time =
- main_thread_only().time_domain->ComputeDelayedRunTime(time_domain_now,
- delay);
+ base::TimeTicks time_domain_delayed_run_time = time_domain_now + delay;
PushOntoDelayedIncomingQueueFromMainThread(
Task(from_here, task, time_domain_delayed_run_time, sequence_number,
task_type != TaskType::NON_NESTABLE),
@@ -209,8 +207,7 @@ bool TaskQueueImpl::PostDelayedTaskImpl(
any_thread().task_queue_manager->GetNextSequenceNumber();
base::TimeTicks time_domain_now = any_thread().time_domain->Now();
- base::TimeTicks time_domain_delayed_run_time =
- any_thread().time_domain->ComputeDelayedRunTime(time_domain_now, delay);
+ base::TimeTicks time_domain_delayed_run_time = time_domain_now + delay;
PushOntoDelayedIncomingQueueLocked(
Task(from_here, task, time_domain_delayed_run_time, sequence_number,
task_type != TaskType::NON_NESTABLE));
@@ -450,7 +447,8 @@ void TaskQueueImpl::SetPumpPolicy(PumpPolicy pump_policy) {
base::AutoLock lock(any_thread_lock_);
if (pump_policy == PumpPolicy::AUTO &&
any_thread().pump_policy != PumpPolicy::AUTO) {
- PumpQueueLocked(true);
+ LazyNow lazy_now(main_thread_only().time_domain->CreateLazyNow());
rmcilroy 2016/07/18 15:22:57 Just out of interest, wondering why this LazyNow c
alex clarke (OOO till 29th) 2016/07/18 15:35:52 There could be many throttled task queues, and Thr
rmcilroy 2016/07/18 16:01:42 I see, makes sense, thanks.
+ PumpQueueLocked(&lazy_now, true);
}
any_thread().pump_policy = pump_policy;
main_thread_only().pump_policy = pump_policy;
@@ -460,15 +458,14 @@ TaskQueue::PumpPolicy TaskQueueImpl::GetPumpPolicy() const {
return main_thread_only().pump_policy;
}
-void TaskQueueImpl::PumpQueueLocked(bool may_post_dowork) {
+void TaskQueueImpl::PumpQueueLocked(LazyNow* lazy_now, bool may_post_dowork) {
TRACE_EVENT1(disabled_by_default_tracing_category_,
"TaskQueueImpl::PumpQueueLocked", "queue", name_);
TaskQueueManager* task_queue_manager = any_thread().task_queue_manager;
if (!task_queue_manager)
return;
- LazyNow lazy_now(main_thread_only().time_domain->CreateLazyNow());
- MoveReadyDelayedTasksToDelayedWorkQueue(&lazy_now);
+ MoveReadyDelayedTasksToDelayedWorkQueue(lazy_now);
while (!any_thread().immediate_incoming_queue.empty()) {
main_thread_only().immediate_work_queue->Push(
@@ -489,9 +486,9 @@ void TaskQueueImpl::PumpQueueLocked(bool may_post_dowork) {
task_queue_manager->MaybeScheduleImmediateWork(FROM_HERE);
}
-void TaskQueueImpl::PumpQueue(bool may_post_dowork) {
+void TaskQueueImpl::PumpQueue(LazyNow* lazy_now, bool may_post_dowork) {
base::AutoLock lock(any_thread_lock_);
- PumpQueueLocked(may_post_dowork);
+ PumpQueueLocked(lazy_now, may_post_dowork);
}
const char* TaskQueueImpl::GetName() const {

Powered by Google App Engine
This is Rietveld 408576698