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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 base::AutoLock lock(any_thread_lock_); | 834 base::AutoLock lock(any_thread_lock_); |
829 return AsValueLocked(optional_now); | 835 return AsValueLocked(optional_now); |
830 } | 836 } |
831 | 837 |
832 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 838 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
833 RendererSchedulerImpl::AsValueLocked(base::TimeTicks optional_now) const { | 839 RendererSchedulerImpl::AsValueLocked(base::TimeTicks optional_now) const { |
834 helper_.CheckOnValidThread(); | 840 helper_.CheckOnValidThread(); |
835 any_thread_lock_.AssertAcquired(); | 841 any_thread_lock_.AssertAcquired(); |
836 | 842 |
837 if (optional_now.is_null()) | 843 if (optional_now.is_null()) |
838 optional_now = helper_.Now(); | 844 optional_now = helper_.tick_clock()->NowTicks(); |
839 scoped_refptr<base::trace_event::TracedValue> state = | 845 scoped_refptr<base::trace_event::TracedValue> state = |
840 new base::trace_event::TracedValue(); | 846 new base::trace_event::TracedValue(); |
841 | 847 |
842 state->SetBoolean( | 848 state->SetBoolean( |
843 "has_visible_render_widget_with_touch_handler", | 849 "has_visible_render_widget_with_touch_handler", |
844 MainThreadOnly().has_visible_render_widget_with_touch_handler); | 850 MainThreadOnly().has_visible_render_widget_with_touch_handler); |
845 state->SetString("current_use_case", | 851 state->SetString("current_use_case", |
846 UseCaseToString(MainThreadOnly().current_use_case)); | 852 UseCaseToString(MainThreadOnly().current_use_case)); |
847 state->SetBoolean("loading_tasks_seem_expensive", | 853 state->SetBoolean("loading_tasks_seem_expensive", |
848 MainThreadOnly().loading_tasks_seem_expensive); | 854 MainThreadOnly().loading_tasks_seem_expensive); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 } | 906 } |
901 | 907 |
902 void RendererSchedulerImpl::OnIdlePeriodStarted() { | 908 void RendererSchedulerImpl::OnIdlePeriodStarted() { |
903 base::AutoLock lock(any_thread_lock_); | 909 base::AutoLock lock(any_thread_lock_); |
904 AnyThread().in_idle_period = true; | 910 AnyThread().in_idle_period = true; |
905 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); | 911 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); |
906 } | 912 } |
907 | 913 |
908 void RendererSchedulerImpl::OnIdlePeriodEnded() { | 914 void RendererSchedulerImpl::OnIdlePeriodEnded() { |
909 base::AutoLock lock(any_thread_lock_); | 915 base::AutoLock lock(any_thread_lock_); |
910 AnyThread().last_idle_period_end_time = helper_.Now(); | 916 AnyThread().last_idle_period_end_time = helper_.tick_clock()->NowTicks(); |
911 AnyThread().in_idle_period = false; | 917 AnyThread().in_idle_period = false; |
912 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); | 918 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); |
913 } | 919 } |
914 | 920 |
915 void RendererSchedulerImpl::AddPendingNavigation() { | 921 void RendererSchedulerImpl::AddPendingNavigation() { |
916 helper_.CheckOnValidThread(); | 922 helper_.CheckOnValidThread(); |
917 MainThreadOnly().navigation_task_expected_count++; | 923 MainThreadOnly().navigation_task_expected_count++; |
918 UpdatePolicy(); | 924 UpdatePolicy(); |
919 } | 925 } |
920 | 926 |
921 void RendererSchedulerImpl::RemovePendingNavigation() { | 927 void RendererSchedulerImpl::RemovePendingNavigation() { |
922 helper_.CheckOnValidThread(); | 928 helper_.CheckOnValidThread(); |
923 DCHECK_GT(MainThreadOnly().navigation_task_expected_count, 0); | 929 DCHECK_GT(MainThreadOnly().navigation_task_expected_count, 0); |
924 if (MainThreadOnly().navigation_task_expected_count > 0) | 930 if (MainThreadOnly().navigation_task_expected_count > 0) |
925 MainThreadOnly().navigation_task_expected_count--; | 931 MainThreadOnly().navigation_task_expected_count--; |
926 UpdatePolicy(); | 932 UpdatePolicy(); |
927 } | 933 } |
928 | 934 |
929 void RendererSchedulerImpl::OnNavigationStarted() { | 935 void RendererSchedulerImpl::OnNavigationStarted() { |
930 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 936 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
931 "RendererSchedulerImpl::OnNavigationStarted"); | 937 "RendererSchedulerImpl::OnNavigationStarted"); |
932 base::AutoLock lock(any_thread_lock_); | 938 base::AutoLock lock(any_thread_lock_); |
933 AnyThread().rails_loading_priority_deadline = | 939 AnyThread().rails_loading_priority_deadline = |
934 helper_.Now() + base::TimeDelta::FromMilliseconds( | 940 helper_.tick_clock()->NowTicks() + |
935 kRailsInitialLoadingPrioritizationMillis); | 941 base::TimeDelta::FromMilliseconds( |
| 942 kRailsInitialLoadingPrioritizationMillis); |
936 ResetForNavigationLocked(); | 943 ResetForNavigationLocked(); |
937 } | 944 } |
938 | 945 |
939 bool RendererSchedulerImpl::HadAnIdlePeriodRecently(base::TimeTicks now) const { | 946 bool RendererSchedulerImpl::HadAnIdlePeriodRecently(base::TimeTicks now) const { |
940 return (now - AnyThread().last_idle_period_end_time) <= | 947 return (now - AnyThread().last_idle_period_end_time) <= |
941 base::TimeDelta::FromMilliseconds( | 948 base::TimeDelta::FromMilliseconds( |
942 kIdlePeriodStarvationThresholdMillis); | 949 kIdlePeriodStarvationThresholdMillis); |
943 } | 950 } |
944 | 951 |
945 void RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded() { | 952 void RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded() { |
(...skipping 13 matching lines...) Expand all Loading... |
959 MainThreadOnly().timer_queue_suspended_when_backgrounded = false; | 966 MainThreadOnly().timer_queue_suspended_when_backgrounded = false; |
960 ForceUpdatePolicy(); | 967 ForceUpdatePolicy(); |
961 } | 968 } |
962 | 969 |
963 void RendererSchedulerImpl::ResetForNavigationLocked() { | 970 void RendererSchedulerImpl::ResetForNavigationLocked() { |
964 helper_.CheckOnValidThread(); | 971 helper_.CheckOnValidThread(); |
965 any_thread_lock_.AssertAcquired(); | 972 any_thread_lock_.AssertAcquired(); |
966 MainThreadOnly().loading_task_cost_estimator.Clear(); | 973 MainThreadOnly().loading_task_cost_estimator.Clear(); |
967 MainThreadOnly().timer_task_cost_estimator.Clear(); | 974 MainThreadOnly().timer_task_cost_estimator.Clear(); |
968 MainThreadOnly().idle_time_estimator.Clear(); | 975 MainThreadOnly().idle_time_estimator.Clear(); |
969 AnyThread().user_model.Reset(helper_.Now()); | 976 AnyThread().user_model.Reset(helper_.tick_clock()->NowTicks()); |
970 MainThreadOnly().have_seen_a_begin_main_frame = false; | 977 MainThreadOnly().have_seen_a_begin_main_frame = false; |
971 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); | 978 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); |
972 } | 979 } |
973 | 980 |
974 } // namespace scheduler | 981 } // namespace scheduler |
OLD | NEW |