| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 void AddWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler); | 149 void AddWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler); |
| 150 void RemoveWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler); | 150 void RemoveWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler); |
| 151 | 151 |
| 152 void AddTaskTimeObserver(TaskTimeObserver* task_time_observer); | 152 void AddTaskTimeObserver(TaskTimeObserver* task_time_observer); |
| 153 void RemoveTaskTimeObserver(TaskTimeObserver* task_time_observer); | 153 void RemoveTaskTimeObserver(TaskTimeObserver* task_time_observer); |
| 154 | 154 |
| 155 // Snapshots this RendererScheduler for tracing. | 155 // Snapshots this RendererScheduler for tracing. |
| 156 void CreateTraceEventObjectSnapshot() const; | 156 void CreateTraceEventObjectSnapshot() const; |
| 157 | 157 |
| 158 // Called when one of associated WebView schedulers has changed audio |
| 159 // state. |
| 160 void OnAudioStateChanged(); |
| 161 |
| 158 // Test helpers. | 162 // Test helpers. |
| 159 SchedulerHelper* GetSchedulerHelperForTesting(); | 163 SchedulerHelper* GetSchedulerHelperForTesting(); |
| 160 TaskCostEstimator* GetLoadingTaskCostEstimatorForTesting(); | 164 TaskCostEstimator* GetLoadingTaskCostEstimatorForTesting(); |
| 161 TaskCostEstimator* GetTimerTaskCostEstimatorForTesting(); | 165 TaskCostEstimator* GetTimerTaskCostEstimatorForTesting(); |
| 162 IdleTimeEstimator* GetIdleTimeEstimatorForTesting(); | 166 IdleTimeEstimator* GetIdleTimeEstimatorForTesting(); |
| 163 base::TimeTicks CurrentIdleTaskDeadlineForTesting() const; | 167 base::TimeTicks CurrentIdleTaskDeadlineForTesting() const; |
| 164 void RunIdleTasksForTesting(const base::Closure& callback); | 168 void RunIdleTasksForTesting(const base::Closure& callback); |
| 165 void EndIdlePeriodForTesting(const base::Closure& callback, | 169 void EndIdlePeriodForTesting(const base::Closure& callback, |
| 166 base::TimeTicks time_remaining); | 170 base::TimeTicks time_remaining); |
| 167 bool PolicyNeedsUpdateForTesting(); | 171 bool PolicyNeedsUpdateForTesting(); |
| 168 | 172 |
| 169 base::TickClock* tick_clock() const; | 173 base::TickClock* tick_clock() const; |
| 170 | 174 |
| 171 RealTimeDomain* real_time_domain() const { | 175 RealTimeDomain* real_time_domain() const { |
| 172 return helper_.real_time_domain(); | 176 return helper_.real_time_domain(); |
| 173 } | 177 } |
| 174 | 178 |
| 175 AutoAdvancingVirtualTimeDomain* GetVirtualTimeDomain(); | 179 AutoAdvancingVirtualTimeDomain* GetVirtualTimeDomain(); |
| 176 | 180 |
| 181 TimeDomain* GetActiveTimeDomain(); |
| 182 |
| 177 TaskQueueThrottler* task_queue_throttler() const { | 183 TaskQueueThrottler* task_queue_throttler() const { |
| 178 return task_queue_throttler_.get(); | 184 return task_queue_throttler_.get(); |
| 179 } | 185 } |
| 180 | 186 |
| 181 private: | 187 private: |
| 182 friend class RendererSchedulerImplTest; | 188 friend class RendererSchedulerImplTest; |
| 183 friend class RendererSchedulerImplForTest; | 189 friend class RendererSchedulerImplForTest; |
| 184 friend class RenderWidgetSchedulingState; | 190 friend class RenderWidgetSchedulingState; |
| 185 | 191 |
| 186 enum class ExpensiveTaskPolicy { RUN, BLOCK, THROTTLE }; | 192 enum class ExpensiveTaskPolicy { RUN, BLOCK, THROTTLE }; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 206 time_domain_type == other.time_domain_type; | 212 time_domain_type == other.time_domain_type; |
| 207 } | 213 } |
| 208 }; | 214 }; |
| 209 | 215 |
| 210 struct Policy { | 216 struct Policy { |
| 211 TaskQueuePolicy compositor_queue_policy; | 217 TaskQueuePolicy compositor_queue_policy; |
| 212 TaskQueuePolicy loading_queue_policy; | 218 TaskQueuePolicy loading_queue_policy; |
| 213 TaskQueuePolicy timer_queue_policy; | 219 TaskQueuePolicy timer_queue_policy; |
| 214 TaskQueuePolicy default_queue_policy; | 220 TaskQueuePolicy default_queue_policy; |
| 215 v8::RAILMode rail_mode = v8::PERFORMANCE_ANIMATION; | 221 v8::RAILMode rail_mode = v8::PERFORMANCE_ANIMATION; |
| 222 bool should_disable_throttling = false; |
| 216 | 223 |
| 217 bool operator==(const Policy& other) const { | 224 bool operator==(const Policy& other) const { |
| 218 return compositor_queue_policy == other.compositor_queue_policy && | 225 return compositor_queue_policy == other.compositor_queue_policy && |
| 219 loading_queue_policy == other.loading_queue_policy && | 226 loading_queue_policy == other.loading_queue_policy && |
| 220 timer_queue_policy == other.timer_queue_policy && | 227 timer_queue_policy == other.timer_queue_policy && |
| 221 default_queue_policy == other.default_queue_policy && | 228 default_queue_policy == other.default_queue_policy && |
| 222 rail_mode == other.rail_mode; | 229 rail_mode == other.rail_mode && |
| 230 should_disable_throttling == other.should_disable_throttling; |
| 223 } | 231 } |
| 224 }; | 232 }; |
| 225 | 233 |
| 226 class PollableNeedsUpdateFlag { | 234 class PollableNeedsUpdateFlag { |
| 227 public: | 235 public: |
| 228 PollableNeedsUpdateFlag(base::Lock* write_lock); | 236 PollableNeedsUpdateFlag(base::Lock* write_lock); |
| 229 ~PollableNeedsUpdateFlag(); | 237 ~PollableNeedsUpdateFlag(); |
| 230 | 238 |
| 231 // Set the flag. May only be called if |write_lock| is held. | 239 // Set the flag. May only be called if |write_lock| is held. |
| 232 void SetWhileLocked(bool value); | 240 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. | 344 // Report an intervention to all WebViews in this process. |
| 337 void BroadcastIntervention(const std::string& message); | 345 void BroadcastIntervention(const std::string& message); |
| 338 | 346 |
| 339 void ApplyTaskQueuePolicy(TaskQueue* task_queue, | 347 void ApplyTaskQueuePolicy(TaskQueue* task_queue, |
| 340 const TaskQueuePolicy& old_task_queue_policy, | 348 const TaskQueuePolicy& old_task_queue_policy, |
| 341 const TaskQueuePolicy& new_task_queue_policy) const; | 349 const TaskQueuePolicy& new_task_queue_policy) const; |
| 342 | 350 |
| 343 static const char* ExpensiveTaskPolicyToString( | 351 static const char* ExpensiveTaskPolicyToString( |
| 344 ExpensiveTaskPolicy expensive_task_policy); | 352 ExpensiveTaskPolicy expensive_task_policy); |
| 345 | 353 |
| 354 bool ShouldDisableThrottlingBecauseOfAudio(base::TimeTicks now); |
| 355 |
| 346 SchedulerHelper helper_; | 356 SchedulerHelper helper_; |
| 347 IdleHelper idle_helper_; | 357 IdleHelper idle_helper_; |
| 348 std::unique_ptr<TaskQueueThrottler> task_queue_throttler_; | 358 std::unique_ptr<TaskQueueThrottler> task_queue_throttler_; |
| 349 RenderWidgetSignals render_widget_scheduler_signals_; | 359 RenderWidgetSignals render_widget_scheduler_signals_; |
| 350 | 360 |
| 351 const scoped_refptr<TaskQueue> control_task_runner_; | 361 const scoped_refptr<TaskQueue> control_task_runner_; |
| 352 const scoped_refptr<TaskQueue> compositor_task_runner_; | 362 const scoped_refptr<TaskQueue> compositor_task_runner_; |
| 353 std::set<scoped_refptr<TaskQueue>> loading_task_runners_; | 363 std::set<scoped_refptr<TaskQueue>> loading_task_runners_; |
| 354 std::set<scoped_refptr<TaskQueue>> timer_task_runners_; | 364 std::set<scoped_refptr<TaskQueue>> timer_task_runners_; |
| 355 std::set<scoped_refptr<TaskQueue>> unthrottled_task_runners_; | 365 std::set<scoped_refptr<TaskQueue>> unthrottled_task_runners_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 379 QueueingTimeEstimator queueing_time_estimator; | 389 QueueingTimeEstimator queueing_time_estimator; |
| 380 IdleTimeEstimator idle_time_estimator; | 390 IdleTimeEstimator idle_time_estimator; |
| 381 ThreadLoadTracker background_main_thread_load_tracker; | 391 ThreadLoadTracker background_main_thread_load_tracker; |
| 382 ThreadLoadTracker foreground_main_thread_load_tracker; | 392 ThreadLoadTracker foreground_main_thread_load_tracker; |
| 383 UseCase current_use_case; | 393 UseCase current_use_case; |
| 384 Policy current_policy; | 394 Policy current_policy; |
| 385 base::TimeTicks current_policy_expiration_time; | 395 base::TimeTicks current_policy_expiration_time; |
| 386 base::TimeTicks estimated_next_frame_begin; | 396 base::TimeTicks estimated_next_frame_begin; |
| 387 base::TimeDelta compositor_frame_interval; | 397 base::TimeDelta compositor_frame_interval; |
| 388 base::TimeDelta longest_jank_free_task_duration; | 398 base::TimeDelta longest_jank_free_task_duration; |
| 399 base::Optional<base::TimeTicks> last_audio_state_change; |
| 389 int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero. | 400 int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero. |
| 390 int navigation_task_expected_count; | 401 int navigation_task_expected_count; |
| 391 ExpensiveTaskPolicy expensive_task_policy; | 402 ExpensiveTaskPolicy expensive_task_policy; |
| 392 bool renderer_hidden; | 403 bool renderer_hidden; |
| 393 bool renderer_backgrounded; | 404 bool renderer_backgrounded; |
| 394 bool renderer_suspended; | 405 bool renderer_suspended; |
| 395 bool timer_queue_suspension_when_backgrounded_enabled; | 406 bool timer_queue_suspension_when_backgrounded_enabled; |
| 396 bool timer_queue_suspended_when_backgrounded; | 407 bool timer_queue_suspended_when_backgrounded; |
| 397 bool was_shutdown; | 408 bool was_shutdown; |
| 398 bool loading_tasks_seem_expensive; | 409 bool loading_tasks_seem_expensive; |
| 399 bool timer_tasks_seem_expensive; | 410 bool timer_tasks_seem_expensive; |
| 400 bool touchstart_expected_soon; | 411 bool touchstart_expected_soon; |
| 401 bool have_seen_a_begin_main_frame; | 412 bool have_seen_a_begin_main_frame; |
| 402 bool have_reported_blocking_intervention_in_current_policy; | 413 bool have_reported_blocking_intervention_in_current_policy; |
| 403 bool have_reported_blocking_intervention_since_navigation; | 414 bool have_reported_blocking_intervention_since_navigation; |
| 404 bool has_visible_render_widget_with_touch_handler; | 415 bool has_visible_render_widget_with_touch_handler; |
| 405 bool begin_frame_not_expected_soon; | 416 bool begin_frame_not_expected_soon; |
| 406 bool in_idle_period_for_testing; | 417 bool in_idle_period_for_testing; |
| 407 bool use_virtual_time; | 418 bool use_virtual_time; |
| 419 bool is_audio_playing; |
| 408 std::set<WebViewSchedulerImpl*> web_view_schedulers; // Not owned. | 420 std::set<WebViewSchedulerImpl*> web_view_schedulers; // Not owned. |
| 409 RAILModeObserver* rail_mode_observer; // Not owned. | 421 RAILModeObserver* rail_mode_observer; // Not owned. |
| 410 }; | 422 }; |
| 411 | 423 |
| 412 struct AnyThread { | 424 struct AnyThread { |
| 413 AnyThread(); | 425 AnyThread(); |
| 414 ~AnyThread(); | 426 ~AnyThread(); |
| 415 | 427 |
| 416 base::TimeTicks last_idle_period_end_time; | 428 base::TimeTicks last_idle_period_end_time; |
| 417 base::TimeTicks rails_loading_priority_deadline; | 429 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_; | 488 PollableThreadSafeFlag policy_may_need_update_; |
| 477 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; | 489 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; |
| 478 | 490 |
| 479 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); | 491 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); |
| 480 }; | 492 }; |
| 481 | 493 |
| 482 } // namespace scheduler | 494 } // namespace scheduler |
| 483 } // namespace blink | 495 } // namespace blink |
| 484 | 496 |
| 485 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU
LER_IMPL_H_ | 497 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU
LER_IMPL_H_ |
| OLD | NEW |