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

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: Minor tweaks 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
114 // IdleTaskDeadlineSupplier Implementation: 117 // IdleTaskDeadlineSupplier Implementation:
115 void CurrentIdleTaskDeadlineCallback(base::TimeTicks* deadline_out) const; 118 void CurrentIdleTaskDeadlineCallback(base::TimeTicks* deadline_out) const;
116 119
117 // Returns the current scheduler policy. Must be called from the main thread. 120 // Returns the current scheduler policy. Must be called from the main thread.
118 Policy SchedulerPolicy() const; 121 Policy SchedulerPolicy() const;
119 122
120 // Posts a call to UpdatePolicy on the control runner to be run after |delay| 123 // Posts a call to UpdatePolicy on the control runner to be run after |delay|
121 void PostUpdatePolicyOnControlRunner(base::TimeDelta delay); 124 void PostUpdatePolicyOnControlRunner(base::TimeDelta delay);
122 125
123 // Update the policy if a new signal has arrived. Must be called from the main 126 // Update the policy if a new signal has arrived. Must be called from the main
124 // thread. 127 // thread.
125 void MaybeUpdatePolicy(); 128 void MaybeUpdatePolicy();
126 129
127 // Updates the scheduler policy. Must be called from the main thread. 130 // Updates the scheduler policy. Must be called from the main thread.
128 void UpdatePolicy(); 131 void UpdatePolicy();
129 132
133 // Returns the amount of time left in the current input escalated priority
134 // policy.
135 base::TimeDelta TimeLeftInInputEscalatedPolicy();
Sami 2015/03/03 16:55:36 Can this be const?
rmcilroy 2015/03/04 14:23:12 Yes - done.
136
130 // Helper for computing the new policy. |new_policy_duration| will be filled 137 // 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 138 // 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 139 // the duration is zero, a new policy update will not be scheduled. Must be
133 // called with |incoming_signals_lock_| held. 140 // called with |incoming_signals_lock_| held.
134 Policy ComputeNewPolicy(base::TimeDelta* new_policy_duration); 141 Policy ComputeNewPolicy(base::TimeDelta* new_policy_duration);
135 142
136 // An input event of some sort happened, the policy may need updating. 143 // An input event of some sort happened, the policy may need updating.
137 void UpdateForInputEvent(blink::WebInputEvent::Type type); 144 void UpdateForInputEvent(blink::WebInputEvent::Type type);
138 145
139 // Called when a previously queued input event was processed. 146 // Called when a previously queued input event was processed.
140 // |begin_frame_time|, if non-zero, identifies the frame time at which the 147 // |begin_frame_time|, if non-zero, identifies the frame time at which the
141 // input was processed. 148 // input was processed.
142 void DidProcessInputEvent(base::TimeTicks begin_frame_time); 149 void DidProcessInputEvent(base::TimeTicks begin_frame_time);
143 150
151 // Returns true if we should initiate a long idle time now. Fills in
152 // |next_long_idle_period_delay_out| with the next time we should try to
153 // initiate the next idle period.
154 bool ShouldStartLongIdlePeriod(
155 const base::TimeTicks& now,
Sami 2015/03/03 16:55:36 nit: pass TimeTicks by value.
rmcilroy 2015/03/04 14:23:12 Done.
156 base::TimeDelta* next_long_idle_period_delay_out);
157
158 // Initiate a long idle period.
159 void InitiateLongIdlePeriod();
160 void AfterWakeupInitiateLongIdlePeriod();
Sami 2015/03/03 16:55:36 InitiateLongIdlePeriodAfterWakeup to make this les
rmcilroy 2015/03/04 14:23:12 mmh, I originally had this but thought it sounded
rmcilroy 2015/03/04 14:23:12 Done.
161
144 // Start and end an idle period. 162 // Start and end an idle period.
145 void StartIdlePeriod(); 163 void StartIdlePeriod();
146 void EndIdlePeriod(); 164 void EndIdlePeriod();
147 165
148 base::TimeTicks Now() const; 166 base::TimeTicks Now() const;
149 167
150 base::ThreadChecker main_thread_checker_; 168 base::ThreadChecker main_thread_checker_;
151 scoped_ptr<RendererTaskQueueSelector> renderer_task_queue_selector_; 169 scoped_ptr<RendererTaskQueueSelector> renderer_task_queue_selector_;
152 scoped_ptr<TaskQueueManager> task_queue_manager_; 170 scoped_ptr<TaskQueueManager> task_queue_manager_;
153 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; 171 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_;
154 scoped_refptr<base::SingleThreadTaskRunner> control_task_after_wakeup_runner_; 172 scoped_refptr<base::SingleThreadTaskRunner> control_task_after_wakeup_runner_;
155 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_; 173 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_;
156 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; 174 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
157 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_; 175 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_;
158 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_; 176 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_;
159 177
160 base::Closure update_policy_closure_; 178 base::Closure update_policy_closure_;
161 CancelableClosureHolder end_idle_period_closure_; 179 CancelableClosureHolder end_idle_period_closure_;
180 CancelableClosureHolder initiate_next_long_idle_period_closure_;
181 CancelableClosureHolder after_wakeup_initiate_next_long_idle_period_closure_;
162 182
163 // Don't access current_policy_ directly, instead use SchedulerPolicy(). 183 // Don't access current_policy_ directly, instead use SchedulerPolicy().
164 Policy current_policy_; 184 Policy current_policy_;
165 185
166 base::TimeTicks estimated_next_frame_begin_; 186 base::TimeTicks estimated_next_frame_begin_;
167 187
168 // The incoming_signals_lock_ mutex protects access to all variables in the 188 // The incoming_signals_lock_ mutex protects access to all variables in the
169 // (contiguous) block below. 189 // (contiguous) block below.
170 base::Lock incoming_signals_lock_; 190 base::Lock incoming_signals_lock_;
171 base::TimeTicks last_input_receipt_time_on_compositor_; 191 base::TimeTicks last_input_receipt_time_on_compositor_;
172 base::TimeTicks last_input_process_time_on_main_; 192 base::TimeTicks last_input_process_time_on_main_;
173 blink::WebInputEvent::Type last_input_type_; 193 blink::WebInputEvent::Type last_input_type_;
174 InputStreamState input_stream_state_; 194 InputStreamState input_stream_state_;
175 PollableNeedsUpdateFlag policy_may_need_update_; 195 PollableNeedsUpdateFlag policy_may_need_update_;
176 196
177 scoped_refptr<cc::TestNowSource> time_source_; 197 scoped_refptr<cc::TestNowSource> time_source_;
178 198
179 base::WeakPtr<RendererSchedulerImpl> weak_renderer_scheduler_ptr_; 199 base::WeakPtr<RendererSchedulerImpl> weak_renderer_scheduler_ptr_;
180 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; 200 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_;
181 201
182 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); 202 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl);
183 }; 203 };
184 204
185 } // namespace content 205 } // namespace content
186 206
187 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ 207 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698