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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.h

Issue 2483843002: Revert of [scheduler] Teach scheduler about audio state (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER _IMPL_H_ 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER _IMPL_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER _IMPL_H_ 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER _IMPL_H_
7 7
8 #include "base/atomicops.h" 8 #include "base/atomicops.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 void AddWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler); 153 void AddWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler);
154 void RemoveWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler); 154 void RemoveWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler);
155 155
156 void AddTaskTimeObserver(TaskTimeObserver* task_time_observer); 156 void AddTaskTimeObserver(TaskTimeObserver* task_time_observer);
157 void RemoveTaskTimeObserver(TaskTimeObserver* task_time_observer); 157 void RemoveTaskTimeObserver(TaskTimeObserver* task_time_observer);
158 158
159 // Snapshots this RendererScheduler for tracing. 159 // Snapshots this RendererScheduler for tracing.
160 void CreateTraceEventObjectSnapshot() const; 160 void CreateTraceEventObjectSnapshot() const;
161 161
162 // Called when one of associated WebView schedulers has changed audio
163 // state.
164 void OnAudioStateChanged();
165
166 // Test helpers. 162 // Test helpers.
167 SchedulerHelper* GetSchedulerHelperForTesting(); 163 SchedulerHelper* GetSchedulerHelperForTesting();
168 TaskCostEstimator* GetLoadingTaskCostEstimatorForTesting(); 164 TaskCostEstimator* GetLoadingTaskCostEstimatorForTesting();
169 TaskCostEstimator* GetTimerTaskCostEstimatorForTesting(); 165 TaskCostEstimator* GetTimerTaskCostEstimatorForTesting();
170 IdleTimeEstimator* GetIdleTimeEstimatorForTesting(); 166 IdleTimeEstimator* GetIdleTimeEstimatorForTesting();
171 base::TimeTicks CurrentIdleTaskDeadlineForTesting() const; 167 base::TimeTicks CurrentIdleTaskDeadlineForTesting() const;
172 void RunIdleTasksForTesting(const base::Closure& callback); 168 void RunIdleTasksForTesting(const base::Closure& callback);
173 void EndIdlePeriodForTesting(const base::Closure& callback, 169 void EndIdlePeriodForTesting(const base::Closure& callback,
174 base::TimeTicks time_remaining); 170 base::TimeTicks time_remaining);
175 bool PolicyNeedsUpdateForTesting(); 171 bool PolicyNeedsUpdateForTesting();
176 172
177 base::TickClock* tick_clock() const; 173 base::TickClock* tick_clock() const;
178 174
179 RealTimeDomain* real_time_domain() const { 175 RealTimeDomain* real_time_domain() const {
180 return helper_.real_time_domain(); 176 return helper_.real_time_domain();
181 } 177 }
182 178
183 AutoAdvancingVirtualTimeDomain* GetVirtualTimeDomain(); 179 AutoAdvancingVirtualTimeDomain* GetVirtualTimeDomain();
184 180
185 TimeDomain* GetActiveTimeDomain();
186
187 TaskQueueThrottler* task_queue_throttler() const { 181 TaskQueueThrottler* task_queue_throttler() const {
188 return task_queue_throttler_.get(); 182 return task_queue_throttler_.get();
189 } 183 }
190 184
191 private: 185 private:
192 friend class RendererSchedulerImplTest; 186 friend class RendererSchedulerImplTest;
193 friend class RendererSchedulerImplForTest; 187 friend class RendererSchedulerImplForTest;
194 friend class RenderWidgetSchedulingState; 188 friend class RenderWidgetSchedulingState;
195 189
196 enum class ExpensiveTaskPolicy { RUN, BLOCK, THROTTLE }; 190 enum class ExpensiveTaskPolicy { RUN, BLOCK, THROTTLE };
(...skipping 19 matching lines...) Expand all
216 time_domain_type == other.time_domain_type; 210 time_domain_type == other.time_domain_type;
217 } 211 }
218 }; 212 };
219 213
220 struct Policy { 214 struct Policy {
221 TaskQueuePolicy compositor_queue_policy; 215 TaskQueuePolicy compositor_queue_policy;
222 TaskQueuePolicy loading_queue_policy; 216 TaskQueuePolicy loading_queue_policy;
223 TaskQueuePolicy timer_queue_policy; 217 TaskQueuePolicy timer_queue_policy;
224 TaskQueuePolicy default_queue_policy; 218 TaskQueuePolicy default_queue_policy;
225 v8::RAILMode rail_mode = v8::PERFORMANCE_ANIMATION; 219 v8::RAILMode rail_mode = v8::PERFORMANCE_ANIMATION;
226 bool should_disable_throttling = false;
227 220
228 bool operator==(const Policy& other) const { 221 bool operator==(const Policy& other) const {
229 return compositor_queue_policy == other.compositor_queue_policy && 222 return compositor_queue_policy == other.compositor_queue_policy &&
230 loading_queue_policy == other.loading_queue_policy && 223 loading_queue_policy == other.loading_queue_policy &&
231 timer_queue_policy == other.timer_queue_policy && 224 timer_queue_policy == other.timer_queue_policy &&
232 default_queue_policy == other.default_queue_policy && 225 default_queue_policy == other.default_queue_policy &&
233 rail_mode == other.rail_mode && 226 rail_mode == other.rail_mode;
234 should_disable_throttling == other.should_disable_throttling;
235 } 227 }
236 }; 228 };
237 229
238 class PollableNeedsUpdateFlag { 230 class PollableNeedsUpdateFlag {
239 public: 231 public:
240 PollableNeedsUpdateFlag(base::Lock* write_lock); 232 PollableNeedsUpdateFlag(base::Lock* write_lock);
241 ~PollableNeedsUpdateFlag(); 233 ~PollableNeedsUpdateFlag();
242 234
243 // Set the flag. May only be called if |write_lock| is held. 235 // Set the flag. May only be called if |write_lock| is held.
244 void SetWhileLocked(bool value); 236 void SetWhileLocked(bool value);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 // Report an intervention to all WebViews in this process. 340 // Report an intervention to all WebViews in this process.
349 void BroadcastIntervention(const std::string& message); 341 void BroadcastIntervention(const std::string& message);
350 342
351 void ApplyTaskQueuePolicy(TaskQueue* task_queue, 343 void ApplyTaskQueuePolicy(TaskQueue* task_queue,
352 const TaskQueuePolicy& old_task_queue_policy, 344 const TaskQueuePolicy& old_task_queue_policy,
353 const TaskQueuePolicy& new_task_queue_policy) const; 345 const TaskQueuePolicy& new_task_queue_policy) const;
354 346
355 static const char* ExpensiveTaskPolicyToString( 347 static const char* ExpensiveTaskPolicyToString(
356 ExpensiveTaskPolicy expensive_task_policy); 348 ExpensiveTaskPolicy expensive_task_policy);
357 349
358 bool ShouldDisableThrottlingBecauseOfAudio(base::TimeTicks now);
359
360 SchedulerHelper helper_; 350 SchedulerHelper helper_;
361 IdleHelper idle_helper_; 351 IdleHelper idle_helper_;
362 std::unique_ptr<TaskQueueThrottler> task_queue_throttler_; 352 std::unique_ptr<TaskQueueThrottler> task_queue_throttler_;
363 RenderWidgetSignals render_widget_scheduler_signals_; 353 RenderWidgetSignals render_widget_scheduler_signals_;
364 354
365 const scoped_refptr<TaskQueue> control_task_runner_; 355 const scoped_refptr<TaskQueue> control_task_runner_;
366 const scoped_refptr<TaskQueue> compositor_task_runner_; 356 const scoped_refptr<TaskQueue> compositor_task_runner_;
367 std::set<scoped_refptr<TaskQueue>> loading_task_runners_; 357 std::set<scoped_refptr<TaskQueue>> loading_task_runners_;
368 std::set<scoped_refptr<TaskQueue>> timer_task_runners_; 358 std::set<scoped_refptr<TaskQueue>> timer_task_runners_;
369 std::set<scoped_refptr<TaskQueue>> unthrottled_task_runners_; 359 std::set<scoped_refptr<TaskQueue>> unthrottled_task_runners_;
(...skipping 23 matching lines...) Expand all
393 QueueingTimeEstimator queueing_time_estimator; 383 QueueingTimeEstimator queueing_time_estimator;
394 IdleTimeEstimator idle_time_estimator; 384 IdleTimeEstimator idle_time_estimator;
395 ThreadLoadTracker background_main_thread_load_tracker; 385 ThreadLoadTracker background_main_thread_load_tracker;
396 ThreadLoadTracker foreground_main_thread_load_tracker; 386 ThreadLoadTracker foreground_main_thread_load_tracker;
397 UseCase current_use_case; 387 UseCase current_use_case;
398 Policy current_policy; 388 Policy current_policy;
399 base::TimeTicks current_policy_expiration_time; 389 base::TimeTicks current_policy_expiration_time;
400 base::TimeTicks estimated_next_frame_begin; 390 base::TimeTicks estimated_next_frame_begin;
401 base::TimeDelta compositor_frame_interval; 391 base::TimeDelta compositor_frame_interval;
402 base::TimeDelta longest_jank_free_task_duration; 392 base::TimeDelta longest_jank_free_task_duration;
403 base::Optional<base::TimeTicks> last_audio_state_change;
404 int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero. 393 int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero.
405 int navigation_task_expected_count; 394 int navigation_task_expected_count;
406 ExpensiveTaskPolicy expensive_task_policy; 395 ExpensiveTaskPolicy expensive_task_policy;
407 bool renderer_hidden; 396 bool renderer_hidden;
408 bool renderer_backgrounded; 397 bool renderer_backgrounded;
409 bool renderer_suspended; 398 bool renderer_suspended;
410 bool timer_queue_suspension_when_backgrounded_enabled; 399 bool timer_queue_suspension_when_backgrounded_enabled;
411 bool timer_queue_suspended_when_backgrounded; 400 bool timer_queue_suspended_when_backgrounded;
412 bool was_shutdown; 401 bool was_shutdown;
413 bool loading_tasks_seem_expensive; 402 bool loading_tasks_seem_expensive;
414 bool timer_tasks_seem_expensive; 403 bool timer_tasks_seem_expensive;
415 bool touchstart_expected_soon; 404 bool touchstart_expected_soon;
416 bool have_seen_a_begin_main_frame; 405 bool have_seen_a_begin_main_frame;
417 bool have_reported_blocking_intervention_in_current_policy; 406 bool have_reported_blocking_intervention_in_current_policy;
418 bool have_reported_blocking_intervention_since_navigation; 407 bool have_reported_blocking_intervention_since_navigation;
419 bool has_visible_render_widget_with_touch_handler; 408 bool has_visible_render_widget_with_touch_handler;
420 bool begin_frame_not_expected_soon; 409 bool begin_frame_not_expected_soon;
421 bool in_idle_period_for_testing; 410 bool in_idle_period_for_testing;
422 bool use_virtual_time; 411 bool use_virtual_time;
423 bool is_audio_playing;
424 std::set<WebViewSchedulerImpl*> web_view_schedulers; // Not owned. 412 std::set<WebViewSchedulerImpl*> web_view_schedulers; // Not owned.
425 RAILModeObserver* rail_mode_observer; // Not owned. 413 RAILModeObserver* rail_mode_observer; // Not owned.
426 }; 414 };
427 415
428 struct AnyThread { 416 struct AnyThread {
429 AnyThread(); 417 AnyThread();
430 ~AnyThread(); 418 ~AnyThread();
431 419
432 base::TimeTicks last_idle_period_end_time; 420 base::TimeTicks last_idle_period_end_time;
433 base::TimeTicks rails_loading_priority_deadline; 421 base::TimeTicks rails_loading_priority_deadline;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 PollableThreadSafeFlag policy_may_need_update_; 480 PollableThreadSafeFlag policy_may_need_update_;
493 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; 481 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_;
494 482
495 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); 483 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl);
496 }; 484 };
497 485
498 } // namespace scheduler 486 } // namespace scheduler
499 } // namespace blink 487 } // namespace blink
500 488
501 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU LER_IMPL_H_ 489 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU LER_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698