| 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" |
| 11 #include "platform/scheduler/base/long_task_tracker.h" | |
| 12 #include "platform/scheduler/base/pollable_thread_safe_flag.h" | 11 #include "platform/scheduler/base/pollable_thread_safe_flag.h" |
| 13 #include "platform/scheduler/base/queueing_time_estimator.h" | 12 #include "platform/scheduler/base/queueing_time_estimator.h" |
| 14 #include "platform/scheduler/base/task_time_tracker.h" | |
| 15 #include "platform/scheduler/base/thread_load_tracker.h" | 13 #include "platform/scheduler/base/thread_load_tracker.h" |
| 16 #include "platform/scheduler/child/idle_helper.h" | 14 #include "platform/scheduler/child/idle_helper.h" |
| 17 #include "platform/scheduler/child/scheduler_helper.h" | 15 #include "platform/scheduler/child/scheduler_helper.h" |
| 18 #include "platform/scheduler/renderer/deadline_task_runner.h" | 16 #include "platform/scheduler/renderer/deadline_task_runner.h" |
| 19 #include "platform/scheduler/renderer/idle_time_estimator.h" | 17 #include "platform/scheduler/renderer/idle_time_estimator.h" |
| 20 #include "platform/scheduler/renderer/render_widget_signals.h" | 18 #include "platform/scheduler/renderer/render_widget_signals.h" |
| 21 #include "platform/scheduler/renderer/task_cost_estimator.h" | 19 #include "platform/scheduler/renderer/task_cost_estimator.h" |
| 22 #include "platform/scheduler/renderer/throttling_helper.h" | 20 #include "platform/scheduler/renderer/throttling_helper.h" |
| 23 #include "platform/scheduler/renderer/user_model.h" | 21 #include "platform/scheduler/renderer/user_model.h" |
| 24 #include "platform/scheduler/renderer/web_view_scheduler_impl.h" | 22 #include "platform/scheduler/renderer/web_view_scheduler_impl.h" |
| 25 #include "public/platform/scheduler/renderer/renderer_scheduler.h" | 23 #include "public/platform/scheduler/renderer/renderer_scheduler.h" |
| 24 #include "public/platform/scheduler/base/task_time_observer.h" |
| 26 | 25 |
| 27 namespace base { | 26 namespace base { |
| 28 namespace trace_event { | 27 namespace trace_event { |
| 29 class ConvertableToTraceFormat; | 28 class ConvertableToTraceFormat; |
| 30 } | 29 } |
| 31 } | 30 } |
| 32 | 31 |
| 33 namespace blink { | 32 namespace blink { |
| 34 namespace scheduler { | 33 namespace scheduler { |
| 35 class AutoAdvancingVirtualTimeDomain; | 34 class AutoAdvancingVirtualTimeDomain; |
| 36 class RenderWidgetSchedulingState; | 35 class RenderWidgetSchedulingState; |
| 37 class WebViewSchedulerImpl; | 36 class WebViewSchedulerImpl; |
| 38 class ThrottlingHelper; | 37 class ThrottlingHelper; |
| 39 | 38 |
| 40 class BLINK_PLATFORM_EXPORT RendererSchedulerImpl | 39 class BLINK_PLATFORM_EXPORT RendererSchedulerImpl |
| 41 : public RendererScheduler, | 40 : public RendererScheduler, |
| 42 public IdleHelper::Delegate, | 41 public IdleHelper::Delegate, |
| 43 public SchedulerHelper::Observer, | 42 public SchedulerHelper::Observer, |
| 44 public RenderWidgetSignals::Observer, | 43 public RenderWidgetSignals::Observer, |
| 45 public TaskTimeTracker, | 44 public TaskTimeObserver, |
| 46 public QueueingTimeEstimator::Client { | 45 public QueueingTimeEstimator::Client { |
| 47 public: | 46 public: |
| 48 // Keep RendererScheduler::UseCaseToString in sync with this enum. | 47 // Keep RendererScheduler::UseCaseToString in sync with this enum. |
| 49 enum class UseCase { | 48 enum class UseCase { |
| 50 // No active use case detected. | 49 // No active use case detected. |
| 51 NONE, | 50 NONE, |
| 52 // A continuous gesture (e.g., scroll, pinch) which is being driven by the | 51 // A continuous gesture (e.g., scroll, pinch) which is being driven by the |
| 53 // compositor thread. | 52 // compositor thread. |
| 54 COMPOSITOR_GESTURE, | 53 COMPOSITOR_GESTURE, |
| 55 // An unspecified touch gesture which is being handled by the main thread. | 54 // An unspecified touch gesture which is being handled by the main thread. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // RenderWidgetSignals::Observer implementation: | 123 // RenderWidgetSignals::Observer implementation: |
| 125 void SetAllRenderWidgetsHidden(bool hidden) override; | 124 void SetAllRenderWidgetsHidden(bool hidden) override; |
| 126 void SetHasVisibleRenderWidgetWithTouchHandler( | 125 void SetHasVisibleRenderWidgetWithTouchHandler( |
| 127 bool has_visible_render_widget_with_touch_handler) override; | 126 bool has_visible_render_widget_with_touch_handler) override; |
| 128 | 127 |
| 129 // SchedulerHelper::Observer implementation: | 128 // SchedulerHelper::Observer implementation: |
| 130 void OnUnregisterTaskQueue(const scoped_refptr<TaskQueue>& queue) override; | 129 void OnUnregisterTaskQueue(const scoped_refptr<TaskQueue>& queue) override; |
| 131 void OnTriedToExecuteBlockedTask(const TaskQueue& queue, | 130 void OnTriedToExecuteBlockedTask(const TaskQueue& queue, |
| 132 const base::PendingTask& task) override; | 131 const base::PendingTask& task) override; |
| 133 | 132 |
| 134 // TaskTimeTracker implementation: | 133 // TaskTimeObserver implementation: |
| 135 void ReportTaskTime(base::TimeTicks start_time, | 134 void ReportTaskTime(double start_time, double end_time) override; |
| 136 base::TimeTicks end_time) override; | |
| 137 | 135 |
| 138 // QueueingTimeEstimator::Client implementation: | 136 // QueueingTimeEstimator::Client implementation: |
| 139 void OnQueueingTimeForWindowEstimated(base::TimeDelta queueing_time) override; | 137 void OnQueueingTimeForWindowEstimated(base::TimeDelta queueing_time) override; |
| 140 | 138 |
| 141 // Returns a task runner where tasks run at the highest possible priority. | 139 // Returns a task runner where tasks run at the highest possible priority. |
| 142 scoped_refptr<TaskQueue> ControlTaskRunner(); | 140 scoped_refptr<TaskQueue> ControlTaskRunner(); |
| 143 | 141 |
| 144 void RegisterTimeDomain(TimeDomain* time_domain); | 142 void RegisterTimeDomain(TimeDomain* time_domain); |
| 145 void UnregisterTimeDomain(TimeDomain* time_domain); | 143 void UnregisterTimeDomain(TimeDomain* time_domain); |
| 146 | 144 |
| 147 // Tells the scheduler that all TaskQueues should use virtual time. | 145 // Tells the scheduler that all TaskQueues should use virtual time. |
| 148 void EnableVirtualTime(); | 146 void EnableVirtualTime(); |
| 149 | 147 |
| 150 void AddWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler); | 148 void AddWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler); |
| 151 void RemoveWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler); | 149 void RemoveWebViewScheduler(WebViewSchedulerImpl* web_view_scheduler); |
| 152 | 150 |
| 153 LongTaskTracker::LongTaskTiming GetLongTaskTiming(); | 151 void AddTaskTimeObserver(TaskTimeObserver* task_time_observer); |
| 152 void RemoveTaskTimeObserver(TaskTimeObserver* task_time_observer); |
| 154 | 153 |
| 155 // Test helpers. | 154 // Test helpers. |
| 156 SchedulerHelper* GetSchedulerHelperForTesting(); | 155 SchedulerHelper* GetSchedulerHelperForTesting(); |
| 157 TaskCostEstimator* GetLoadingTaskCostEstimatorForTesting(); | 156 TaskCostEstimator* GetLoadingTaskCostEstimatorForTesting(); |
| 158 TaskCostEstimator* GetTimerTaskCostEstimatorForTesting(); | 157 TaskCostEstimator* GetTimerTaskCostEstimatorForTesting(); |
| 159 IdleTimeEstimator* GetIdleTimeEstimatorForTesting(); | 158 IdleTimeEstimator* GetIdleTimeEstimatorForTesting(); |
| 160 base::TimeTicks CurrentIdleTaskDeadlineForTesting() const; | 159 base::TimeTicks CurrentIdleTaskDeadlineForTesting() const; |
| 161 void RunIdleTasksForTesting(const base::Closure& callback); | 160 void RunIdleTasksForTesting(const base::Closure& callback); |
| 162 void EndIdlePeriodForTesting(const base::Closure& callback, | 161 void EndIdlePeriodForTesting(const base::Closure& callback, |
| 163 base::TimeTicks time_remaining); | 162 base::TimeTicks time_remaining); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 struct MainThreadOnly { | 363 struct MainThreadOnly { |
| 365 MainThreadOnly(RendererSchedulerImpl* renderer_scheduler_impl, | 364 MainThreadOnly(RendererSchedulerImpl* renderer_scheduler_impl, |
| 366 const scoped_refptr<TaskQueue>& compositor_task_runner, | 365 const scoped_refptr<TaskQueue>& compositor_task_runner, |
| 367 base::TickClock* time_source, | 366 base::TickClock* time_source, |
| 368 base::TimeTicks now); | 367 base::TimeTicks now); |
| 369 ~MainThreadOnly(); | 368 ~MainThreadOnly(); |
| 370 | 369 |
| 371 TaskCostEstimator loading_task_cost_estimator; | 370 TaskCostEstimator loading_task_cost_estimator; |
| 372 TaskCostEstimator timer_task_cost_estimator; | 371 TaskCostEstimator timer_task_cost_estimator; |
| 373 QueueingTimeEstimator queueing_time_estimator; | 372 QueueingTimeEstimator queueing_time_estimator; |
| 374 LongTaskTracker long_task_tracker; | |
| 375 IdleTimeEstimator idle_time_estimator; | 373 IdleTimeEstimator idle_time_estimator; |
| 376 ThreadLoadTracker background_main_thread_load_tracker; | 374 ThreadLoadTracker background_main_thread_load_tracker; |
| 377 ThreadLoadTracker foreground_main_thread_load_tracker; | 375 ThreadLoadTracker foreground_main_thread_load_tracker; |
| 378 UseCase current_use_case; | 376 UseCase current_use_case; |
| 379 Policy current_policy; | 377 Policy current_policy; |
| 380 base::TimeTicks current_policy_expiration_time; | 378 base::TimeTicks current_policy_expiration_time; |
| 381 base::TimeTicks estimated_next_frame_begin; | 379 base::TimeTicks estimated_next_frame_begin; |
| 382 base::TimeDelta compositor_frame_interval; | 380 base::TimeDelta compositor_frame_interval; |
| 383 base::TimeDelta longest_jank_free_task_duration; | 381 base::TimeDelta longest_jank_free_task_duration; |
| 384 int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero. | 382 int timer_queue_suspend_count; // TIMER_TASK_QUEUE suspended if non-zero. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 PollableThreadSafeFlag policy_may_need_update_; | 469 PollableThreadSafeFlag policy_may_need_update_; |
| 472 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; | 470 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; |
| 473 | 471 |
| 474 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); | 472 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); |
| 475 }; | 473 }; |
| 476 | 474 |
| 477 } // namespace scheduler | 475 } // namespace scheduler |
| 478 } // namespace blink | 476 } // namespace blink |
| 479 | 477 |
| 480 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU
LER_IMPL_H_ | 478 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU
LER_IMPL_H_ |
| OLD | NEW |