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/debug/stack_trace.h" | 8 #include "base/debug/stack_trace.h" |
| 9 #include "base/logging.h" |
9 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
10 #include "base/trace_event/trace_event_argument.h" | 11 #include "base/trace_event/trace_event_argument.h" |
11 #include "cc/output/begin_frame_args.h" | 12 #include "cc/output/begin_frame_args.h" |
12 #include "components/scheduler/base/task_queue_impl.h" | 13 #include "components/scheduler/base/task_queue_impl.h" |
13 #include "components/scheduler/base/task_queue_selector.h" | 14 #include "components/scheduler/base/task_queue_selector.h" |
14 #include "components/scheduler/child/scheduler_task_runner_delegate.h" | 15 #include "components/scheduler/child/scheduler_tqm_delegate.h" |
15 | 16 |
16 namespace scheduler { | 17 namespace scheduler { |
17 namespace { | 18 namespace { |
18 // The run time of loading tasks is strongly bimodal. The vast majority are | 19 // The run time of loading tasks is strongly bimodal. The vast majority are |
19 // very cheap, but there are usually a handful of very expensive tasks (e.g ~1 | 20 // very cheap, but there are usually a handful of very expensive tasks (e.g ~1 |
20 // second on a mobile device) so we take a very pesimistic view when estimating | 21 // second on a mobile device) so we take a very pesimistic view when estimating |
21 // the cost of loading tasks. | 22 // the cost of loading tasks. |
22 const int kLoadingTaskEstimationSampleCount = 1000; | 23 const int kLoadingTaskEstimationSampleCount = 1000; |
23 const double kLoadingTaskEstimationPercentile = 98; | 24 const double kLoadingTaskEstimationPercentile = 98; |
24 const int kTimerTaskEstimationSampleCount = 200; | 25 const int kTimerTaskEstimationSampleCount = 200; |
25 const double kTimerTaskEstimationPercentile = 90; | 26 const double kTimerTaskEstimationPercentile = 90; |
26 const int kShortIdlePeriodDurationSampleCount = 10; | 27 const int kShortIdlePeriodDurationSampleCount = 10; |
27 const double kShortIdlePeriodDurationPercentile = 50; | 28 const double kShortIdlePeriodDurationPercentile = 50; |
28 } | 29 } |
29 | 30 |
30 RendererSchedulerImpl::RendererSchedulerImpl( | 31 RendererSchedulerImpl::RendererSchedulerImpl( |
31 scoped_refptr<SchedulerTaskRunnerDelegate> main_task_runner) | 32 scoped_refptr<SchedulerTqmDelegate> main_task_runner) |
32 : helper_(main_task_runner, | 33 : helper_(main_task_runner, |
33 "renderer.scheduler", | 34 "renderer.scheduler", |
34 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 35 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
35 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler.debug")), | 36 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler.debug")), |
36 idle_helper_(&helper_, | 37 idle_helper_(&helper_, |
37 this, | 38 this, |
38 "renderer.scheduler", | 39 "renderer.scheduler", |
39 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 40 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
40 "RendererSchedulerIdlePeriod", | 41 "RendererSchedulerIdlePeriod", |
41 base::TimeDelta()), | 42 base::TimeDelta()), |
42 render_widget_scheduler_signals_(this), | 43 render_widget_scheduler_signals_(this), |
43 control_task_runner_(helper_.ControlTaskRunner()), | 44 control_task_runner_(helper_.ControlTaskRunner()), |
44 compositor_task_runner_( | 45 compositor_task_runner_( |
45 helper_.NewTaskQueue(TaskQueue::Spec("compositor_tq") | 46 helper_.NewTaskQueue(TaskQueue::Spec("compositor_tq") |
46 .SetShouldMonitorQuiescence(true))), | 47 .SetShouldMonitorQuiescence(true))), |
47 delayed_update_policy_runner_( | 48 delayed_update_policy_runner_( |
48 base::Bind(&RendererSchedulerImpl::UpdatePolicy, | 49 base::Bind(&RendererSchedulerImpl::UpdatePolicy, |
49 base::Unretained(this)), | 50 base::Unretained(this)), |
50 helper_.ControlTaskRunner()), | 51 helper_.ControlTaskRunner()), |
51 main_thread_only_(compositor_task_runner_), | 52 main_thread_only_(compositor_task_runner_, helper_.tick_clock()), |
52 policy_may_need_update_(&any_thread_lock_), | 53 policy_may_need_update_(&any_thread_lock_), |
53 weak_factory_(this) { | 54 weak_factory_(this) { |
54 update_policy_closure_ = base::Bind(&RendererSchedulerImpl::UpdatePolicy, | 55 update_policy_closure_ = base::Bind(&RendererSchedulerImpl::UpdatePolicy, |
55 weak_factory_.GetWeakPtr()); | 56 weak_factory_.GetWeakPtr()); |
56 end_renderer_hidden_idle_period_closure_.Reset(base::Bind( | 57 end_renderer_hidden_idle_period_closure_.Reset(base::Bind( |
57 &RendererSchedulerImpl::EndIdlePeriod, weak_factory_.GetWeakPtr())); | 58 &RendererSchedulerImpl::EndIdlePeriod, weak_factory_.GetWeakPtr())); |
58 | 59 |
59 suspend_timers_when_backgrounded_closure_.Reset( | 60 suspend_timers_when_backgrounded_closure_.Reset( |
60 base::Bind(&RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded, | 61 base::Bind(&RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded, |
61 weak_factory_.GetWeakPtr())); | 62 weak_factory_.GetWeakPtr())); |
(...skipping 28 matching lines...) Expand all Loading... |
90 DCHECK(MainThreadOnly().was_shutdown); | 91 DCHECK(MainThreadOnly().was_shutdown); |
91 } | 92 } |
92 | 93 |
93 RendererSchedulerImpl::Policy::Policy() | 94 RendererSchedulerImpl::Policy::Policy() |
94 : compositor_queue_priority(TaskQueue::NORMAL_PRIORITY), | 95 : compositor_queue_priority(TaskQueue::NORMAL_PRIORITY), |
95 loading_queue_priority(TaskQueue::NORMAL_PRIORITY), | 96 loading_queue_priority(TaskQueue::NORMAL_PRIORITY), |
96 timer_queue_priority(TaskQueue::NORMAL_PRIORITY), | 97 timer_queue_priority(TaskQueue::NORMAL_PRIORITY), |
97 default_queue_priority(TaskQueue::NORMAL_PRIORITY) {} | 98 default_queue_priority(TaskQueue::NORMAL_PRIORITY) {} |
98 | 99 |
99 RendererSchedulerImpl::MainThreadOnly::MainThreadOnly( | 100 RendererSchedulerImpl::MainThreadOnly::MainThreadOnly( |
100 const scoped_refptr<TaskQueue>& compositor_task_runner) | 101 const scoped_refptr<TaskQueue>& compositor_task_runner, |
101 : loading_task_cost_estimator(kLoadingTaskEstimationSampleCount, | 102 base::TickClock* time_source) |
| 103 : loading_task_cost_estimator(time_source, |
| 104 kLoadingTaskEstimationSampleCount, |
102 kLoadingTaskEstimationPercentile), | 105 kLoadingTaskEstimationPercentile), |
103 timer_task_cost_estimator(kTimerTaskEstimationSampleCount, | 106 timer_task_cost_estimator(time_source, |
| 107 kTimerTaskEstimationSampleCount, |
104 kTimerTaskEstimationPercentile), | 108 kTimerTaskEstimationPercentile), |
105 idle_time_estimator(compositor_task_runner, | 109 idle_time_estimator(compositor_task_runner, |
| 110 time_source, |
106 kShortIdlePeriodDurationSampleCount, | 111 kShortIdlePeriodDurationSampleCount, |
107 kShortIdlePeriodDurationPercentile), | 112 kShortIdlePeriodDurationPercentile), |
108 current_use_case(UseCase::NONE), | 113 current_use_case(UseCase::NONE), |
109 timer_queue_suspend_count(0), | 114 timer_queue_suspend_count(0), |
110 navigation_task_expected_count(0), | 115 navigation_task_expected_count(0), |
111 renderer_hidden(false), | 116 renderer_hidden(false), |
112 renderer_backgrounded(false), | 117 renderer_backgrounded(false), |
113 timer_queue_suspension_when_backgrounded_enabled(false), | 118 timer_queue_suspension_when_backgrounded_enabled(false), |
114 timer_queue_suspended_when_backgrounded(false), | 119 timer_queue_suspended_when_backgrounded(false), |
115 was_shutdown(false), | 120 was_shutdown(false), |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 243 } |
239 } | 244 } |
240 | 245 |
241 void RendererSchedulerImpl::DidCommitFrameToCompositor() { | 246 void RendererSchedulerImpl::DidCommitFrameToCompositor() { |
242 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 247 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
243 "RendererSchedulerImpl::DidCommitFrameToCompositor"); | 248 "RendererSchedulerImpl::DidCommitFrameToCompositor"); |
244 helper_.CheckOnValidThread(); | 249 helper_.CheckOnValidThread(); |
245 if (helper_.IsShutdown()) | 250 if (helper_.IsShutdown()) |
246 return; | 251 return; |
247 | 252 |
248 base::TimeTicks now(helper_.Now()); | 253 base::TimeTicks now(helper_.tick_clock()->NowTicks()); |
249 if (now < MainThreadOnly().estimated_next_frame_begin) { | 254 if (now < MainThreadOnly().estimated_next_frame_begin) { |
250 // TODO(rmcilroy): Consider reducing the idle period based on the runtime of | 255 // TODO(rmcilroy): Consider reducing the idle period based on the runtime of |
251 // the next pending delayed tasks (as currently done in for long idle times) | 256 // the next pending delayed tasks (as currently done in for long idle times) |
252 idle_helper_.StartIdlePeriod( | 257 idle_helper_.StartIdlePeriod( |
253 IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, now, | 258 IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, now, |
254 MainThreadOnly().estimated_next_frame_begin); | 259 MainThreadOnly().estimated_next_frame_begin); |
255 } | 260 } |
256 | 261 |
257 MainThreadOnly().idle_time_estimator.DidCommitFrameToCompositor(); | 262 MainThreadOnly().idle_time_estimator.DidCommitFrameToCompositor(); |
258 } | 263 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 end_idle_when_hidden_delay); | 300 end_idle_when_hidden_delay); |
296 MainThreadOnly().renderer_hidden = true; | 301 MainThreadOnly().renderer_hidden = true; |
297 } else { | 302 } else { |
298 MainThreadOnly().renderer_hidden = false; | 303 MainThreadOnly().renderer_hidden = false; |
299 EndIdlePeriod(); | 304 EndIdlePeriod(); |
300 } | 305 } |
301 | 306 |
302 // TODO(alexclarke): Should we update policy here? | 307 // TODO(alexclarke): Should we update policy here? |
303 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 308 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
304 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", | 309 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", |
305 this, AsValue(helper_.Now())); | 310 this, AsValue(helper_.tick_clock()->NowTicks())); |
306 } | 311 } |
307 | 312 |
308 void RendererSchedulerImpl::SetHasVisibleRenderWidgetWithTouchHandler( | 313 void RendererSchedulerImpl::SetHasVisibleRenderWidgetWithTouchHandler( |
309 bool has_visible_render_widget_with_touch_handler) { | 314 bool has_visible_render_widget_with_touch_handler) { |
310 helper_.CheckOnValidThread(); | 315 helper_.CheckOnValidThread(); |
311 if (has_visible_render_widget_with_touch_handler == | 316 if (has_visible_render_widget_with_touch_handler == |
312 MainThreadOnly().has_visible_render_widget_with_touch_handler) | 317 MainThreadOnly().has_visible_render_widget_with_touch_handler) |
313 return; | 318 return; |
314 | 319 |
315 MainThreadOnly().has_visible_render_widget_with_touch_handler = | 320 MainThreadOnly().has_visible_render_widget_with_touch_handler = |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 "RendererSchedulerImpl::DidAnimateForInputOnCompositorThread"); | 400 "RendererSchedulerImpl::DidAnimateForInputOnCompositorThread"); |
396 UpdateForInputEventOnCompositorThread( | 401 UpdateForInputEventOnCompositorThread( |
397 blink::WebInputEvent::Undefined, | 402 blink::WebInputEvent::Undefined, |
398 InputEventState::EVENT_CONSUMED_BY_COMPOSITOR); | 403 InputEventState::EVENT_CONSUMED_BY_COMPOSITOR); |
399 } | 404 } |
400 | 405 |
401 void RendererSchedulerImpl::UpdateForInputEventOnCompositorThread( | 406 void RendererSchedulerImpl::UpdateForInputEventOnCompositorThread( |
402 blink::WebInputEvent::Type type, | 407 blink::WebInputEvent::Type type, |
403 InputEventState input_event_state) { | 408 InputEventState input_event_state) { |
404 base::AutoLock lock(any_thread_lock_); | 409 base::AutoLock lock(any_thread_lock_); |
405 base::TimeTicks now = helper_.Now(); | 410 base::TimeTicks now = helper_.tick_clock()->NowTicks(); |
406 | 411 |
407 // TODO(alexclarke): Move WebInputEventTraits where we can access it from here | 412 // TODO(alexclarke): Move WebInputEventTraits where we can access it from here |
408 // and record the name rather than the integer representation. | 413 // and record the name rather than the integer representation. |
409 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 414 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
410 "RendererSchedulerImpl::UpdateForInputEventOnCompositorThread", | 415 "RendererSchedulerImpl::UpdateForInputEventOnCompositorThread", |
411 "type", static_cast<int>(type), "input_event_state", | 416 "type", static_cast<int>(type), "input_event_state", |
412 InputEventStateToString(input_event_state)); | 417 InputEventStateToString(input_event_state)); |
413 | 418 |
414 bool gesture_already_in_progress = InputSignalsSuggestGestureInProgress(now); | 419 bool gesture_already_in_progress = InputSignalsSuggestGestureInProgress(now); |
415 bool was_awaiting_touch_start_response = | 420 bool was_awaiting_touch_start_response = |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 CompositorThreadOnly().last_input_type = type; | 468 CompositorThreadOnly().last_input_type = type; |
464 } | 469 } |
465 | 470 |
466 void RendererSchedulerImpl::DidHandleInputEventOnMainThread( | 471 void RendererSchedulerImpl::DidHandleInputEventOnMainThread( |
467 const blink::WebInputEvent& web_input_event) { | 472 const blink::WebInputEvent& web_input_event) { |
468 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 473 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
469 "RendererSchedulerImpl::DidHandleInputEventOnMainThread"); | 474 "RendererSchedulerImpl::DidHandleInputEventOnMainThread"); |
470 helper_.CheckOnValidThread(); | 475 helper_.CheckOnValidThread(); |
471 if (ShouldPrioritizeInputEvent(web_input_event)) { | 476 if (ShouldPrioritizeInputEvent(web_input_event)) { |
472 base::AutoLock lock(any_thread_lock_); | 477 base::AutoLock lock(any_thread_lock_); |
473 AnyThread().user_model.DidFinishProcessingInputEvent(helper_.Now()); | 478 AnyThread().user_model.DidFinishProcessingInputEvent( |
| 479 helper_.tick_clock()->NowTicks()); |
474 } | 480 } |
475 } | 481 } |
476 | 482 |
477 bool RendererSchedulerImpl::IsHighPriorityWorkAnticipated() { | 483 bool RendererSchedulerImpl::IsHighPriorityWorkAnticipated() { |
478 helper_.CheckOnValidThread(); | 484 helper_.CheckOnValidThread(); |
479 if (helper_.IsShutdown()) | 485 if (helper_.IsShutdown()) |
480 return false; | 486 return false; |
481 | 487 |
482 MaybeUpdatePolicy(); | 488 MaybeUpdatePolicy(); |
483 // The touchstart and main-thread gesture use cases indicate a strong | 489 // The touchstart and main-thread gesture use cases indicate a strong |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 base::AutoLock lock(any_thread_lock_); | 560 base::AutoLock lock(any_thread_lock_); |
555 UpdatePolicyLocked(UpdateType::FORCE_UPDATE); | 561 UpdatePolicyLocked(UpdateType::FORCE_UPDATE); |
556 } | 562 } |
557 | 563 |
558 void RendererSchedulerImpl::UpdatePolicyLocked(UpdateType update_type) { | 564 void RendererSchedulerImpl::UpdatePolicyLocked(UpdateType update_type) { |
559 helper_.CheckOnValidThread(); | 565 helper_.CheckOnValidThread(); |
560 any_thread_lock_.AssertAcquired(); | 566 any_thread_lock_.AssertAcquired(); |
561 if (helper_.IsShutdown()) | 567 if (helper_.IsShutdown()) |
562 return; | 568 return; |
563 | 569 |
564 base::TimeTicks now = helper_.Now(); | 570 base::TimeTicks now = helper_.tick_clock()->NowTicks(); |
565 policy_may_need_update_.SetWhileLocked(false); | 571 policy_may_need_update_.SetWhileLocked(false); |
566 | 572 |
567 base::TimeDelta expected_use_case_duration; | 573 base::TimeDelta expected_use_case_duration; |
568 UseCase use_case = ComputeCurrentUseCase(now, &expected_use_case_duration); | 574 UseCase use_case = ComputeCurrentUseCase(now, &expected_use_case_duration); |
569 MainThreadOnly().current_use_case = use_case; | 575 MainThreadOnly().current_use_case = use_case; |
570 | 576 |
571 base::TimeDelta touchstart_expected_flag_valid_for_duration; | 577 base::TimeDelta touchstart_expected_flag_valid_for_duration; |
572 bool touchstart_expected_soon = false; | 578 bool touchstart_expected_soon = false; |
573 if (MainThreadOnly().has_visible_render_widget_with_touch_handler) { | 579 if (MainThreadOnly().has_visible_render_widget_with_touch_handler) { |
574 touchstart_expected_soon = AnyThread().user_model.IsGestureExpectedSoon( | 580 touchstart_expected_soon = AnyThread().user_model.IsGestureExpectedSoon( |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 base::AutoLock lock(any_thread_lock_); | 819 base::AutoLock lock(any_thread_lock_); |
814 return AsValueLocked(optional_now); | 820 return AsValueLocked(optional_now); |
815 } | 821 } |
816 | 822 |
817 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 823 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
818 RendererSchedulerImpl::AsValueLocked(base::TimeTicks optional_now) const { | 824 RendererSchedulerImpl::AsValueLocked(base::TimeTicks optional_now) const { |
819 helper_.CheckOnValidThread(); | 825 helper_.CheckOnValidThread(); |
820 any_thread_lock_.AssertAcquired(); | 826 any_thread_lock_.AssertAcquired(); |
821 | 827 |
822 if (optional_now.is_null()) | 828 if (optional_now.is_null()) |
823 optional_now = helper_.Now(); | 829 optional_now = helper_.tick_clock()->NowTicks(); |
824 scoped_refptr<base::trace_event::TracedValue> state = | 830 scoped_refptr<base::trace_event::TracedValue> state = |
825 new base::trace_event::TracedValue(); | 831 new base::trace_event::TracedValue(); |
826 | 832 |
827 state->SetBoolean( | 833 state->SetBoolean( |
828 "has_visible_render_widget_with_touch_handler", | 834 "has_visible_render_widget_with_touch_handler", |
829 MainThreadOnly().has_visible_render_widget_with_touch_handler); | 835 MainThreadOnly().has_visible_render_widget_with_touch_handler); |
830 state->SetString("current_use_case", | 836 state->SetString("current_use_case", |
831 UseCaseToString(MainThreadOnly().current_use_case)); | 837 UseCaseToString(MainThreadOnly().current_use_case)); |
832 state->SetBoolean("loading_tasks_seem_expensive", | 838 state->SetBoolean("loading_tasks_seem_expensive", |
833 MainThreadOnly().loading_tasks_seem_expensive); | 839 MainThreadOnly().loading_tasks_seem_expensive); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 } | 891 } |
886 | 892 |
887 void RendererSchedulerImpl::OnIdlePeriodStarted() { | 893 void RendererSchedulerImpl::OnIdlePeriodStarted() { |
888 base::AutoLock lock(any_thread_lock_); | 894 base::AutoLock lock(any_thread_lock_); |
889 AnyThread().in_idle_period = true; | 895 AnyThread().in_idle_period = true; |
890 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); | 896 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); |
891 } | 897 } |
892 | 898 |
893 void RendererSchedulerImpl::OnIdlePeriodEnded() { | 899 void RendererSchedulerImpl::OnIdlePeriodEnded() { |
894 base::AutoLock lock(any_thread_lock_); | 900 base::AutoLock lock(any_thread_lock_); |
895 AnyThread().last_idle_period_end_time = helper_.Now(); | 901 AnyThread().last_idle_period_end_time = helper_.tick_clock()->NowTicks(); |
896 AnyThread().in_idle_period = false; | 902 AnyThread().in_idle_period = false; |
897 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); | 903 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); |
898 } | 904 } |
899 | 905 |
900 void RendererSchedulerImpl::AddPendingNavigation() { | 906 void RendererSchedulerImpl::AddPendingNavigation() { |
901 helper_.CheckOnValidThread(); | 907 helper_.CheckOnValidThread(); |
902 MainThreadOnly().navigation_task_expected_count++; | 908 MainThreadOnly().navigation_task_expected_count++; |
903 UpdatePolicy(); | 909 UpdatePolicy(); |
904 } | 910 } |
905 | 911 |
906 void RendererSchedulerImpl::RemovePendingNavigation() { | 912 void RendererSchedulerImpl::RemovePendingNavigation() { |
907 helper_.CheckOnValidThread(); | 913 helper_.CheckOnValidThread(); |
908 DCHECK_GT(MainThreadOnly().navigation_task_expected_count, 0); | 914 DCHECK_GT(MainThreadOnly().navigation_task_expected_count, 0); |
909 if (MainThreadOnly().navigation_task_expected_count > 0) | 915 if (MainThreadOnly().navigation_task_expected_count > 0) |
910 MainThreadOnly().navigation_task_expected_count--; | 916 MainThreadOnly().navigation_task_expected_count--; |
911 UpdatePolicy(); | 917 UpdatePolicy(); |
912 } | 918 } |
913 | 919 |
914 void RendererSchedulerImpl::OnNavigationStarted() { | 920 void RendererSchedulerImpl::OnNavigationStarted() { |
915 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 921 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
916 "RendererSchedulerImpl::OnNavigationStarted"); | 922 "RendererSchedulerImpl::OnNavigationStarted"); |
917 base::AutoLock lock(any_thread_lock_); | 923 base::AutoLock lock(any_thread_lock_); |
918 AnyThread().rails_loading_priority_deadline = | 924 AnyThread().rails_loading_priority_deadline = |
919 helper_.Now() + base::TimeDelta::FromMilliseconds( | 925 helper_.tick_clock()->NowTicks() + |
920 kRailsInitialLoadingPrioritizationMillis); | 926 base::TimeDelta::FromMilliseconds( |
| 927 kRailsInitialLoadingPrioritizationMillis); |
921 ResetForNavigationLocked(); | 928 ResetForNavigationLocked(); |
922 } | 929 } |
923 | 930 |
924 bool RendererSchedulerImpl::HadAnIdlePeriodRecently(base::TimeTicks now) const { | 931 bool RendererSchedulerImpl::HadAnIdlePeriodRecently(base::TimeTicks now) const { |
925 return (now - AnyThread().last_idle_period_end_time) <= | 932 return (now - AnyThread().last_idle_period_end_time) <= |
926 base::TimeDelta::FromMilliseconds( | 933 base::TimeDelta::FromMilliseconds( |
927 kIdlePeriodStarvationThresholdMillis); | 934 kIdlePeriodStarvationThresholdMillis); |
928 } | 935 } |
929 | 936 |
930 void RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded() { | 937 void RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded() { |
(...skipping 13 matching lines...) Expand all Loading... |
944 MainThreadOnly().timer_queue_suspended_when_backgrounded = false; | 951 MainThreadOnly().timer_queue_suspended_when_backgrounded = false; |
945 ForceUpdatePolicy(); | 952 ForceUpdatePolicy(); |
946 } | 953 } |
947 | 954 |
948 void RendererSchedulerImpl::ResetForNavigationLocked() { | 955 void RendererSchedulerImpl::ResetForNavigationLocked() { |
949 helper_.CheckOnValidThread(); | 956 helper_.CheckOnValidThread(); |
950 any_thread_lock_.AssertAcquired(); | 957 any_thread_lock_.AssertAcquired(); |
951 MainThreadOnly().loading_task_cost_estimator.Clear(); | 958 MainThreadOnly().loading_task_cost_estimator.Clear(); |
952 MainThreadOnly().timer_task_cost_estimator.Clear(); | 959 MainThreadOnly().timer_task_cost_estimator.Clear(); |
953 MainThreadOnly().idle_time_estimator.Clear(); | 960 MainThreadOnly().idle_time_estimator.Clear(); |
954 AnyThread().user_model.Reset(helper_.Now()); | 961 AnyThread().user_model.Reset(helper_.tick_clock()->NowTicks()); |
955 MainThreadOnly().have_seen_a_begin_main_frame = false; | 962 MainThreadOnly().have_seen_a_begin_main_frame = false; |
956 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); | 963 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); |
957 } | 964 } |
958 | 965 |
959 } // namespace scheduler | 966 } // namespace scheduler |
OLD | NEW |