| OLD | NEW |
| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 void BeginFrameNotExpectedSoon() override; | 94 void BeginFrameNotExpectedSoon() override; |
| 95 void DidCommitFrameToCompositor() override; | 95 void DidCommitFrameToCompositor() override; |
| 96 void DidHandleInputEventOnCompositorThread( | 96 void DidHandleInputEventOnCompositorThread( |
| 97 const WebInputEvent& web_input_event, | 97 const WebInputEvent& web_input_event, |
| 98 InputEventState event_state) override; | 98 InputEventState event_state) override; |
| 99 void DidHandleInputEventOnMainThread( | 99 void DidHandleInputEventOnMainThread( |
| 100 const WebInputEvent& web_input_event) override; | 100 const WebInputEvent& web_input_event) override; |
| 101 void DidAnimateForInputOnCompositorThread() override; | 101 void DidAnimateForInputOnCompositorThread() override; |
| 102 void OnRendererBackgrounded() override; | 102 void OnRendererBackgrounded() override; |
| 103 void OnRendererForegrounded() override; | 103 void OnRendererForegrounded() override; |
| 104 void OnAudioStateChanged(bool is_audio_playing) override; |
| 104 void SuspendRenderer() override; | 105 void SuspendRenderer() override; |
| 105 void AddPendingNavigation(WebScheduler::NavigatingFrameType type) override; | 106 void AddPendingNavigation(WebScheduler::NavigatingFrameType type) override; |
| 106 void RemovePendingNavigation(WebScheduler::NavigatingFrameType type) override; | 107 void RemovePendingNavigation(WebScheduler::NavigatingFrameType type) override; |
| 107 void OnNavigationStarted() override; | 108 void OnNavigationStarted() override; |
| 108 bool IsHighPriorityWorkAnticipated() override; | 109 bool IsHighPriorityWorkAnticipated() override; |
| 109 bool ShouldYieldForHighPriorityWork() override; | 110 bool ShouldYieldForHighPriorityWork() override; |
| 110 bool CanExceedIdleDeadlineIfRequired() const override; | 111 bool CanExceedIdleDeadlineIfRequired() const override; |
| 111 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; | 112 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; |
| 112 void RemoveTaskObserver( | 113 void RemoveTaskObserver( |
| 113 base::MessageLoop::TaskObserver* task_observer) override; | 114 base::MessageLoop::TaskObserver* task_observer) override; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 bool PolicyNeedsUpdateForTesting(); | 168 bool PolicyNeedsUpdateForTesting(); |
| 168 | 169 |
| 169 base::TickClock* tick_clock() const; | 170 base::TickClock* tick_clock() const; |
| 170 | 171 |
| 171 RealTimeDomain* real_time_domain() const { | 172 RealTimeDomain* real_time_domain() const { |
| 172 return helper_.real_time_domain(); | 173 return helper_.real_time_domain(); |
| 173 } | 174 } |
| 174 | 175 |
| 175 AutoAdvancingVirtualTimeDomain* GetVirtualTimeDomain(); | 176 AutoAdvancingVirtualTimeDomain* GetVirtualTimeDomain(); |
| 176 | 177 |
| 178 TimeDomain* GetActiveTimeDomain(); |
| 179 |
| 177 TaskQueueThrottler* task_queue_throttler() const { | 180 TaskQueueThrottler* task_queue_throttler() const { |
| 178 return task_queue_throttler_.get(); | 181 return task_queue_throttler_.get(); |
| 179 } | 182 } |
| 180 | 183 |
| 181 private: | 184 private: |
| 182 friend class RendererSchedulerImplTest; | 185 friend class RendererSchedulerImplTest; |
| 183 friend class RendererSchedulerImplForTest; | 186 friend class RendererSchedulerImplForTest; |
| 184 friend class RenderWidgetSchedulingState; | 187 friend class RenderWidgetSchedulingState; |
| 185 | 188 |
| 186 enum class ExpensiveTaskPolicy { RUN, BLOCK, THROTTLE }; | 189 enum class ExpensiveTaskPolicy { RUN, BLOCK, THROTTLE }; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 206 time_domain_type == other.time_domain_type; | 209 time_domain_type == other.time_domain_type; |
| 207 } | 210 } |
| 208 }; | 211 }; |
| 209 | 212 |
| 210 struct Policy { | 213 struct Policy { |
| 211 TaskQueuePolicy compositor_queue_policy; | 214 TaskQueuePolicy compositor_queue_policy; |
| 212 TaskQueuePolicy loading_queue_policy; | 215 TaskQueuePolicy loading_queue_policy; |
| 213 TaskQueuePolicy timer_queue_policy; | 216 TaskQueuePolicy timer_queue_policy; |
| 214 TaskQueuePolicy default_queue_policy; | 217 TaskQueuePolicy default_queue_policy; |
| 215 v8::RAILMode rail_mode = v8::PERFORMANCE_ANIMATION; | 218 v8::RAILMode rail_mode = v8::PERFORMANCE_ANIMATION; |
| 219 bool should_disable_throttling = false; |
| 216 | 220 |
| 217 bool operator==(const Policy& other) const { | 221 bool operator==(const Policy& other) const { |
| 218 return compositor_queue_policy == other.compositor_queue_policy && | 222 return compositor_queue_policy == other.compositor_queue_policy && |
| 219 loading_queue_policy == other.loading_queue_policy && | 223 loading_queue_policy == other.loading_queue_policy && |
| 220 timer_queue_policy == other.timer_queue_policy && | 224 timer_queue_policy == other.timer_queue_policy && |
| 221 default_queue_policy == other.default_queue_policy && | 225 default_queue_policy == other.default_queue_policy && |
| 222 rail_mode == other.rail_mode; | 226 rail_mode == other.rail_mode && |
| 227 should_disable_throttling == other.should_disable_throttling; |
| 223 } | 228 } |
| 224 }; | 229 }; |
| 225 | 230 |
| 226 class PollableNeedsUpdateFlag { | 231 class PollableNeedsUpdateFlag { |
| 227 public: | 232 public: |
| 228 PollableNeedsUpdateFlag(base::Lock* write_lock); | 233 PollableNeedsUpdateFlag(base::Lock* write_lock); |
| 229 ~PollableNeedsUpdateFlag(); | 234 ~PollableNeedsUpdateFlag(); |
| 230 | 235 |
| 231 // Set the flag. May only be called if |write_lock| is held. | 236 // Set the flag. May only be called if |write_lock| is held. |
| 232 void SetWhileLocked(bool value); | 237 void SetWhileLocked(bool value); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // Report an intervention to all WebViews in this process. | 341 // Report an intervention to all WebViews in this process. |
| 337 void BroadcastIntervention(const std::string& message); | 342 void BroadcastIntervention(const std::string& message); |
| 338 | 343 |
| 339 void ApplyTaskQueuePolicy(TaskQueue* task_queue, | 344 void ApplyTaskQueuePolicy(TaskQueue* task_queue, |
| 340 const TaskQueuePolicy& old_task_queue_policy, | 345 const TaskQueuePolicy& old_task_queue_policy, |
| 341 const TaskQueuePolicy& new_task_queue_policy) const; | 346 const TaskQueuePolicy& new_task_queue_policy) const; |
| 342 | 347 |
| 343 static const char* ExpensiveTaskPolicyToString( | 348 static const char* ExpensiveTaskPolicyToString( |
| 344 ExpensiveTaskPolicy expensive_task_policy); | 349 ExpensiveTaskPolicy expensive_task_policy); |
| 345 | 350 |
| 351 bool ShouldDisableThrottlingBecauseOfAudio(base::TimeTicks now); |
| 352 |
| 346 SchedulerHelper helper_; | 353 SchedulerHelper helper_; |
| 347 IdleHelper idle_helper_; | 354 IdleHelper idle_helper_; |
| 348 std::unique_ptr<TaskQueueThrottler> task_queue_throttler_; | 355 std::unique_ptr<TaskQueueThrottler> task_queue_throttler_; |
| 349 RenderWidgetSignals render_widget_scheduler_signals_; | 356 RenderWidgetSignals render_widget_scheduler_signals_; |
| 350 | 357 |
| 351 const scoped_refptr<TaskQueue> control_task_runner_; | 358 const scoped_refptr<TaskQueue> control_task_runner_; |
| 352 const scoped_refptr<TaskQueue> compositor_task_runner_; | 359 const scoped_refptr<TaskQueue> compositor_task_runner_; |
| 353 std::set<scoped_refptr<TaskQueue>> loading_task_runners_; | 360 std::set<scoped_refptr<TaskQueue>> loading_task_runners_; |
| 354 std::set<scoped_refptr<TaskQueue>> timer_task_runners_; | 361 std::set<scoped_refptr<TaskQueue>> timer_task_runners_; |
| 355 std::set<scoped_refptr<TaskQueue>> unthrottled_task_runners_; | 362 std::set<scoped_refptr<TaskQueue>> unthrottled_task_runners_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 379 QueueingTimeEstimator queueing_time_estimator; | 386 QueueingTimeEstimator queueing_time_estimator; |
| 380 IdleTimeEstimator idle_time_estimator; | 387 IdleTimeEstimator idle_time_estimator; |
| 381 ThreadLoadTracker background_main_thread_load_tracker; | 388 ThreadLoadTracker background_main_thread_load_tracker; |
| 382 ThreadLoadTracker foreground_main_thread_load_tracker; | 389 ThreadLoadTracker foreground_main_thread_load_tracker; |
| 383 UseCase current_use_case; | 390 UseCase current_use_case; |
| 384 Policy current_policy; | 391 Policy current_policy; |
| 385 base::TimeTicks current_policy_expiration_time; | 392 base::TimeTicks current_policy_expiration_time; |
| 386 base::TimeTicks estimated_next_frame_begin; | 393 base::TimeTicks estimated_next_frame_begin; |
| 387 base::TimeDelta compositor_frame_interval; | 394 base::TimeDelta compositor_frame_interval; |
| 388 base::TimeDelta longest_jank_free_task_duration; | 395 base::TimeDelta longest_jank_free_task_duration; |
| 396 base::Optional<base::TimeTicks> last_audio_state_change; |
| 397 base::TimeDelta throttling_delay_after_audio_is_played; |
| 389 int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero. | 398 int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero. |
| 390 int navigation_task_expected_count; | 399 int navigation_task_expected_count; |
| 391 ExpensiveTaskPolicy expensive_task_policy; | 400 ExpensiveTaskPolicy expensive_task_policy; |
| 392 bool renderer_hidden; | 401 bool renderer_hidden; |
| 393 bool renderer_backgrounded; | 402 bool renderer_backgrounded; |
| 394 bool renderer_suspended; | 403 bool renderer_suspended; |
| 395 bool timer_queue_suspension_when_backgrounded_enabled; | 404 bool timer_queue_suspension_when_backgrounded_enabled; |
| 396 bool timer_queue_suspended_when_backgrounded; | 405 bool timer_queue_suspended_when_backgrounded; |
| 397 bool was_shutdown; | 406 bool was_shutdown; |
| 398 bool loading_tasks_seem_expensive; | 407 bool loading_tasks_seem_expensive; |
| 399 bool timer_tasks_seem_expensive; | 408 bool timer_tasks_seem_expensive; |
| 400 bool touchstart_expected_soon; | 409 bool touchstart_expected_soon; |
| 401 bool have_seen_a_begin_main_frame; | 410 bool have_seen_a_begin_main_frame; |
| 402 bool have_reported_blocking_intervention_in_current_policy; | 411 bool have_reported_blocking_intervention_in_current_policy; |
| 403 bool have_reported_blocking_intervention_since_navigation; | 412 bool have_reported_blocking_intervention_since_navigation; |
| 404 bool has_visible_render_widget_with_touch_handler; | 413 bool has_visible_render_widget_with_touch_handler; |
| 405 bool begin_frame_not_expected_soon; | 414 bool begin_frame_not_expected_soon; |
| 406 bool in_idle_period_for_testing; | 415 bool in_idle_period_for_testing; |
| 407 bool use_virtual_time; | 416 bool use_virtual_time; |
| 417 bool is_audio_playing; |
| 408 std::set<WebViewSchedulerImpl*> web_view_schedulers; // Not owned. | 418 std::set<WebViewSchedulerImpl*> web_view_schedulers; // Not owned. |
| 409 RAILModeObserver* rail_mode_observer; // Not owned. | 419 RAILModeObserver* rail_mode_observer; // Not owned. |
| 410 }; | 420 }; |
| 411 | 421 |
| 412 struct AnyThread { | 422 struct AnyThread { |
| 413 AnyThread(); | 423 AnyThread(); |
| 414 ~AnyThread(); | 424 ~AnyThread(); |
| 415 | 425 |
| 416 base::TimeTicks last_idle_period_end_time; | 426 base::TimeTicks last_idle_period_end_time; |
| 417 base::TimeTicks rails_loading_priority_deadline; | 427 base::TimeTicks rails_loading_priority_deadline; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 PollableThreadSafeFlag policy_may_need_update_; | 486 PollableThreadSafeFlag policy_may_need_update_; |
| 477 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; | 487 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; |
| 478 | 488 |
| 479 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); | 489 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); |
| 480 }; | 490 }; |
| 481 | 491 |
| 482 } // namespace scheduler | 492 } // namespace scheduler |
| 483 } // namespace blink | 493 } // namespace blink |
| 484 | 494 |
| 485 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU
LER_IMPL_H_ | 495 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU
LER_IMPL_H_ |
| OLD | NEW |