Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ | |
| 6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ | |
| 7 | |
| 8 #include "base/atomicops.h" | |
| 9 #include "base/synchronization/lock.h" | |
| 10 #include "base/threading/thread_checker.h" | |
| 11 #include "content/renderer/scheduler/renderer_scheduler.h" | |
| 12 #include "content/renderer/scheduler/single_thread_idle_task_runner.h" | |
| 13 #include "content/renderer/scheduler/task_queue_manager.h" | |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 class RendererTaskQueueSelector; | |
| 18 | |
| 19 class RendererSchedulerImpl : public RendererScheduler, | |
| 20 private IdleTaskDeadlineSupplier { | |
| 21 public: | |
| 22 RendererSchedulerImpl(); | |
|
no sievers
2014/10/30 23:40:51
is this constructor needed?
rmcilroy
2014/11/03 19:02:52
Good point, replaced it with the previously protec
| |
| 23 ~RendererSchedulerImpl() override; | |
|
no sievers
2014/10/30 23:40:51
nit: can this be protected?
rmcilroy
2014/11/03 19:02:52
Unfortunately not since we wrap it in a scoped_ptr
| |
| 24 | |
| 25 // RendererScheduler implementation: | |
| 26 scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner() override; | |
| 27 scoped_refptr<base::SingleThreadTaskRunner> CompositorTaskRunner() override; | |
| 28 scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() override; | |
| 29 void WillBeginFrame(const cc::BeginFrameArgs& args) override; | |
| 30 void DidCommitFrameToCompositor() override; | |
| 31 void DidReceiveInputEvent() override; | |
| 32 bool ShouldYieldForHighPriorityWork() override; | |
| 33 void Shutdown() override; | |
| 34 | |
| 35 protected: | |
| 36 RendererSchedulerImpl( | |
| 37 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | |
| 38 | |
| 39 // Virtual for testing. | |
| 40 virtual base::TimeTicks Now() const; | |
| 41 | |
| 42 private: | |
| 43 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); | |
|
no sievers
2014/10/30 23:40:51
nit: make this the last thing in the class (style-
rmcilroy
2014/11/03 19:02:52
Done.
| |
| 44 friend base::WeakPtr<content::IdleTaskDeadlineSupplier>; | |
| 45 friend class RendererSchedulerImplTest; | |
| 46 | |
| 47 enum QueueId { | |
| 48 DEFAULT_TASK_QUEUE, | |
| 49 COMPOSITOR_TASK_QUEUE, | |
| 50 IDLE_TASK_QUEUE, | |
| 51 CONTROL_TASK_QUEUE, | |
| 52 // Must be the last entry. | |
| 53 TASK_QUEUE_COUNT, | |
| 54 }; | |
| 55 | |
| 56 enum Policy { | |
| 57 NORMAL_PRIORITY_POLICY, | |
| 58 COMPOSITOR_PRIORITY_POLICY, | |
| 59 }; | |
| 60 | |
| 61 // The time we should stay in CompositorPriority mode for after a touch event. | |
| 62 static const int kCompositorPriorityAfterTouchMillis = 100; | |
|
no sievers
2014/10/30 23:40:51
So this covers multiple frames. So we are basicall
alex clarke (OOO till 29th)
2014/11/03 17:39:34
Yes the idea is we want smooth and responsive scro
rmcilroy
2014/11/03 19:02:52
Yes that is the idea, we try to stay in compositor
| |
| 63 | |
| 64 // IdleTaskDeadlineSupplier Implementation: | |
| 65 base::TimeTicks CurrentIdleTaskDeadline() const override; | |
| 66 | |
| 67 // Returns the current scheduler policy. This may involve updating the | |
| 68 // current policy if a new signal has arrived. Must be called from the main | |
| 69 // thread. | |
| 70 Policy SchedulerPolicy(); | |
| 71 | |
| 72 // Posts a call to UpdatePolicy on the control runner to be run after |delay| | |
| 73 void PostUpdatePolicyOnControlRunner(base::TimeDelta delay); | |
| 74 | |
| 75 // Updates the scheduler policy. Must be called from the main thread. | |
| 76 void UpdatePolicy(); | |
| 77 | |
| 78 // Start and end an idle period. | |
| 79 void StartIdlePeriod(); | |
| 80 void EndIdlePeriod(); | |
| 81 | |
| 82 base::ThreadChecker main_thread_checker_; | |
| 83 scoped_ptr<RendererTaskQueueSelector> renderer_task_queue_selector_; | |
| 84 scoped_ptr<TaskQueueManager> task_queue_manager_; | |
| 85 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; | |
| 86 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_; | |
| 87 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; | |
| 88 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_; | |
| 89 | |
| 90 // Don't access current_policy_ directly, instead use SchedulerPolicy(). | |
| 91 Policy current_policy_; | |
| 92 | |
| 93 base::TimeTicks estimated_next_frame_begin_; | |
| 94 | |
| 95 // The incoming_signals_lock_ mutex protects access to last_input_time_ | |
| 96 // and write access to policy_may_need_update_. | |
| 97 base::Lock incoming_signals_lock_; | |
| 98 base::TimeTicks last_input_time_; | |
| 99 base::subtle::AtomicWord policy_may_need_update_; | |
| 100 | |
| 101 base::WeakPtr<RendererSchedulerImpl> weak_renderer_scheduler_ptr_; | |
| 102 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; | |
| 103 }; | |
| 104 | |
| 105 } // namespace content | |
| 106 | |
| 107 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ | |
| OLD | NEW |