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..d20a3b8cc1601b85b61d759a5978f56168cee72a 100644 |
--- a/components/scheduler/renderer/renderer_scheduler_impl.h |
+++ b/components/scheduler/renderer/renderer_scheduler_impl.h |
@@ -13,6 +13,7 @@ |
#include "components/scheduler/renderer/deadline_task_runner.h" |
#include "components/scheduler/renderer/renderer_scheduler.h" |
#include "components/scheduler/renderer/task_cost_estimator.h" |
+#include "components/scheduler/renderer/user_model.h" |
#include "components/scheduler/scheduler_export.h" |
namespace base { |
@@ -65,16 +66,18 @@ 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, |
- // Must be the last entry. |
- POLICY_COUNT, |
- FIRST_POLICY = NORMAL, |
+ struct Policy { |
+ Policy(); |
+ |
+ TaskQueue::QueuePriority compositor_queue_priority; |
+ 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,14 +113,10 @@ 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 bool ShouldPrioritizeInputEvent( |
const blink::WebInputEvent& web_input_event); |
- // The time we should stay in a priority-escalated mode after an input event. |
- static const int kPriorityEscalationAfterInputMillis = 100; |
- |
// 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; |
@@ -160,19 +159,26 @@ class SCHEDULER_EXPORT RendererSchedulerImpl : public RendererScheduler, |
virtual void UpdatePolicyLocked(UpdateType update_type); |
// Returns the amount of time left in the current input escalated priority |
- // policy. Can be called from any thread. |
+ // 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 |
+ // Tries to guess if a Touchstart is expected soon. Currently this is |
Sami
2015/08/27 15:15:59
nit: the second sentence is guaranteed to get out
alex clarke (OOO till 29th)
2015/09/03 10:34:25
Done.
|
+ // very simple, but one day I hope to do something more sophisticated here. |
+ bool TouchStartExpectedSoon(UseCase use_case, |
+ const base::TimeTicks now, |
+ base::TimeDelta* new_policy_duration) const; |
+ |
+ // Helper for computing the policy. |expected_usecase_duration| will be filled |
Sami
2015/08/27 15:15:59
s/policy/use case/
alex clarke (OOO till 29th)
2015/09/03 10:34:25
Done.
|
// 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( |
Sami
2015/08/27 15:15:59
Idle thought for the future: maybe the use case de
alex clarke (OOO till 29th)
2015/09/03 10:34:25
Acknowledged.
|
+ base::TimeTicks now, |
+ base::TimeDelta* expected_use_case_duration) const; |
- // 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; |
+ // Works out if a gesture appears to be in progress based on the current |
+ // input signals. Can be called from any thread. |
+ bool InputSignalsSuggestGestureInProgress(base::TimeTicks now) const; |
// An input event of some sort happened, the policy may need updating. |
void UpdateForInputEventOnCompositorThread(blink::WebInputEvent::Type type, |
@@ -201,44 +207,47 @@ class SCHEDULER_EXPORT RendererSchedulerImpl : public RendererScheduler, |
MainThreadOnly(); |
~MainThreadOnly(); |
- TaskCostEstimator timer_task_cost_estimator_; |
- cc::RollingTimeDeltaHistory short_idle_period_duration_; |
- Policy current_policy_; |
- base::TimeTicks current_policy_expiration_time_; |
- base::TimeTicks estimated_next_frame_begin_; |
- base::TimeDelta expected_short_idle_period_duration_; |
- int timer_queue_suspend_count_; // TIMER_TASK_QUEUE suspended if non-zero. |
- bool renderer_hidden_; |
- bool was_shutdown_; |
+ 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; |
+ base::TimeDelta expected_short_idle_period_duration; |
+ 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 touchstart_expected_soon; |
}; |
struct AnyThread { |
AnyThread(); |
- base::TimeTicks last_input_signal_time_; |
- base::TimeTicks last_idle_period_end_time_; |
- base::TimeTicks rails_loading_priority_deadline_; |
- 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_; |
+ base::TimeTicks last_idle_period_end_time; |
+ base::TimeTicks rails_loading_priority_deadline; |
+ UserModel user_model; |
+ bool awaiting_touch_start_response; |
+ bool in_idle_period; |
+ bool begin_main_frame_on_critical_path; |
}; |
struct CompositorThreadOnly { |
CompositorThreadOnly(); |
~CompositorThreadOnly(); |
- blink::WebInputEvent::Type last_input_type_; |
- scoped_ptr<base::ThreadChecker> compositor_thread_checker_; |
+ blink::WebInputEvent::Type last_input_type; |
+ scoped_ptr<base::ThreadChecker> compositor_thread_checker; |
void CheckOnValidThread() { |
#if DCHECK_IS_ON() |
// We don't actually care which thread this called from, just so long as |
// its consistent. |
- if (!compositor_thread_checker_) |
- compositor_thread_checker_.reset(new base::ThreadChecker()); |
- DCHECK(compositor_thread_checker_->CalledOnValidThread()); |
+ if (!compositor_thread_checker) |
+ compositor_thread_checker.reset(new base::ThreadChecker()); |
+ DCHECK(compositor_thread_checker->CalledOnValidThread()); |
#endif |
} |
}; |