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

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

Issue 2583333002: Revert of Dont post delayed DoWork for disabled queues. (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/scheduler/base/task_queue_impl.h" 5 #include "platform/scheduler/base/task_queue_impl.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/trace_event/blame_context.h" 10 #include "base/trace_event/blame_context.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 return true; 269 return true;
270 } 270 }
271 271
272 void TaskQueueImpl::PushOntoDelayedIncomingQueueFromMainThread( 272 void TaskQueueImpl::PushOntoDelayedIncomingQueueFromMainThread(
273 Task pending_task, base::TimeTicks now) { 273 Task pending_task, base::TimeTicks now) {
274 base::TimeTicks delayed_run_time = pending_task.delayed_run_time; 274 base::TimeTicks delayed_run_time = pending_task.delayed_run_time;
275 main_thread_only().task_queue_manager->DidQueueTask(pending_task); 275 main_thread_only().task_queue_manager->DidQueueTask(pending_task);
276 main_thread_only().delayed_incoming_queue.push(std::move(pending_task)); 276 main_thread_only().delayed_incoming_queue.push(std::move(pending_task));
277 277
278 // If |pending_task| is at the head of the queue, then make sure a wakeup 278 // If |pending_task| is at the head of the queue, then make sure a wakeup
279 // is requested if the queue is enabled. Note we still want to schedule a 279 // is requested.
280 // wakeup even if blocked by a fence, because we'd break throttling logic 280 if (main_thread_only().delayed_incoming_queue.top().delayed_run_time ==
281 // otherwise. 281 delayed_run_time) {
282 base::TimeTicks next_delayed_task = 282 main_thread_only().time_domain->ScheduleDelayedWork(
283 main_thread_only().delayed_incoming_queue.top().delayed_run_time; 283 this, pending_task.delayed_run_time, now);
284 if (next_delayed_task == delayed_run_time && IsQueueEnabled()) {
285 LazyNow lazy_now(now);
286 main_thread_only().time_domain->ScheduleDelayedWork(this, delayed_run_time,
287 &lazy_now);
288 } 284 }
289 285
290 TraceQueueSize(false); 286 TraceQueueSize(false);
291 } 287 }
292 288
293 void TaskQueueImpl::PushOntoDelayedIncomingQueueLocked(Task pending_task) { 289 void TaskQueueImpl::PushOntoDelayedIncomingQueueLocked(Task pending_task) {
294 any_thread().task_queue_manager->DidQueueTask(pending_task); 290 any_thread().task_queue_manager->DidQueueTask(pending_task);
295 291
296 int thread_hop_task_sequence_number = 292 int thread_hop_task_sequence_number =
297 any_thread().task_queue_manager->GetNextSequenceNumber(); 293 any_thread().task_queue_manager->GetNextSequenceNumber();
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 bool is_enabled = IsQueueEnabled(); 809 bool is_enabled = IsQueueEnabled();
814 if (was_enabled != is_enabled) 810 if (was_enabled != is_enabled)
815 EnableOrDisableWithSelector(is_enabled); 811 EnableOrDisableWithSelector(is_enabled);
816 } 812 }
817 813
818 void TaskQueueImpl::EnableOrDisableWithSelector(bool enable) { 814 void TaskQueueImpl::EnableOrDisableWithSelector(bool enable) {
819 if (!main_thread_only().task_queue_manager) 815 if (!main_thread_only().task_queue_manager)
820 return; 816 return;
821 817
822 if (enable) { 818 if (enable) {
823 if (!main_thread_only().delayed_incoming_queue.empty()) {
824 LazyNow lazy_now = main_thread_only().time_domain->CreateLazyNow();
825 main_thread_only().time_domain->ScheduleDelayedWork(
826 this,
827 main_thread_only().delayed_incoming_queue.top().delayed_run_time,
828 &lazy_now);
829 }
830 // Note it's the job of the selector to tell the TaskQueueManager if 819 // Note it's the job of the selector to tell the TaskQueueManager if
831 // an immediate DoWork needs posting. 820 // a DoWork needs posting.
832 main_thread_only().task_queue_manager->selector_.EnableQueue(this); 821 main_thread_only().task_queue_manager->selector_.EnableQueue(this);
833 } else { 822 } else {
834 if (!main_thread_only().delayed_incoming_queue.empty())
835 main_thread_only().time_domain->CancelDelayedWork(this);
836 main_thread_only().task_queue_manager->selector_.DisableQueue(this); 823 main_thread_only().task_queue_manager->selector_.DisableQueue(this);
837 } 824 }
838 } 825 }
839 826
840 std::unique_ptr<TaskQueueImpl::QueueEnabledVoter> 827 std::unique_ptr<TaskQueueImpl::QueueEnabledVoter>
841 TaskQueueImpl::CreateQueueEnabledVoter() { 828 TaskQueueImpl::CreateQueueEnabledVoter() {
842 main_thread_only().voter_refcount++; 829 main_thread_only().voter_refcount++;
843 main_thread_only().is_enabled_refcount++; 830 main_thread_only().is_enabled_refcount++;
844 return base::MakeUnique<QueueEnabledVoterImpl>(this); 831 return base::MakeUnique<QueueEnabledVoterImpl>(this);
845 } 832 }
846 833
847 } // namespace internal 834 } // namespace internal
848 } // namespace scheduler 835 } // namespace scheduler
849 } // namespace blink 836 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698