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