OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/scheduler/renderer/renderer_scheduler_impl.h" | 5 #include "components/scheduler/renderer/renderer_scheduler_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 delayed_update_policy_runner_.SetDeadline(FROM_HERE, new_policy_duration, | 355 delayed_update_policy_runner_.SetDeadline(FROM_HERE, new_policy_duration, |
356 now); | 356 now); |
357 } else { | 357 } else { |
358 current_policy_expiration_time_ = base::TimeTicks(); | 358 current_policy_expiration_time_ = base::TimeTicks(); |
359 } | 359 } |
360 | 360 |
361 if (update_type == UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED && | 361 if (update_type == UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED && |
362 new_policy == current_policy_) | 362 new_policy == current_policy_) |
363 return; | 363 return; |
364 | 364 |
365 PrioritizingTaskQueueSelector* task_queue_selector = | |
366 helper_.SchedulerTaskQueueSelector(); | |
367 bool policy_disables_timers = false; | 365 bool policy_disables_timers = false; |
368 | 366 |
369 switch (new_policy) { | 367 switch (new_policy) { |
370 case Policy::COMPOSITOR_PRIORITY: | 368 case Policy::COMPOSITOR_PRIORITY: |
371 task_queue_selector->SetQueuePriority( | 369 helper_.SetQueuePriority(COMPOSITOR_TASK_QUEUE, |
372 COMPOSITOR_TASK_QUEUE, PrioritizingTaskQueueSelector::HIGH_PRIORITY); | 370 PrioritizingTaskQueueSelector::HIGH_PRIORITY); |
373 // TODO(scheduler-dev): Add a task priority between HIGH and BEST_EFFORT | 371 // TODO(scheduler-dev): Add a task priority between HIGH and BEST_EFFORT |
374 // that still has some guarantee of running. | 372 // that still has some guarantee of running. |
375 task_queue_selector->SetQueuePriority( | 373 helper_.SetQueuePriority( |
376 LOADING_TASK_QUEUE, | 374 LOADING_TASK_QUEUE, |
377 PrioritizingTaskQueueSelector::BEST_EFFORT_PRIORITY); | 375 PrioritizingTaskQueueSelector::BEST_EFFORT_PRIORITY); |
378 break; | 376 break; |
379 case Policy::TOUCHSTART_PRIORITY: | 377 case Policy::TOUCHSTART_PRIORITY: |
380 task_queue_selector->SetQueuePriority( | 378 helper_.SetQueuePriority(COMPOSITOR_TASK_QUEUE, |
381 COMPOSITOR_TASK_QUEUE, PrioritizingTaskQueueSelector::HIGH_PRIORITY); | 379 PrioritizingTaskQueueSelector::HIGH_PRIORITY); |
382 task_queue_selector->DisableQueue(LOADING_TASK_QUEUE); | 380 helper_.DisableQueue(LOADING_TASK_QUEUE); |
383 // TODO(alexclarke): Set policy_disables_timers once the blink TimerBase | 381 // TODO(alexclarke): Set policy_disables_timers once the blink TimerBase |
384 // refactor is safely landed. | 382 // refactor is safely landed. |
385 break; | 383 break; |
386 case Policy::NORMAL: | 384 case Policy::NORMAL: |
387 task_queue_selector->SetQueuePriority( | 385 helper_.SetQueuePriority(COMPOSITOR_TASK_QUEUE, |
388 COMPOSITOR_TASK_QUEUE, | 386 PrioritizingTaskQueueSelector::NORMAL_PRIORITY); |
389 PrioritizingTaskQueueSelector::NORMAL_PRIORITY); | 387 helper_.SetQueuePriority(LOADING_TASK_QUEUE, |
390 task_queue_selector->SetQueuePriority( | 388 PrioritizingTaskQueueSelector::NORMAL_PRIORITY); |
391 LOADING_TASK_QUEUE, PrioritizingTaskQueueSelector::NORMAL_PRIORITY); | |
392 break; | 389 break; |
393 } | 390 } |
394 if (timer_queue_suspend_count_ != 0 || policy_disables_timers) { | 391 if (timer_queue_suspend_count_ != 0 || policy_disables_timers) { |
395 task_queue_selector->DisableQueue(TIMER_TASK_QUEUE); | 392 helper_.DisableQueue(TIMER_TASK_QUEUE); |
396 } else { | 393 } else { |
397 helper_.SchedulerTaskQueueSelector()->SetQueuePriority( | 394 helper_.SetQueuePriority(TIMER_TASK_QUEUE, |
398 TIMER_TASK_QUEUE, PrioritizingTaskQueueSelector::NORMAL_PRIORITY); | 395 PrioritizingTaskQueueSelector::NORMAL_PRIORITY); |
399 } | 396 } |
400 DCHECK(task_queue_selector->IsQueueEnabled(COMPOSITOR_TASK_QUEUE)); | 397 DCHECK(helper_.IsQueueEnabled(COMPOSITOR_TASK_QUEUE)); |
401 if (new_policy != Policy::TOUCHSTART_PRIORITY) | 398 if (new_policy != Policy::TOUCHSTART_PRIORITY) |
402 DCHECK(task_queue_selector->IsQueueEnabled(LOADING_TASK_QUEUE)); | 399 DCHECK(helper_.IsQueueEnabled(LOADING_TASK_QUEUE)); |
403 | 400 |
404 current_policy_ = new_policy; | 401 current_policy_ = new_policy; |
405 | 402 |
406 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 403 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
407 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", | 404 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", |
408 this, AsValueLocked(now)); | 405 this, AsValueLocked(now)); |
409 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 406 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
410 "RendererScheduler.policy", current_policy_); | 407 "RendererScheduler.policy", current_policy_); |
411 } | 408 } |
412 | 409 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 } | 497 } |
501 | 498 |
502 bool RendererSchedulerImpl::PollableNeedsUpdateFlag::IsSet() const { | 499 bool RendererSchedulerImpl::PollableNeedsUpdateFlag::IsSet() const { |
503 return base::subtle::Acquire_Load(&flag_) != 0; | 500 return base::subtle::Acquire_Load(&flag_) != 0; |
504 } | 501 } |
505 | 502 |
506 void RendererSchedulerImpl::SuspendTimerQueue() { | 503 void RendererSchedulerImpl::SuspendTimerQueue() { |
507 helper_.CheckOnValidThread(); | 504 helper_.CheckOnValidThread(); |
508 timer_queue_suspend_count_++; | 505 timer_queue_suspend_count_++; |
509 ForceUpdatePolicy(); | 506 ForceUpdatePolicy(); |
510 DCHECK( | 507 DCHECK(!helper_.IsQueueEnabled(TIMER_TASK_QUEUE)); |
511 !helper_.SchedulerTaskQueueSelector()->IsQueueEnabled(TIMER_TASK_QUEUE)); | |
512 } | 508 } |
513 | 509 |
514 void RendererSchedulerImpl::ResumeTimerQueue() { | 510 void RendererSchedulerImpl::ResumeTimerQueue() { |
515 helper_.CheckOnValidThread(); | 511 helper_.CheckOnValidThread(); |
516 timer_queue_suspend_count_--; | 512 timer_queue_suspend_count_--; |
517 DCHECK_GE(timer_queue_suspend_count_, 0); | 513 DCHECK_GE(timer_queue_suspend_count_, 0); |
518 ForceUpdatePolicy(); | 514 ForceUpdatePolicy(); |
519 } | 515 } |
520 | 516 |
521 // static | 517 // static |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 // meaningful touchstart response and should not impact task priority. | 620 // meaningful touchstart response and should not impact task priority. |
625 return current_state; | 621 return current_state; |
626 | 622 |
627 default: | 623 default: |
628 break; | 624 break; |
629 } | 625 } |
630 return InputStreamState::ACTIVE; | 626 return InputStreamState::ACTIVE; |
631 } | 627 } |
632 | 628 |
633 } // namespace scheduler | 629 } // namespace scheduler |
OLD | NEW |