Chromium Code Reviews| Index: components/scheduler/renderer/renderer_scheduler_impl.h |
| diff --git a/components/scheduler/renderer/renderer_scheduler_impl.h b/components/scheduler/renderer/renderer_scheduler_impl.h |
| index 14693460eba115a9d9d1438d7e528d1c0f75fb48..acc198cdf4b5ee61da3bde1e914d70eb32fedf74 100644 |
| --- a/components/scheduler/renderer/renderer_scheduler_impl.h |
| +++ b/components/scheduler/renderer/renderer_scheduler_impl.h |
| @@ -65,16 +65,30 @@ class SCHEDULER_EXPORT RendererSchedulerImpl : public RendererScheduler, |
| friend class RendererSchedulerImplTest; |
| friend class RendererSchedulerImplForTest; |
| - // Keep RendererSchedulerImpl::PolicyToString in sync with this enum. |
| - enum class Policy { |
| - NORMAL, |
| - COMPOSITOR_PRIORITY, |
| - COMPOSITOR_CRITICAL_PATH_PRIORITY, |
| - TOUCHSTART_PRIORITY, |
| - LOADING_PRIORITY, |
| + // Keep RendererSchedulerImpl::UseCaseToString in sync with this enum. |
| + enum class UseCase { |
| + NOT_SCROLLING, |
|
Sami
2015/08/26 13:38:02
I feel like scrolling as a term is too narrow sinc
alex clarke (OOO till 29th)
2015/08/27 12:02:51
As discussed offline I went with COMPOSITOR_GESTUR
|
| + COMPOSITOR_SCROLLING, |
| + MAINTHREAD_SCROLLING, |
|
Sami
2015/08/26 13:38:02
nit: MAIN_THREAD_SCROLLING
alex clarke (OOO till 29th)
2015/08/27 12:02:51
Acknowledged.
|
| + TOUCHSTART, |
| + LOADING, |
| // Must be the last entry. |
| - POLICY_COUNT, |
| - FIRST_POLICY = NORMAL, |
| + USE_CASE_COUNT, |
| + FIRST_USE_CASE = NOT_SCROLLING, |
| + }; |
| + |
| + struct Policy { |
| + Policy(); |
| + |
| + TaskQueue::QueuePriority compositor_queue_priority_; |
|
Sami
2015/08/26 13:38:02
Public struct members shouldn't have trailing unde
alex clarke (OOO till 29th)
2015/08/27 12:02:51
OK lets fix em. Or at least the ones in this clas
|
| + TaskQueue::QueuePriority loading_queue_priority_; |
| + TaskQueue::QueuePriority timer_queue_priority_; |
| + |
| + bool operator==(const Policy& other) const { |
| + return compositor_queue_priority_ == other.compositor_queue_priority_ && |
| + loading_queue_priority_ == other.loading_queue_priority_ && |
| + timer_queue_priority_ == other.timer_queue_priority_; |
| + } |
| }; |
| class PollableNeedsUpdateFlag { |
| @@ -110,7 +124,7 @@ class SCHEDULER_EXPORT RendererSchedulerImpl : public RendererScheduler, |
| base::TimeTicks optional_now) const; |
| scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsValueLocked( |
| base::TimeTicks optional_now) const; |
| - static const char* PolicyToString(Policy policy); |
| + static const char* UseCaseToString(UseCase use_case); |
| static bool ShouldPrioritizeInputEvent( |
| const blink::WebInputEvent& web_input_event); |
| @@ -118,6 +132,11 @@ class SCHEDULER_EXPORT RendererSchedulerImpl : public RendererScheduler, |
| // The time we should stay in a priority-escalated mode after an input event. |
| static const int kPriorityEscalationAfterInputMillis = 100; |
| + // We consider further input invents to be likely if the user has interacted |
| + // with the device in the past two seconds. |
| + // TODO(alexclarke): Get a real number based on actual data. |
| + static const int kExpectSubsequentInputMillis = 2000; |
| + |
| // The amount of time which idle periods can continue being scheduled when the |
| // renderer has been hidden, before going to sleep for good. |
| static const int kEndIdleWhenHiddenDelayMillis = 10000; |
| @@ -126,6 +145,9 @@ class SCHEDULER_EXPORT RendererSchedulerImpl : public RendererScheduler, |
| // other tasks during the initial page load. |
| static const int kRailsInitialLoadingPrioritizationMillis = 1000; |
| + // TODO(alexclarke): Get a real number on actual data. |
| + static const int kMinimumTypicalScrollDurationMillis = 500; |
| + |
| // For the purposes of deciding whether or not it's safe to turn timers and |
| // loading tasks on only in idle periods, we regard the system as being as |
| // being "idle period" starved if there hasn't been an idle period in the last |
| @@ -163,16 +185,16 @@ class SCHEDULER_EXPORT RendererSchedulerImpl : public RendererScheduler, |
| // policy. Can be called from any thread. |
| base::TimeDelta TimeLeftInInputEscalatedPolicy(base::TimeTicks now) const; |
| - // Helper for computing the new policy. |new_policy_duration| will be filled |
| + // Helper for computing the policy. |new_policy_duration| will be filled |
| // with the amount of time after which the policy should be updated again. If |
| // the duration is zero, a new policy update will not be scheduled. Must be |
| // called with |any_thread_lock_| held. Can be called from any thread. |
| - Policy ComputeNewPolicy(base::TimeTicks now, |
| - base::TimeDelta* new_policy_duration) const; |
| + UseCase ComputeCurrentUseCase(base::TimeTicks now, |
| + base::TimeDelta* new_policy_duration) const; |
|
Sami
2015/08/26 13:38:02
Should this now be the policy duration or the use
alex clarke (OOO till 29th)
2015/08/27 12:02:51
How about expected_use_case_duration?
|
| // Works out if compositor tasks would be prioritized based on the current |
| // input signals. Can be called from any thread. |
| - bool InputSignalsSuggestCompositorPriority(base::TimeTicks now) const; |
| + bool InputSignalsSuggestScrolling(base::TimeTicks now) const; |
|
Sami
2015/08/26 13:38:02
Suggest main thread scrolling?
alex clarke (OOO till 29th)
2015/08/27 12:02:51
This is used to avoid posting lots of policy updat
|
| // An input event of some sort happened, the policy may need updating. |
| void UpdateForInputEventOnCompositorThread(blink::WebInputEvent::Type type, |
| @@ -182,6 +204,12 @@ class SCHEDULER_EXPORT RendererSchedulerImpl : public RendererScheduler, |
| // |kIdlePeriodStarvationThresholdMillis|. |
| bool HadAnIdlePeriodRecently(base::TimeTicks now) const; |
| + // Tries to guess if the user is likely to happen soon. Currently this is |
| + // very simple, but one day I hope to do something more sophisticated here. |
| + bool ScrollExpectedSoon(UseCase use_case, |
|
Sami
2015/08/26 13:38:02
Could you split all the logic about predicting the
alex clarke (OOO till 29th)
2015/08/27 12:02:51
Done.
|
| + const base::TimeTicks now, |
| + base::TimeDelta* new_policy_duration) const; |
| + |
| SchedulerHelper helper_; |
| IdleHelper idle_helper_; |
| @@ -201,8 +229,10 @@ class SCHEDULER_EXPORT RendererSchedulerImpl : public RendererScheduler, |
| MainThreadOnly(); |
| ~MainThreadOnly(); |
| + TaskCostEstimator loading_task_cost_estimator_; |
| TaskCostEstimator timer_task_cost_estimator_; |
| cc::RollingTimeDeltaHistory short_idle_period_duration_; |
| + UseCase current_use_case_; |
| Policy current_policy_; |
| base::TimeTicks current_policy_expiration_time_; |
| base::TimeTicks estimated_next_frame_begin_; |
| @@ -210,6 +240,9 @@ class SCHEDULER_EXPORT RendererSchedulerImpl : public RendererScheduler, |
| int timer_queue_suspend_count_; // TIMER_TASK_QUEUE suspended if non-zero. |
| bool renderer_hidden_; |
| bool was_shutdown_; |
| + bool loading_tasks_seem_expensive_; |
| + bool timer_tasks_seem_expensive_; |
| + bool scroll_expected_soon_; |
| }; |
| struct AnyThread { |
| @@ -218,11 +251,11 @@ class SCHEDULER_EXPORT RendererSchedulerImpl : public RendererScheduler, |
| base::TimeTicks last_input_signal_time_; |
| base::TimeTicks last_idle_period_end_time_; |
| base::TimeTicks rails_loading_priority_deadline_; |
| + base::TimeTicks last_touchstart_time_; |
| int pending_main_thread_input_event_count_; |
| bool awaiting_touch_start_response_; |
| bool in_idle_period_; |
| bool begin_main_frame_on_critical_path_; |
| - bool timer_tasks_seem_expensive_; |
| }; |
| struct CompositorThreadOnly { |