OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_ | 5 #ifndef CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_ |
6 #define CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_ | 6 #define CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
11 #include "content/common/input/event_with_latency_info.h" | 11 #include "content/common/input/event_with_latency_info.h" |
12 #include "content/common/input/input_event_ack_state.h" | 12 #include "content/common/input/input_event_ack_state.h" |
13 #include "content/common/input/input_event_dispatch_type.h" | 13 #include "content/common/input/input_event_dispatch_type.h" |
14 #include "content/common/input/web_input_event_queue.h" | 14 #include "content/common/input/web_input_event_queue.h" |
15 #include "content/public/common/content_features.h" | 15 #include "content/public/common/content_features.h" |
16 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 16 #include "third_party/WebKit/public/platform/CoalescedWebInputEvent.h" |
17 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" | 17 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" |
18 #include "ui/events/blink/web_input_event_traits.h" | 18 #include "ui/events/blink/web_input_event_traits.h" |
19 #include "ui/events/latency_info.h" | 19 #include "ui/events/latency_info.h" |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 | 22 |
23 class EventWithDispatchType : public ScopedWebInputEventWithLatencyInfo { | 23 class EventWithDispatchType : public ScopedWebInputEventWithLatencyInfo { |
24 public: | 24 public: |
25 EventWithDispatchType(ui::ScopedWebInputEvent event, | 25 EventWithDispatchType( |
26 const ui::LatencyInfo& latency, | 26 blink::CoalescedWebInputEvent::ScopedWebInputEvent event, |
27 InputEventDispatchType dispatch_type); | 27 const ui::LatencyInfo& latency, |
| 28 InputEventDispatchType dispatch_type); |
28 ~EventWithDispatchType(); | 29 ~EventWithDispatchType(); |
29 bool CanCoalesceWith(const EventWithDispatchType& other) const | 30 bool CanCoalesceWith(const EventWithDispatchType& other) const |
30 WARN_UNUSED_RESULT; | 31 WARN_UNUSED_RESULT; |
31 void CoalesceWith(const EventWithDispatchType& other); | 32 void CoalesceWith(const EventWithDispatchType& other); |
32 | 33 |
33 const std::deque<uint32_t>& coalescedEventIds() const { | 34 const std::deque<uint32_t>& coalescedEventIds() const { |
34 return coalesced_event_ids_; | 35 return coalesced_event_ids_; |
35 } | 36 } |
36 InputEventDispatchType dispatchType() const { return dispatch_type_; } | 37 InputEventDispatchType dispatchType() const { return dispatch_type_; } |
37 base::TimeTicks creationTimestamp() const { return creation_timestamp_; } | 38 base::TimeTicks creationTimestamp() const { return creation_timestamp_; } |
(...skipping 13 matching lines...) Expand all Loading... |
51 base::TimeTicks last_coalesced_timestamp_; | 52 base::TimeTicks last_coalesced_timestamp_; |
52 }; | 53 }; |
53 | 54 |
54 class CONTENT_EXPORT MainThreadEventQueueClient { | 55 class CONTENT_EXPORT MainThreadEventQueueClient { |
55 public: | 56 public: |
56 // Handle an |event| that was previously queued (possibly | 57 // Handle an |event| that was previously queued (possibly |
57 // coalesced with another event) to the |routing_id|'s | 58 // coalesced with another event) to the |routing_id|'s |
58 // channel. Implementors must implement this callback. | 59 // channel. Implementors must implement this callback. |
59 virtual void HandleEventOnMainThread( | 60 virtual void HandleEventOnMainThread( |
60 int routing_id, | 61 int routing_id, |
61 const blink::WebInputEvent* event, | 62 const blink::CoalescedWebInputEvent* event, |
62 const ui::LatencyInfo& latency, | 63 const ui::LatencyInfo& latency, |
63 InputEventDispatchType dispatch_type) = 0; | 64 InputEventDispatchType dispatch_type) = 0; |
64 | 65 |
65 virtual void SendInputEventAck(int routing_id, | 66 virtual void SendInputEventAck(int routing_id, |
66 blink::WebInputEvent::Type type, | 67 blink::WebInputEvent::Type type, |
67 InputEventAckState ack_result, | 68 InputEventAckState ack_result, |
68 uint32_t touch_event_id) = 0; | 69 uint32_t touch_event_id) = 0; |
69 virtual void NeedsMainFrame(int routing_id) = 0; | 70 virtual void NeedsMainFrame(int routing_id) = 0; |
70 }; | 71 }; |
71 | 72 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 : public base::RefCountedThreadSafe<MainThreadEventQueue> { | 110 : public base::RefCountedThreadSafe<MainThreadEventQueue> { |
110 public: | 111 public: |
111 MainThreadEventQueue( | 112 MainThreadEventQueue( |
112 int routing_id, | 113 int routing_id, |
113 MainThreadEventQueueClient* client, | 114 MainThreadEventQueueClient* client, |
114 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, | 115 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, |
115 blink::scheduler::RendererScheduler* renderer_scheduler); | 116 blink::scheduler::RendererScheduler* renderer_scheduler); |
116 | 117 |
117 // Called once the compositor has handled |event| and indicated that it is | 118 // Called once the compositor has handled |event| and indicated that it is |
118 // a non-blocking event to be queued to the main thread. | 119 // a non-blocking event to be queued to the main thread. |
119 bool HandleEvent(ui::ScopedWebInputEvent event, | 120 bool HandleEvent(blink::CoalescedWebInputEvent::ScopedWebInputEvent event, |
120 const ui::LatencyInfo& latency, | 121 const ui::LatencyInfo& latency, |
121 InputEventDispatchType dispatch_type, | 122 InputEventDispatchType dispatch_type, |
122 InputEventAckState ack_result); | 123 InputEventAckState ack_result); |
123 void DispatchRafAlignedInput(); | 124 void DispatchRafAlignedInput(); |
124 | 125 |
125 // Call once the main thread has handled an outstanding |type| event | 126 // Call once the main thread has handled an outstanding |type| event |
126 // in flight. | 127 // in flight. |
127 void EventHandled(blink::WebInputEvent::Type type, | 128 void EventHandled(blink::WebInputEvent::Type type, |
128 InputEventAckState ack_result); | 129 InputEventAckState ack_result); |
129 | 130 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 168 |
168 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 169 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
169 blink::scheduler::RendererScheduler* renderer_scheduler_; | 170 blink::scheduler::RendererScheduler* renderer_scheduler_; |
170 | 171 |
171 DISALLOW_COPY_AND_ASSIGN(MainThreadEventQueue); | 172 DISALLOW_COPY_AND_ASSIGN(MainThreadEventQueue); |
172 }; | 173 }; |
173 | 174 |
174 } // namespace content | 175 } // namespace content |
175 | 176 |
176 #endif // CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_ | 177 #endif // CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_ |
OLD | NEW |