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_H_ | 5 #ifndef COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_ |
6 #define COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_ | 6 #define COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_ |
7 | 7 |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "components/scheduler/child/child_scheduler.h" | 9 #include "components/scheduler/child/child_scheduler.h" |
10 #include "components/scheduler/child/single_thread_idle_task_runner.h" | 10 #include "components/scheduler/child/single_thread_idle_task_runner.h" |
11 #include "components/scheduler/scheduler_export.h" | 11 #include "components/scheduler/scheduler_export.h" |
12 #include "third_party/WebKit/public/web/WebInputEvent.h" | 12 #include "third_party/WebKit/public/web/WebInputEvent.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 struct BeginFrameArgs; | 15 struct BeginFrameArgs; |
16 } | 16 } |
17 | 17 |
18 namespace scheduler { | 18 namespace scheduler { |
19 | 19 |
20 class SCHEDULER_EXPORT RendererScheduler : public ChildScheduler { | 20 class SCHEDULER_EXPORT RendererScheduler : public ChildScheduler { |
21 public: | 21 public: |
22 ~RendererScheduler() override; | 22 ~RendererScheduler() override; |
23 static scoped_ptr<RendererScheduler> Create(); | 23 static scoped_ptr<RendererScheduler> Create(); |
24 | 24 |
25 // Returns the compositor task runner. | 25 // Returns the compositor task runner. |
26 virtual scoped_refptr<base::SingleThreadTaskRunner> | 26 virtual scoped_refptr<base::SingleThreadTaskRunner> |
27 CompositorTaskRunner() = 0; | 27 CompositorTaskRunner() = 0; |
28 | 28 |
| 29 // Keep RendererScheduler::UseCaseToString in sync with this enum. |
| 30 enum class UseCase { |
| 31 NONE, |
| 32 COMPOSITOR_GESTURE, |
| 33 MAIN_THREAD_GESTURE, |
| 34 TOUCHSTART, |
| 35 LOADING, |
| 36 // Must be the last entry. |
| 37 USE_CASE_COUNT, |
| 38 FIRST_USE_CASE = NONE, |
| 39 }; |
| 40 static const char* UseCaseToString(UseCase use_case); |
| 41 |
29 // Returns the loading task runner. This queue is intended for tasks related | 42 // Returns the loading task runner. This queue is intended for tasks related |
30 // to resource dispatch, foreground HTML parsing, etc... | 43 // to resource dispatch, foreground HTML parsing, etc... |
31 virtual scoped_refptr<base::SingleThreadTaskRunner> LoadingTaskRunner() = 0; | 44 virtual scoped_refptr<base::SingleThreadTaskRunner> LoadingTaskRunner() = 0; |
32 | 45 |
33 // Returns the timer task runner. This queue is intended for DOM Timers. | 46 // Returns the timer task runner. This queue is intended for DOM Timers. |
34 virtual scoped_refptr<TaskQueue> TimerTaskRunner() = 0; | 47 virtual scoped_refptr<TaskQueue> TimerTaskRunner() = 0; |
35 | 48 |
36 // Called to notify about the start of an extended period where no frames | 49 // Called to notify about the start of an extended period where no frames |
37 // need to be drawn. Must be called from the main thread. | 50 // need to be drawn. Must be called from the main thread. |
38 virtual void BeginFrameNotExpectedSoon() = 0; | 51 virtual void BeginFrameNotExpectedSoon() = 0; |
39 | 52 |
40 // Called to notify about the start of a new frame. Must be called from the | 53 // Called to notify about the start of a new frame. Must be called from the |
41 // main thread. | 54 // main thread. |
42 virtual void WillBeginFrame(const cc::BeginFrameArgs& args) = 0; | 55 virtual void WillBeginFrame(const cc::BeginFrameArgs& args) = 0; |
43 | 56 |
44 // Called to notify that a previously begun frame was committed. Must be | 57 // Called to notify that a previously begun frame was committed. Must be |
45 // called from the main thread. | 58 // called from the main thread. |
46 virtual void DidCommitFrameToCompositor() = 0; | 59 virtual void DidCommitFrameToCompositor() = 0; |
47 | 60 |
| 61 // Keep RendererScheduler::InputEventStateToString in sync with this enum. |
48 enum class InputEventState { | 62 enum class InputEventState { |
49 EVENT_CONSUMED_BY_COMPOSITOR, | 63 EVENT_CONSUMED_BY_COMPOSITOR, |
50 EVENT_FORWARDED_TO_MAIN_THREAD, | 64 EVENT_FORWARDED_TO_MAIN_THREAD, |
51 }; | 65 }; |
| 66 static const char* InputEventStateToString(InputEventState input_event_state); |
52 | 67 |
53 // Tells the scheduler that the system processed an input event. Called by the | 68 // Tells the scheduler that the system processed an input event. Called by the |
54 // compositor (impl) thread. Note it's expected that every call to | 69 // compositor (impl) thread. Note it's expected that every call to |
55 // DidHandleInputEventOnCompositorThread where |event_state| is | 70 // DidHandleInputEventOnCompositorThread where |event_state| is |
56 // EVENT_FORWARDED_TO_MAIN_THREAD will be followed by a corresponding call | 71 // EVENT_FORWARDED_TO_MAIN_THREAD will be followed by a corresponding call |
57 // to DidHandleInputEventOnMainThread. | 72 // to DidHandleInputEventOnMainThread. |
58 virtual void DidHandleInputEventOnCompositorThread( | 73 virtual void DidHandleInputEventOnCompositorThread( |
59 const blink::WebInputEvent& web_input_event, | 74 const blink::WebInputEvent& web_input_event, |
60 InputEventState event_state) = 0; | 75 InputEventState event_state) = 0; |
61 | 76 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 virtual void SetTimerQueueSuspensionWhenBackgroundedEnabled(bool enabled) = 0; | 130 virtual void SetTimerQueueSuspensionWhenBackgroundedEnabled(bool enabled) = 0; |
116 | 131 |
117 protected: | 132 protected: |
118 RendererScheduler(); | 133 RendererScheduler(); |
119 DISALLOW_COPY_AND_ASSIGN(RendererScheduler); | 134 DISALLOW_COPY_AND_ASSIGN(RendererScheduler); |
120 }; | 135 }; |
121 | 136 |
122 } // namespace scheduler | 137 } // namespace scheduler |
123 | 138 |
124 #endif // COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_ | 139 #endif // COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_ |
OLD | NEW |