Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(929)

Unified Diff: components/scheduler/renderer/renderer_scheduler_impl.h

Issue 1337993002: Revert of Optimize for TouchStart responsiveness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 11431c3283bc1d4057a88a5c94f498bc810ad5ef..1898ca81bd8826a4762a350f4bcd127c8f5b6856 100644
--- a/components/scheduler/renderer/renderer_scheduler_impl.h
+++ b/components/scheduler/renderer/renderer_scheduler_impl.h
@@ -13,7 +13,6 @@
#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 {
@@ -69,20 +68,16 @@
friend class RendererSchedulerImplTest;
friend class RendererSchedulerImplForTest;
- struct Policy {
- Policy();
-
- TaskQueue::QueuePriority compositor_queue_priority;
- TaskQueue::QueuePriority loading_queue_priority;
- TaskQueue::QueuePriority timer_queue_priority;
- TaskQueue::QueuePriority default_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 &&
- default_queue_priority == other.default_queue_priority;
- }
+ // 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,
};
class PollableNeedsUpdateFlag {
@@ -118,9 +113,13 @@
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.
@@ -138,7 +137,7 @@
static const int kIdlePeriodStarvationThresholdMillis = 10000;
// The amount of time to wait before suspending shared timers after the
- // renderer has been backgrounded. This is used only if background suspension
+ // renderer has been backgrounded. This is use donly if background suspension
// of shared timers is enabled.
static const int kSuspendTimersWhenBackgroundedDelayMillis = 5 * 60 * 1000;
@@ -168,18 +167,20 @@
// early out if |update_type| is MAY_EARLY_OUT_IF_POLICY_UNCHANGED.
virtual void UpdatePolicyLocked(UpdateType update_type);
- // Helper for computing the use case. |expected_usecase_duration| will be
- // filled with the amount of time after which the use case should be updated
- // again. If the duration is zero, a new use case update should not be
- // scheduled. Must be called with |any_thread_lock_| held. Can be called from
- // any thread.
- UseCase ComputeCurrentUseCase(
- base::TimeTicks now,
- base::TimeDelta* expected_use_case_duration) 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;
+ // Returns the amount of time left in the current input escalated priority
+ // 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
+ // 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;
+
+ // 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;
// An input event of some sort happened, the policy may need updating.
void UpdateForInputEventOnCompositorThread(blink::WebInputEvent::Type type,
@@ -194,10 +195,6 @@
void SuspendTimerQueueWhenBackgrounded();
void ResumeTimerQueueWhenForegrounded();
- // The task cost estimators and the UserModel need to be reset upon page
- // nagigation. This function does that. Must be called from the main thread.
- void ResetForNavigationLocked();
-
SchedulerHelper helper_;
IdleHelper idle_helper_;
@@ -218,51 +215,47 @@
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;
- base::TimeDelta expected_short_idle_period_duration;
- int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero.
- bool renderer_hidden;
- bool renderer_backgrounded;
- bool timer_queue_suspension_when_backgrounded_enabled;
- bool timer_queue_suspended_when_backgrounded;
- bool was_shutdown;
- bool loading_tasks_seem_expensive;
- bool timer_tasks_seem_expensive;
- bool touchstart_expected_soon;
- bool have_seen_a_begin_main_frame;
+ 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 renderer_backgrounded_;
+ bool timer_queue_suspension_when_backgrounded_enabled_;
+ bool timer_queue_suspended_when_backgrounded_;
+ bool was_shutdown_;
};
struct AnyThread {
AnyThread();
- 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;
+ 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_;
};
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
}
};
« no previous file with comments | « components/scheduler/renderer/renderer_scheduler.cc ('k') | components/scheduler/renderer/renderer_scheduler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698