Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: content/renderer/input/main_thread_event_queue.h

Issue 2713093005: Teach MainThreadEventQueue about touchmove throttling. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/input_event_ack_state.h" 11 #include "content/common/input/input_event_ack_state.h"
12 #include "content/common/input/input_event_dispatch_type.h" 12 #include "content/common/input/input_event_dispatch_type.h"
13 #include "content/common/input/web_input_event_queue.h" 13 #include "content/common/input/web_input_event_queue.h"
14 #include "content/public/common/content_features.h" 14 #include "content/public/common/content_features.h"
15 #include "content/renderer/input/scoped_web_input_event_with_latency_info.h" 15 #include "content/renderer/input/scoped_web_input_event_with_latency_info.h"
16 #include "third_party/WebKit/public/platform/WebInputEvent.h" 16 #include "third_party/WebKit/public/platform/WebInputEvent.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::WebScopedInputEvent event, 25 EventWithDispatchType(ui::WebScopedInputEvent event,
26 const ui::LatencyInfo& latency, 26 const ui::LatencyInfo& latency,
27 InputEventDispatchType dispatch_type); 27 InputEventDispatchType dispatch_type,
28 bool originally_cancelable);
28 ~EventWithDispatchType(); 29 ~EventWithDispatchType();
29 void CoalesceWith(const EventWithDispatchType& other); 30 void CoalesceWith(const EventWithDispatchType& other);
30 31
31 const std::deque<uint32_t>& blockingCoalescedEventIds() const { 32 const std::deque<uint32_t>& blockingCoalescedEventIds() const {
32 return blocking_coalesced_event_ids_; 33 return blocking_coalesced_event_ids_;
33 } 34 }
34 InputEventDispatchType dispatchType() const { return dispatch_type_; } 35 InputEventDispatchType dispatchType() const { return dispatch_type_; }
35 base::TimeTicks creationTimestamp() const { return creation_timestamp_; } 36 base::TimeTicks creationTimestamp() const { return creation_timestamp_; }
36 base::TimeTicks lastCoalescedTimestamp() const { 37 base::TimeTicks lastCoalescedTimestamp() const {
37 return last_coalesced_timestamp_; 38 return last_coalesced_timestamp_;
38 } 39 }
39 40
40 size_t coalescedCount() const { 41 size_t coalescedCount() const {
41 return non_blocking_coalesced_count_ + blocking_coalesced_event_ids_.size(); 42 return non_blocking_coalesced_count_ + blocking_coalesced_event_ids_.size();
42 } 43 }
43 44
45 bool originallyCancelable() const { return originally_cancelable_; }
dtapuska 2017/02/24 19:18:48 Happy for another name. It's friday and I didn't h
aelias_OOO_until_Jul13 2017/02/24 20:19:51 It doesn't seem that the additional state adds any
dtapuska 2017/02/24 20:23:35 Not true. dispatch_type_ is whether an ACK needs t
aelias_OOO_until_Jul13 2017/02/24 21:01:14 OK. If I understand correctly, this is a problem
dtapuska 2017/02/24 21:29:41 These dispatch_types_ are of different enums. We r
46
44 private: 47 private:
45 InputEventDispatchType dispatch_type_; 48 InputEventDispatchType dispatch_type_;
46 49
47 // Contains the unique touch event ids to be acked. If 50 // Contains the unique touch event ids to be acked. If
48 // the events are not TouchEvents the values will be 0. More importantly for 51 // the events are not TouchEvents the values will be 0. More importantly for
49 // those cases the deque ends up containing how many additional ACKs 52 // those cases the deque ends up containing how many additional ACKs
50 // need to be sent. 53 // need to be sent.
51 std::deque<uint32_t> blocking_coalesced_event_ids_; 54 std::deque<uint32_t> blocking_coalesced_event_ids_;
52 // Contains the number of non-blocking events coalesced. 55 // Contains the number of non-blocking events coalesced.
53 size_t non_blocking_coalesced_count_; 56 size_t non_blocking_coalesced_count_;
54 base::TimeTicks creation_timestamp_; 57 base::TimeTicks creation_timestamp_;
55 base::TimeTicks last_coalesced_timestamp_; 58 base::TimeTicks last_coalesced_timestamp_;
59
60 // Whether the received event was originally cancelable or not. The compositor
61 // input handler can change the event based on presence of event handlers so
62 // this is the state at which the renderer received the event from the
63 // browser.
64 bool originally_cancelable_;
56 }; 65 };
57 66
58 class CONTENT_EXPORT MainThreadEventQueueClient { 67 class CONTENT_EXPORT MainThreadEventQueueClient {
59 public: 68 public:
60 // Handle an |event| that was previously queued (possibly 69 // Handle an |event| that was previously queued (possibly
61 // coalesced with another event) to the |routing_id|'s 70 // coalesced with another event) to the |routing_id|'s
62 // channel. Implementors must implement this callback. 71 // channel. Implementors must implement this callback.
63 virtual void HandleEventOnMainThread( 72 virtual void HandleEventOnMainThread(
64 int routing_id, 73 int routing_id,
65 const blink::WebCoalescedInputEvent* event, 74 const blink::WebCoalescedInputEvent* event,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 MainThreadEventQueueClient* client, 126 MainThreadEventQueueClient* client,
118 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, 127 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
119 blink::scheduler::RendererScheduler* renderer_scheduler); 128 blink::scheduler::RendererScheduler* renderer_scheduler);
120 129
121 // Called once the compositor has handled |event| and indicated that it is 130 // Called once the compositor has handled |event| and indicated that it is
122 // a non-blocking event to be queued to the main thread. 131 // a non-blocking event to be queued to the main thread.
123 bool HandleEvent(ui::WebScopedInputEvent event, 132 bool HandleEvent(ui::WebScopedInputEvent event,
124 const ui::LatencyInfo& latency, 133 const ui::LatencyInfo& latency,
125 InputEventDispatchType dispatch_type, 134 InputEventDispatchType dispatch_type,
126 InputEventAckState ack_result); 135 InputEventAckState ack_result);
127 void DispatchRafAlignedInput(); 136 void DispatchRafAlignedInput(double frame_time_sec);
128 137
129 // Call once the main thread has handled an outstanding |type| event 138 // Call once the main thread has handled an outstanding |type| event
130 // in flight. 139 // in flight.
131 void EventHandled(blink::WebInputEvent::Type type, 140 void EventHandled(blink::WebInputEvent::Type type,
132 blink::WebInputEventResult result, 141 blink::WebInputEventResult result,
133 InputEventAckState ack_result); 142 InputEventAckState ack_result);
134 143
135 private: 144 private:
136 friend class base::RefCountedThreadSafe<MainThreadEventQueue>; 145 friend class base::RefCountedThreadSafe<MainThreadEventQueue>;
137 ~MainThreadEventQueue(); 146 ~MainThreadEventQueue();
(...skipping 22 matching lines...) Expand all
160 bool handle_raf_aligned_touch_input_; 169 bool handle_raf_aligned_touch_input_;
161 bool handle_raf_aligned_mouse_input_; 170 bool handle_raf_aligned_mouse_input_;
162 171
163 // Contains data to be shared between main thread and compositor thread. 172 // Contains data to be shared between main thread and compositor thread.
164 struct SharedState { 173 struct SharedState {
165 SharedState(); 174 SharedState();
166 ~SharedState(); 175 ~SharedState();
167 176
168 WebInputEventQueue<EventWithDispatchType> events_; 177 WebInputEventQueue<EventWithDispatchType> events_;
169 bool sent_main_frame_request_; 178 bool sent_main_frame_request_;
179 double last_async_touch_move_timestamp_;
170 }; 180 };
171 181
172 // Lock used to serialize |shared_state_|. 182 // Lock used to serialize |shared_state_|.
173 base::Lock shared_state_lock_; 183 base::Lock shared_state_lock_;
174 SharedState shared_state_; 184 SharedState shared_state_;
175 185
176 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 186 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
177 blink::scheduler::RendererScheduler* renderer_scheduler_; 187 blink::scheduler::RendererScheduler* renderer_scheduler_;
178 188
179 DISALLOW_COPY_AND_ASSIGN(MainThreadEventQueue); 189 DISALLOW_COPY_AND_ASSIGN(MainThreadEventQueue);
180 }; 190 };
181 191
182 } // namespace content 192 } // namespace content
183 193
184 #endif // CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_ 194 #endif // CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698