| 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 COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_ | 5 #ifndef COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_ |
| 6 #define COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_ | 6 #define COMPONENTS_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 20 matching lines...) Expand all Loading... |
| 31 class RenderWidgetSchedulingState; | 31 class RenderWidgetSchedulingState; |
| 32 class WebViewSchedulerImpl; | 32 class WebViewSchedulerImpl; |
| 33 class ThrottlingHelper; | 33 class ThrottlingHelper; |
| 34 | 34 |
| 35 class SCHEDULER_EXPORT RendererSchedulerImpl | 35 class SCHEDULER_EXPORT RendererSchedulerImpl |
| 36 : public RendererScheduler, | 36 : public RendererScheduler, |
| 37 public IdleHelper::Delegate, | 37 public IdleHelper::Delegate, |
| 38 public SchedulerHelper::Observer, | 38 public SchedulerHelper::Observer, |
| 39 public RenderWidgetSignals::Observer { | 39 public RenderWidgetSignals::Observer { |
| 40 public: | 40 public: |
| 41 // Keep RendererScheduler::UseCaseToString in sync with this enum. |
| 42 enum class UseCase { |
| 43 // No active use case detected. |
| 44 NONE, |
| 45 // A continuous gesture (e.g., scroll, pinch) which is being driven by the |
| 46 // compositor thread. |
| 47 COMPOSITOR_GESTURE, |
| 48 // An unspecified touch gesture which is being handled by the main thread. |
| 49 // Note that since we don't have a full view of the use case, we should be |
| 50 // careful to prioritize all work equally. |
| 51 MAIN_THREAD_CUSTOM_INPUT_HANDLING, |
| 52 // A continuous gesture (e.g., scroll, pinch) which is being driven by the |
| 53 // compositor thread but also observed by the main thread. An example is |
| 54 // synchronized scrolling where a scroll listener on the main thread changes |
| 55 // page layout based on the current scroll position. |
| 56 SYNCHRONIZED_GESTURE, |
| 57 // A gesture has recently started and we are about to run main thread touch |
| 58 // listeners to find out the actual gesture type. To minimize touch latency, |
| 59 // only input handling work should run in this state. |
| 60 TOUCHSTART, |
| 61 // The page is loading. |
| 62 LOADING, |
| 63 // A continuous gesture (e.g., scroll) which is being handled by the main |
| 64 // thread. |
| 65 MAIN_THREAD_GESTURE, |
| 66 // Must be the last entry. |
| 67 USE_CASE_COUNT, |
| 68 FIRST_USE_CASE = NONE, |
| 69 }; |
| 70 static const char* UseCaseToString(UseCase use_case); |
| 71 static const char* RAILModeToString(v8::RAILMode rail_mode); |
| 72 |
| 41 RendererSchedulerImpl(scoped_refptr<SchedulerTqmDelegate> main_task_runner); | 73 RendererSchedulerImpl(scoped_refptr<SchedulerTqmDelegate> main_task_runner); |
| 42 ~RendererSchedulerImpl() override; | 74 ~RendererSchedulerImpl() override; |
| 43 | 75 |
| 44 // RendererScheduler implementation: | 76 // RendererScheduler implementation: |
| 45 std::unique_ptr<blink::WebThread> CreateMainThread() override; | 77 std::unique_ptr<blink::WebThread> CreateMainThread() override; |
| 46 scoped_refptr<TaskQueue> DefaultTaskRunner() override; | 78 scoped_refptr<TaskQueue> DefaultTaskRunner() override; |
| 47 scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() override; | 79 scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() override; |
| 48 scoped_refptr<TaskQueue> CompositorTaskRunner() override; | 80 scoped_refptr<TaskQueue> CompositorTaskRunner() override; |
| 49 scoped_refptr<TaskQueue> LoadingTaskRunner() override; | 81 scoped_refptr<TaskQueue> LoadingTaskRunner() override; |
| 50 scoped_refptr<TaskQueue> TimerTaskRunner() override; | 82 scoped_refptr<TaskQueue> TimerTaskRunner() override; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 74 bool CanExceedIdleDeadlineIfRequired() const override; | 106 bool CanExceedIdleDeadlineIfRequired() const override; |
| 75 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; | 107 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; |
| 76 void RemoveTaskObserver( | 108 void RemoveTaskObserver( |
| 77 base::MessageLoop::TaskObserver* task_observer) override; | 109 base::MessageLoop::TaskObserver* task_observer) override; |
| 78 void Shutdown() override; | 110 void Shutdown() override; |
| 79 void SuspendTimerQueue() override; | 111 void SuspendTimerQueue() override; |
| 80 void ResumeTimerQueue() override; | 112 void ResumeTimerQueue() override; |
| 81 void SetTimerQueueSuspensionWhenBackgroundedEnabled(bool enabled) override; | 113 void SetTimerQueueSuspensionWhenBackgroundedEnabled(bool enabled) override; |
| 82 void SetTopLevelBlameContext( | 114 void SetTopLevelBlameContext( |
| 83 base::trace_event::BlameContext* blame_context) override; | 115 base::trace_event::BlameContext* blame_context) override; |
| 116 void SetRAILModeObserver(RAILModeObserver* observer) override; |
| 84 | 117 |
| 85 // RenderWidgetSignals::Observer implementation: | 118 // RenderWidgetSignals::Observer implementation: |
| 86 void SetAllRenderWidgetsHidden(bool hidden) override; | 119 void SetAllRenderWidgetsHidden(bool hidden) override; |
| 87 void SetHasVisibleRenderWidgetWithTouchHandler( | 120 void SetHasVisibleRenderWidgetWithTouchHandler( |
| 88 bool has_visible_render_widget_with_touch_handler) override; | 121 bool has_visible_render_widget_with_touch_handler) override; |
| 89 | 122 |
| 90 // SchedulerHelper::Observer implementation: | 123 // SchedulerHelper::Observer implementation: |
| 91 void OnUnregisterTaskQueue(const scoped_refptr<TaskQueue>& queue) override; | 124 void OnUnregisterTaskQueue(const scoped_refptr<TaskQueue>& queue) override; |
| 92 void OnTriedToExecuteBlockedTask(const TaskQueue& queue, | 125 void OnTriedToExecuteBlockedTask(const TaskQueue& queue, |
| 93 const base::PendingTask& task) override; | 126 const base::PendingTask& task) override; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 return is_enabled == other.is_enabled && priority == other.priority && | 181 return is_enabled == other.is_enabled && priority == other.priority && |
| 149 time_domain_type == other.time_domain_type; | 182 time_domain_type == other.time_domain_type; |
| 150 } | 183 } |
| 151 }; | 184 }; |
| 152 | 185 |
| 153 struct Policy { | 186 struct Policy { |
| 154 TaskQueuePolicy compositor_queue_policy; | 187 TaskQueuePolicy compositor_queue_policy; |
| 155 TaskQueuePolicy loading_queue_policy; | 188 TaskQueuePolicy loading_queue_policy; |
| 156 TaskQueuePolicy timer_queue_policy; | 189 TaskQueuePolicy timer_queue_policy; |
| 157 TaskQueuePolicy default_queue_policy; | 190 TaskQueuePolicy default_queue_policy; |
| 191 v8::RAILMode rail_mode = v8::PERFORMANCE_ANIMATION; |
| 158 | 192 |
| 159 bool operator==(const Policy& other) const { | 193 bool operator==(const Policy& other) const { |
| 160 return compositor_queue_policy == other.compositor_queue_policy && | 194 return compositor_queue_policy == other.compositor_queue_policy && |
| 161 loading_queue_policy == other.loading_queue_policy && | 195 loading_queue_policy == other.loading_queue_policy && |
| 162 timer_queue_policy == other.timer_queue_policy && | 196 timer_queue_policy == other.timer_queue_policy && |
| 163 default_queue_policy == other.default_queue_policy; | 197 default_queue_policy == other.default_queue_policy && |
| 198 rail_mode == other.rail_mode; |
| 164 } | 199 } |
| 165 }; | 200 }; |
| 166 | 201 |
| 167 class PollableNeedsUpdateFlag { | 202 class PollableNeedsUpdateFlag { |
| 168 public: | 203 public: |
| 169 PollableNeedsUpdateFlag(base::Lock* write_lock); | 204 PollableNeedsUpdateFlag(base::Lock* write_lock); |
| 170 ~PollableNeedsUpdateFlag(); | 205 ~PollableNeedsUpdateFlag(); |
| 171 | 206 |
| 172 // Set the flag. May only be called if |write_lock| is held. | 207 // Set the flag. May only be called if |write_lock| is held. |
| 173 void SetWhileLocked(bool value); | 208 void SetWhileLocked(bool value); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 bool loading_tasks_seem_expensive; | 376 bool loading_tasks_seem_expensive; |
| 342 bool timer_tasks_seem_expensive; | 377 bool timer_tasks_seem_expensive; |
| 343 bool touchstart_expected_soon; | 378 bool touchstart_expected_soon; |
| 344 bool have_seen_a_begin_main_frame; | 379 bool have_seen_a_begin_main_frame; |
| 345 bool have_reported_blocking_intervention_in_current_policy; | 380 bool have_reported_blocking_intervention_in_current_policy; |
| 346 bool have_reported_blocking_intervention_since_navigation; | 381 bool have_reported_blocking_intervention_since_navigation; |
| 347 bool has_visible_render_widget_with_touch_handler; | 382 bool has_visible_render_widget_with_touch_handler; |
| 348 bool begin_frame_not_expected_soon; | 383 bool begin_frame_not_expected_soon; |
| 349 bool expensive_task_blocking_allowed; | 384 bool expensive_task_blocking_allowed; |
| 350 bool in_idle_period_for_testing; | 385 bool in_idle_period_for_testing; |
| 351 std::set<WebViewSchedulerImpl*> web_view_schedulers_; // Not owned. | 386 std::set<WebViewSchedulerImpl*> web_view_schedulers; // Not owned. |
| 387 RAILModeObserver* rail_mode_observer; // Not owned. |
| 352 }; | 388 }; |
| 353 | 389 |
| 354 struct AnyThread { | 390 struct AnyThread { |
| 355 AnyThread(); | 391 AnyThread(); |
| 356 ~AnyThread(); | 392 ~AnyThread(); |
| 357 | 393 |
| 358 base::TimeTicks last_idle_period_end_time; | 394 base::TimeTicks last_idle_period_end_time; |
| 359 base::TimeTicks rails_loading_priority_deadline; | 395 base::TimeTicks rails_loading_priority_deadline; |
| 360 base::TimeTicks fling_compositor_escalation_deadline; | 396 base::TimeTicks fling_compositor_escalation_deadline; |
| 361 UserModel user_model; | 397 UserModel user_model; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 453 |
| 418 PollableThreadSafeFlag policy_may_need_update_; | 454 PollableThreadSafeFlag policy_may_need_update_; |
| 419 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; | 455 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; |
| 420 | 456 |
| 421 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); | 457 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); |
| 422 }; | 458 }; |
| 423 | 459 |
| 424 } // namespace scheduler | 460 } // namespace scheduler |
| 425 | 461 |
| 426 #endif // COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_ | 462 #endif // COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_IMPL_H_ |
| OLD | NEW |