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

Side by Side Diff: content/browser/renderer_host/input/touch_event_queue.h

Issue 997283002: Coalesce async touch move events until the ack back from render (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit tests Created 5 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // single touch-move event). The event may also be immediately forwarded to 59 // single touch-move event). The event may also be immediately forwarded to
60 // the renderer (e.g. when there are no other queued touch event). 60 // the renderer (e.g. when there are no other queued touch event).
61 void QueueEvent(const TouchEventWithLatencyInfo& event); 61 void QueueEvent(const TouchEventWithLatencyInfo& event);
62 62
63 // Notifies the queue that a touch-event has been processed by the renderer. 63 // Notifies the queue that a touch-event has been processed by the renderer.
64 // At this point, the queue may send one or more gesture events and/or 64 // At this point, the queue may send one or more gesture events and/or
65 // additional queued touch-events to the renderer. 65 // additional queued touch-events to the renderer.
66 void ProcessTouchAck(InputEventAckState ack_result, 66 void ProcessTouchAck(InputEventAckState ack_result,
67 const ui::LatencyInfo& latency_info); 67 const ui::LatencyInfo& latency_info);
68 68
69 void ProcessUncancelableTouchMoveAck();
70
69 // When GestureScrollBegin is received, we send a touch cancel to renderer, 71 // When GestureScrollBegin is received, we send a touch cancel to renderer,
70 // route all the following touch events directly to client, and ignore the 72 // route all the following touch events directly to client, and ignore the
71 // ack for the touch cancel. When Gesture{ScrollEnd,FlingStart} is received, 73 // ack for the touch cancel. When Gesture{ScrollEnd,FlingStart} is received,
72 // resume the normal flow of sending touch events to the renderer. 74 // resume the normal flow of sending touch events to the renderer.
73 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event); 75 void OnGestureScrollEvent(const GestureEventWithLatencyInfo& gesture_event);
74 76
75 void OnGestureEventAck( 77 void OnGestureEventAck(
76 const GestureEventWithLatencyInfo& event, 78 const GestureEventWithLatencyInfo& event,
77 InputEventAckState ack_result); 79 InputEventAckState ack_result);
78 80
(...skipping 16 matching lines...) Expand all
95 bool empty() const WARN_UNUSED_RESULT { 97 bool empty() const WARN_UNUSED_RESULT {
96 return touch_queue_.empty(); 98 return touch_queue_.empty();
97 } 99 }
98 100
99 size_t size() const { 101 size_t size() const {
100 return touch_queue_.size(); 102 return touch_queue_.size();
101 } 103 }
102 104
103 bool has_handlers() const { return has_handlers_; } 105 bool has_handlers() const { return has_handlers_; }
104 106
107 int PendingUncancelableEventAckCount() const {
108 return pending_uncancelable_event_ack_count_;
109 }
110
111 int SentUncancelableTouchMoveCount() const {
112 return sent_uncancelable_touch_move_count_;
113 }
114
105 private: 115 private:
106 class TouchTimeoutHandler; 116 class TouchTimeoutHandler;
107 class TouchMoveSlopSuppressor; 117 class TouchMoveSlopSuppressor;
108 friend class TouchTimeoutHandler; 118 friend class TouchTimeoutHandler;
109 friend class TouchEventQueueTest; 119 friend class TouchEventQueueTest;
110 120
111 bool HasPendingAsyncTouchMoveForTesting() const; 121 bool HasPendingAsyncTouchMoveForTesting() const;
112 bool IsTimeoutRunningForTesting() const; 122 bool IsTimeoutRunningForTesting() const;
113 const TouchEventWithLatencyInfo& GetLatestEventForTesting() const; 123 const TouchEventWithLatencyInfo& GetLatestEventForTesting() const;
114 124
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // been preventDefaulted. 205 // been preventDefaulted.
196 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_; 206 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_;
197 207
198 // Whether touch events should remain buffered and dispatched asynchronously 208 // Whether touch events should remain buffered and dispatched asynchronously
199 // while a scroll sequence is active. In this mode, touchmove's are throttled 209 // while a scroll sequence is active. In this mode, touchmove's are throttled
200 // and ack'ed immediately, but remain buffered in |pending_async_touchmove_| 210 // and ack'ed immediately, but remain buffered in |pending_async_touchmove_|
201 // until a sufficient time period has elapsed since the last sent touch event. 211 // until a sufficient time period has elapsed since the last sent touch event.
202 // For details see the design doc at http://goo.gl/lVyJAa. 212 // For details see the design doc at http://goo.gl/lVyJAa.
203 bool send_touch_events_async_; 213 bool send_touch_events_async_;
204 scoped_ptr<TouchEventWithLatencyInfo> pending_async_touchmove_; 214 scoped_ptr<TouchEventWithLatencyInfo> pending_async_touchmove_;
215
216 // Once this value is greater than 0, which means we should ignore the
217 // following ignore_ack_ numbers of acks from render for async touch moves.
218 int pending_uncancelable_event_ack_count_;
219
220 // For uncancelable touch moves, not only we send a fake ack, but also a real
221 // ack from render, which we use to decide when to send the next touch move.
222 // This can help avoid the touch event queue keep growing when render handles
223 // touchmove slow. We use sent_uncancelable_touch_move_count_ to count the
224 // number of uncancelable touch moves sent out are waiting for
225 // their acks back from render.
226 int sent_uncancelable_touch_move_count_;
tdresser 2015/03/25 14:16:18 I'm still not clear on why we need both pending_un
205 double last_sent_touch_timestamp_sec_; 227 double last_sent_touch_timestamp_sec_;
206 228
207 // Event is saved to compare pointer positions for new touchmove events. 229 // Event is saved to compare pointer positions for new touchmove events.
208 scoped_ptr<blink::WebTouchEvent> last_sent_touchevent_; 230 scoped_ptr<blink::WebTouchEvent> last_sent_touchevent_;
209 231
210 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); 232 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue);
211 }; 233 };
212 234
213 } // namespace content 235 } // namespace content
214 236
215 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ 237 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698