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

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

Issue 968073003: [content]: Add support for long idle times in the Blink Scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@long_idle_4
Patch Set: Include IdlePeriodState changes and ENDING_IDLE_PERIOD state. Created 5 years, 10 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: content/renderer/scheduler/renderer_scheduler_impl.h
diff --git a/content/renderer/scheduler/renderer_scheduler_impl.h b/content/renderer/scheduler/renderer_scheduler_impl.h
index c908a974a0d8f21cf24f8cb34d36fc053a1d68c8..cd0701a079559fcc6750e6c74d809e08d5447e6f 100644
--- a/content/renderer/scheduler/renderer_scheduler_impl.h
+++ b/content/renderer/scheduler/renderer_scheduler_impl.h
@@ -66,18 +66,30 @@ class CONTENT_EXPORT RendererSchedulerImpl : public RendererScheduler {
TASK_QUEUE_COUNT,
};
+ // Keep RendererSchedulerImpl::PolicyToString in sync with this enum.
Sami 2015/03/05 16:22:32 Thanks for adding these reminders.
rmcilroy 2015/03/05 16:42:38 Acknowledged.
enum class Policy {
NORMAL,
COMPOSITOR_PRIORITY,
TOUCHSTART_PRIORITY,
};
+ // Keep RendererSchedulerImpl::InputStreamStateToString in sync with this
+ // enum.
enum class InputStreamState {
INACTIVE,
ACTIVE,
ACTIVE_AND_AWAITING_TOUCHSTART_RESPONSE
};
+ // Keep RendererSchedulerImpl::IdlePeriodStateToString in sync with this enum.
+ enum class IdlePeriodState {
+ NOT_IN_IDLE_PERIOD,
+ IN_SHORT_IDLE_PERIOD,
+ IN_LONG_IDLE_PERIOD,
+ IN_LONG_IDLE_WITH_MAX_DEADLINE_PERIOD,
Sami 2015/03/05 16:22:32 nit: IN_LONG_IDLE_PERIOD_WITH_MAX_DEADLINE reads a
rmcilroy 2015/03/05 16:42:38 Done.
+ ENDING_LONG_IDLE_PERIOD
+ };
+
class PollableNeedsUpdateFlag {
public:
PollableNeedsUpdateFlag(base::Lock* write_lock);
@@ -102,6 +114,7 @@ class CONTENT_EXPORT RendererSchedulerImpl : public RendererScheduler {
static const char* TaskQueueIdToString(QueueId queue_id);
static const char* PolicyToString(Policy policy);
static const char* InputStreamStateToString(InputStreamState state);
+ static const char* IdlePeriodStateToString(IdlePeriodState state);
static InputStreamState ComputeNewInputStreamState(
InputStreamState current_state,
@@ -111,6 +124,12 @@ class CONTENT_EXPORT RendererSchedulerImpl : public RendererScheduler {
// The time we should stay in a priority-escalated mode after an input event.
static const int kPriorityEscalationAfterInputMillis = 100;
+ // The maximum length of an idle period.
+ static const int kMaximumIdlePeriodMillis = 50;
+
+ // The minimum delay to wait between retrying to initiate a long idle time.
+ static const int kRetryInitiateLongIdlePeriodDelayMillis = 1;
+
// IdleTaskDeadlineSupplier Implementation:
void CurrentIdleTaskDeadlineCallback(base::TimeTicks* deadline_out) const;
@@ -127,6 +146,10 @@ class CONTENT_EXPORT RendererSchedulerImpl : public RendererScheduler {
// Updates the scheduler policy. Must be called from the main thread.
void UpdatePolicy();
+ // Returns the amount of time left in the current input escalated priority
+ // policy.
+ base::TimeDelta TimeLeftInInputEscalatedPolicy() 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
@@ -141,10 +164,24 @@ class CONTENT_EXPORT RendererSchedulerImpl : public RendererScheduler {
// input was processed.
void DidProcessInputEvent(base::TimeTicks begin_frame_time);
+ // Returns the new idle period state for the next long idle period. Fills in
+ // |next_long_idle_period_delay_out| with the next time we should try to
+ // initiate the next idle period.
+ IdlePeriodState ComputeNewLongIdlePeriodState(
+ const base::TimeTicks now,
+ base::TimeDelta* next_long_idle_period_delay_out);
+
+ // Initiate a long idle period.
+ void InitiateLongIdlePeriod();
+ void InitiateLongIdlePeriodAfterWakeup();
+
// Start and end an idle period.
- void StartIdlePeriod();
+ void StartIdlePeriod(IdlePeriodState new_idle_period_state);
void EndIdlePeriod();
+ // Returns true if |state| represents being within an idle period state.
+ static bool IsInIdlePeriod(IdlePeriodState state);
+
base::TimeTicks Now() const;
base::ThreadChecker main_thread_checker_;
@@ -159,11 +196,15 @@ class CONTENT_EXPORT RendererSchedulerImpl : public RendererScheduler {
base::Closure update_policy_closure_;
CancelableClosureHolder end_idle_period_closure_;
+ CancelableClosureHolder initiate_next_long_idle_period_closure_;
+ CancelableClosureHolder initiate_next_long_idle_period_after_wakeup_closure_;
// Don't access current_policy_ directly, instead use SchedulerPolicy().
Policy current_policy_;
+ IdlePeriodState idle_period_state_;
base::TimeTicks estimated_next_frame_begin_;
+ base::TimeTicks current_policy_expiration_time_;
// The incoming_signals_lock_ mutex protects access to all variables in the
// (contiguous) block below.

Powered by Google App Engine
This is Rietveld 408576698