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 THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER
_H_ |
6 #define COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_ | 6 #define THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER
_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "components/scheduler/child/child_scheduler.h" | 12 #include "public/platform/scheduler/child/child_scheduler.h" |
13 #include "components/scheduler/child/single_thread_idle_task_runner.h" | 13 #include "public/platform/scheduler/child/single_thread_idle_task_runner.h" |
14 #include "components/scheduler/renderer/render_widget_scheduling_state.h" | 14 #include "public/platform/scheduler/renderer/render_widget_scheduling_state.h" |
15 #include "components/scheduler/scheduler_export.h" | 15 #include "public/platform/WebCommon.h" |
16 #include "third_party/WebKit/public/platform/WebScheduler.h" | 16 #include "public/platform/WebInputEvent.h" |
17 #include "third_party/WebKit/public/web/WebInputEvent.h" | 17 #include "public/platform/WebScheduler.h" |
18 #include "v8/include/v8.h" | 18 #include "v8/include/v8.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 namespace trace_event { | 21 namespace trace_event { |
22 class BlameContext; | 22 class BlameContext; |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 namespace cc { | 26 namespace cc { |
27 struct BeginFrameArgs; | 27 struct BeginFrameArgs; |
28 } | 28 } |
29 | 29 |
30 namespace blink { | 30 namespace blink { |
31 class WebLocalFrame; | 31 class WebLocalFrame; |
32 class WebThread; | 32 class WebThread; |
33 } | 33 } |
34 | 34 |
| 35 namespace blink { |
35 namespace scheduler { | 36 namespace scheduler { |
36 | 37 |
37 class RenderWidgetSchedulingState; | 38 class RenderWidgetSchedulingState; |
38 | 39 |
39 class SCHEDULER_EXPORT RendererScheduler : public ChildScheduler { | 40 class BLINK_PLATFORM_EXPORT RendererScheduler : public ChildScheduler { |
40 public: | 41 public: |
41 class SCHEDULER_EXPORT RAILModeObserver { | 42 class BLINK_PLATFORM_EXPORT RAILModeObserver { |
42 public: | 43 public: |
43 virtual ~RAILModeObserver(); | 44 virtual ~RAILModeObserver(); |
44 virtual void OnRAILModeChanged(v8::RAILMode rail_mode) = 0; | 45 virtual void OnRAILModeChanged(v8::RAILMode rail_mode) = 0; |
45 }; | 46 }; |
46 | 47 |
47 ~RendererScheduler() override; | 48 ~RendererScheduler() override; |
48 static std::unique_ptr<RendererScheduler> Create(); | 49 static std::unique_ptr<RendererScheduler> Create(); |
49 | 50 |
50 // Returns the compositor task runner. | 51 // Returns the compositor task runner. |
51 virtual scoped_refptr<TaskQueue> CompositorTaskRunner() = 0; | 52 virtual scoped_refptr<TaskQueue> CompositorTaskRunner() = 0; |
52 | 53 |
53 // Creates a WebThread implementation for the renderer main thread. | 54 // Creates a WebThread implementation for the renderer main thread. |
54 virtual std::unique_ptr<blink::WebThread> CreateMainThread() = 0; | 55 virtual std::unique_ptr<WebThread> CreateMainThread() = 0; |
55 | 56 |
56 // Returns the loading task runner. This queue is intended for tasks related | 57 // Returns the loading task runner. This queue is intended for tasks related |
57 // to resource dispatch, foreground HTML parsing, etc... | 58 // to resource dispatch, foreground HTML parsing, etc... |
58 virtual scoped_refptr<TaskQueue> LoadingTaskRunner() = 0; | 59 virtual scoped_refptr<TaskQueue> LoadingTaskRunner() = 0; |
59 | 60 |
60 // Returns the timer task runner. This queue is intended for DOM Timers. | 61 // Returns the timer task runner. This queue is intended for DOM Timers. |
61 // TODO(alexclarke): Get rid of this default timer queue. | 62 // TODO(alexclarke): Get rid of this default timer queue. |
62 virtual scoped_refptr<TaskQueue> TimerTaskRunner() = 0; | 63 virtual scoped_refptr<TaskQueue> TimerTaskRunner() = 0; |
63 | 64 |
64 // Returns a new loading task runner. This queue is intended for tasks related | 65 // Returns a new loading task runner. This queue is intended for tasks related |
(...skipping 30 matching lines...) Expand all Loading... |
95 EVENT_FORWARDED_TO_MAIN_THREAD, | 96 EVENT_FORWARDED_TO_MAIN_THREAD, |
96 }; | 97 }; |
97 static const char* InputEventStateToString(InputEventState input_event_state); | 98 static const char* InputEventStateToString(InputEventState input_event_state); |
98 | 99 |
99 // Tells the scheduler that the system processed an input event. Called by the | 100 // Tells the scheduler that the system processed an input event. Called by the |
100 // compositor (impl) thread. Note it's expected that every call to | 101 // compositor (impl) thread. Note it's expected that every call to |
101 // DidHandleInputEventOnCompositorThread where |event_state| is | 102 // DidHandleInputEventOnCompositorThread where |event_state| is |
102 // EVENT_FORWARDED_TO_MAIN_THREAD will be followed by a corresponding call | 103 // EVENT_FORWARDED_TO_MAIN_THREAD will be followed by a corresponding call |
103 // to DidHandleInputEventOnMainThread. | 104 // to DidHandleInputEventOnMainThread. |
104 virtual void DidHandleInputEventOnCompositorThread( | 105 virtual void DidHandleInputEventOnCompositorThread( |
105 const blink::WebInputEvent& web_input_event, | 106 const WebInputEvent& web_input_event, |
106 InputEventState event_state) = 0; | 107 InputEventState event_state) = 0; |
107 | 108 |
108 // Tells the scheduler that the system processed an input event. Must be | 109 // Tells the scheduler that the system processed an input event. Must be |
109 // called from the main thread. | 110 // called from the main thread. |
110 virtual void DidHandleInputEventOnMainThread( | 111 virtual void DidHandleInputEventOnMainThread( |
111 const blink::WebInputEvent& web_input_event) = 0; | 112 const WebInputEvent& web_input_event) = 0; |
112 | 113 |
113 // Tells the scheduler that the system is displaying an input animation (e.g. | 114 // Tells the scheduler that the system is displaying an input animation (e.g. |
114 // a fling). Called by the compositor (impl) thread. | 115 // a fling). Called by the compositor (impl) thread. |
115 virtual void DidAnimateForInputOnCompositorThread() = 0; | 116 virtual void DidAnimateForInputOnCompositorThread() = 0; |
116 | 117 |
117 // Tells the scheduler that the renderer process has been backgrounded, i.e., | 118 // Tells the scheduler that the renderer process has been backgrounded, i.e., |
118 // there are no critical, user facing activities (visual, audio, etc...) | 119 // there are no critical, user facing activities (visual, audio, etc...) |
119 // driven by this process. A stricter condition than |OnRendererHidden()|, the | 120 // driven by this process. A stricter condition than |OnRendererHidden()|, the |
120 // process is assumed to be foregrounded when the scheduler is constructed. | 121 // process is assumed to be foregrounded when the scheduler is constructed. |
121 // Must be called on the main thread. | 122 // Must be called on the main thread. |
122 virtual void OnRendererBackgrounded() = 0; | 123 virtual void OnRendererBackgrounded() = 0; |
123 | 124 |
124 // Tells the scheduler that the renderer process has been foregrounded. | 125 // Tells the scheduler that the renderer process has been foregrounded. |
125 // This is the assumed state when the scheduler is constructed. | 126 // This is the assumed state when the scheduler is constructed. |
126 // Must be called on the main thread. | 127 // Must be called on the main thread. |
127 virtual void OnRendererForegrounded() = 0; | 128 virtual void OnRendererForegrounded() = 0; |
128 | 129 |
129 // Tells the scheduler that the render process should be suspended. This can | 130 // Tells the scheduler that the render process should be suspended. This can |
130 // only be done when the renderer is backgrounded. The renderer will be | 131 // only be done when the renderer is backgrounded. The renderer will be |
131 // automatically resumed when foregrounded. | 132 // automatically resumed when foregrounded. |
132 virtual void SuspendRenderer() = 0; | 133 virtual void SuspendRenderer() = 0; |
133 | 134 |
134 // Tells the scheduler that a navigation task is pending. While any main-frame | 135 // Tells the scheduler that a navigation task is pending. While any main-frame |
135 // navigation tasks are pending, the scheduler will ensure that loading tasks | 136 // navigation tasks are pending, the scheduler will ensure that loading tasks |
136 // are not blocked even if they are expensive. Must be called on the main | 137 // are not blocked even if they are expensive. Must be called on the main |
137 // thread. | 138 // thread. |
138 virtual void AddPendingNavigation( | 139 virtual void AddPendingNavigation(WebScheduler::NavigatingFrameType type) = 0; |
139 blink::WebScheduler::NavigatingFrameType type) = 0; | |
140 | 140 |
141 // Tells the scheduler that a navigation task is no longer pending. | 141 // Tells the scheduler that a navigation task is no longer pending. |
142 // Must be called on the main thread. | 142 // Must be called on the main thread. |
143 virtual void RemovePendingNavigation( | 143 virtual void RemovePendingNavigation( |
144 blink::WebScheduler::NavigatingFrameType type) = 0; | 144 WebScheduler::NavigatingFrameType type) = 0; |
145 | 145 |
146 // Tells the scheduler that a navigation has started. The scheduler will | 146 // Tells the scheduler that a navigation has started. The scheduler will |
147 // prioritize loading tasks for a short duration afterwards. | 147 // prioritize loading tasks for a short duration afterwards. |
148 // Must be called from the main thread. | 148 // Must be called from the main thread. |
149 virtual void OnNavigationStarted() = 0; | 149 virtual void OnNavigationStarted() = 0; |
150 | 150 |
151 // Returns true if the scheduler has reason to believe that high priority work | 151 // Returns true if the scheduler has reason to believe that high priority work |
152 // may soon arrive on the main thread, e.g., if gesture events were observed | 152 // may soon arrive on the main thread, e.g., if gesture events were observed |
153 // recently. | 153 // recently. |
154 // Must be called from the main thread. | 154 // Must be called from the main thread. |
(...skipping 22 matching lines...) Expand all Loading... |
177 // [1] | 177 // [1] |
178 // https://developers.google.com/web/tools/chrome-devtools/profile/evaluate-pe
rformance/rail | 178 // https://developers.google.com/web/tools/chrome-devtools/profile/evaluate-pe
rformance/rail |
179 virtual void SetRAILModeObserver(RAILModeObserver* observer) = 0; | 179 virtual void SetRAILModeObserver(RAILModeObserver* observer) = 0; |
180 | 180 |
181 protected: | 181 protected: |
182 RendererScheduler(); | 182 RendererScheduler(); |
183 DISALLOW_COPY_AND_ASSIGN(RendererScheduler); | 183 DISALLOW_COPY_AND_ASSIGN(RendererScheduler); |
184 }; | 184 }; |
185 | 185 |
186 } // namespace scheduler | 186 } // namespace scheduler |
| 187 } // namespace blink |
187 | 188 |
188 #endif // COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_ | 189 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU
LER_H_ |
OLD | NEW |