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

Side by Side 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: Review comments Created 5 years, 9 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 unified diff | Download patch
OLDNEW
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 #ifndef CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ 5 #ifndef CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_
6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ 6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_
7 7
8 #include "base/atomicops.h" 8 #include "base/atomicops.h"
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "base/threading/thread_checker.h" 10 #include "base/threading/thread_checker.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 static const char* InputStreamStateToString(InputStreamState state); 104 static const char* InputStreamStateToString(InputStreamState state);
105 105
106 static InputStreamState ComputeNewInputStreamState( 106 static InputStreamState ComputeNewInputStreamState(
107 InputStreamState current_state, 107 InputStreamState current_state,
108 blink::WebInputEvent::Type new_input_event, 108 blink::WebInputEvent::Type new_input_event,
109 blink::WebInputEvent::Type last_input_event); 109 blink::WebInputEvent::Type last_input_event);
110 110
111 // The time we should stay in a priority-escalated mode after an input event. 111 // The time we should stay in a priority-escalated mode after an input event.
112 static const int kPriorityEscalationAfterInputMillis = 100; 112 static const int kPriorityEscalationAfterInputMillis = 100;
113 113
114 // The maximum length of an idle period.
115 static const int kMaximumIdlePeriodMillis = 50;
116
117 // The minimum delay to wait between retrying to initiate a long idle time.
118 static const int kRetryInitiateLongIdlePeriodDelayMillis = 1;
119
114 // IdleTaskDeadlineSupplier Implementation: 120 // IdleTaskDeadlineSupplier Implementation:
115 void CurrentIdleTaskDeadlineCallback(base::TimeTicks* deadline_out) const; 121 void CurrentIdleTaskDeadlineCallback(base::TimeTicks* deadline_out) const;
116 122
117 // Returns the current scheduler policy. Must be called from the main thread. 123 // Returns the current scheduler policy. Must be called from the main thread.
118 Policy SchedulerPolicy() const; 124 Policy SchedulerPolicy() const;
119 125
120 // Posts a call to UpdatePolicy on the control runner to be run after |delay| 126 // Posts a call to UpdatePolicy on the control runner to be run after |delay|
121 void PostUpdatePolicyOnControlRunner(base::TimeDelta delay); 127 void PostUpdatePolicyOnControlRunner(base::TimeDelta delay);
122 128
123 // Update the policy if a new signal has arrived. Must be called from the main 129 // Update the policy if a new signal has arrived. Must be called from the main
124 // thread. 130 // thread.
125 void MaybeUpdatePolicy(); 131 void MaybeUpdatePolicy();
126 132
127 // Updates the scheduler policy. Must be called from the main thread. 133 // Updates the scheduler policy. Must be called from the main thread.
128 void UpdatePolicy(); 134 void UpdatePolicy();
129 135
136 // Returns the amount of time left in the current input escalated priority
137 // policy.
138 base::TimeDelta TimeLeftInInputEscalatedPolicy() const;
139
130 // Helper for computing the new policy. |new_policy_duration| will be filled 140 // Helper for computing the new policy. |new_policy_duration| will be filled
131 // with the amount of time after which the policy should be updated again. If 141 // with the amount of time after which the policy should be updated again. If
132 // the duration is zero, a new policy update will not be scheduled. Must be 142 // the duration is zero, a new policy update will not be scheduled. Must be
133 // called with |incoming_signals_lock_| held. 143 // called with |incoming_signals_lock_| held.
134 Policy ComputeNewPolicy(base::TimeDelta* new_policy_duration); 144 Policy ComputeNewPolicy(base::TimeDelta* new_policy_duration);
135 145
136 // An input event of some sort happened, the policy may need updating. 146 // An input event of some sort happened, the policy may need updating.
137 void UpdateForInputEvent(blink::WebInputEvent::Type type); 147 void UpdateForInputEvent(blink::WebInputEvent::Type type);
138 148
139 // Called when a previously queued input event was processed. 149 // Called when a previously queued input event was processed.
140 // |begin_frame_time|, if non-zero, identifies the frame time at which the 150 // |begin_frame_time|, if non-zero, identifies the frame time at which the
141 // input was processed. 151 // input was processed.
142 void DidProcessInputEvent(base::TimeTicks begin_frame_time); 152 void DidProcessInputEvent(base::TimeTicks begin_frame_time);
143 153
154 // Returns true if we should initiate a long idle time now. Fills in
155 // |next_long_idle_period_delay_out| with the next time we should try to
156 // initiate the next idle period.
157 bool ShouldStartLongIdlePeriod(
158 const base::TimeTicks now,
159 base::TimeDelta* next_long_idle_period_delay_out);
160
161 // Initiate a long idle period.
162 void InitiateLongIdlePeriod();
163 void InitiateLongIdlePeriodAfterWakeup();
164
144 // Start and end an idle period. 165 // Start and end an idle period.
145 void StartIdlePeriod(); 166 void StartIdlePeriod();
146 void EndIdlePeriod(); 167 void EndIdlePeriod();
147 168
148 base::TimeTicks Now() const; 169 base::TimeTicks Now() const;
149 170
150 base::ThreadChecker main_thread_checker_; 171 base::ThreadChecker main_thread_checker_;
151 scoped_ptr<RendererTaskQueueSelector> renderer_task_queue_selector_; 172 scoped_ptr<RendererTaskQueueSelector> renderer_task_queue_selector_;
152 scoped_ptr<TaskQueueManager> task_queue_manager_; 173 scoped_ptr<TaskQueueManager> task_queue_manager_;
153 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; 174 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_;
154 scoped_refptr<base::SingleThreadTaskRunner> control_task_after_wakeup_runner_; 175 scoped_refptr<base::SingleThreadTaskRunner> control_task_after_wakeup_runner_;
155 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_; 176 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_;
156 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; 177 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
157 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_; 178 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_;
158 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_; 179 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_;
159 180
160 base::Closure update_policy_closure_; 181 base::Closure update_policy_closure_;
161 CancelableClosureHolder end_idle_period_closure_; 182 CancelableClosureHolder end_idle_period_closure_;
183 CancelableClosureHolder initiate_next_long_idle_period_closure_;
184 CancelableClosureHolder after_wakeup_initiate_next_long_idle_period_closure_;
Sami 2015/03/04 18:26:40 nit: swap the names around to match the function n
162 185
163 // Don't access current_policy_ directly, instead use SchedulerPolicy(). 186 // Don't access current_policy_ directly, instead use SchedulerPolicy().
164 Policy current_policy_; 187 Policy current_policy_;
188 bool in_idle_period_;
Sami 2015/03/04 18:26:40 Looks like this isn't initialized in the construct
rmcilroy 2015/03/05 11:48:52 Done and done.
165 189
166 base::TimeTicks estimated_next_frame_begin_; 190 base::TimeTicks estimated_next_frame_begin_;
191 base::TimeTicks current_policy_expiration_time_;
167 192
168 // The incoming_signals_lock_ mutex protects access to all variables in the 193 // The incoming_signals_lock_ mutex protects access to all variables in the
169 // (contiguous) block below. 194 // (contiguous) block below.
170 base::Lock incoming_signals_lock_; 195 base::Lock incoming_signals_lock_;
171 base::TimeTicks last_input_receipt_time_on_compositor_; 196 base::TimeTicks last_input_receipt_time_on_compositor_;
172 base::TimeTicks last_input_process_time_on_main_; 197 base::TimeTicks last_input_process_time_on_main_;
173 blink::WebInputEvent::Type last_input_type_; 198 blink::WebInputEvent::Type last_input_type_;
174 InputStreamState input_stream_state_; 199 InputStreamState input_stream_state_;
175 PollableNeedsUpdateFlag policy_may_need_update_; 200 PollableNeedsUpdateFlag policy_may_need_update_;
176 201
177 scoped_refptr<cc::TestNowSource> time_source_; 202 scoped_refptr<cc::TestNowSource> time_source_;
178 203
179 base::WeakPtr<RendererSchedulerImpl> weak_renderer_scheduler_ptr_; 204 base::WeakPtr<RendererSchedulerImpl> weak_renderer_scheduler_ptr_;
180 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; 205 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_;
181 206
182 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); 207 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl);
183 }; 208 };
184 209
185 } // namespace content 210 } // namespace content
186 211
187 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ 212 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698