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

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: 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 UncancelableTouchMovesPendingAckCount() const {
108 return uncancelable_touch_moves_pending_ack_count_;
109 }
110
105 private: 111 private:
106 class TouchTimeoutHandler; 112 class TouchTimeoutHandler;
107 class TouchMoveSlopSuppressor; 113 class TouchMoveSlopSuppressor;
108 friend class TouchTimeoutHandler; 114 friend class TouchTimeoutHandler;
109 friend class TouchEventQueueTest; 115 friend class TouchEventQueueTest;
110 116
111 bool HasPendingAsyncTouchMoveForTesting() const; 117 bool HasPendingAsyncTouchMoveForTesting() const;
112 bool IsTimeoutRunningForTesting() const; 118 bool IsTimeoutRunningForTesting() const;
113 const TouchEventWithLatencyInfo& GetLatestEventForTesting() const; 119 const TouchEventWithLatencyInfo& GetLatestEventForTesting() const;
114 120
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // been preventDefaulted. 201 // been preventDefaulted.
196 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_; 202 scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_;
197 203
198 // Whether touch events should remain buffered and dispatched asynchronously 204 // Whether touch events should remain buffered and dispatched asynchronously
199 // while a scroll sequence is active. In this mode, touchmove's are throttled 205 // 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_| 206 // 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. 207 // 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. 208 // For details see the design doc at http://goo.gl/lVyJAa.
203 bool send_touch_events_async_; 209 bool send_touch_events_async_;
204 scoped_ptr<TouchEventWithLatencyInfo> pending_async_touchmove_; 210 scoped_ptr<TouchEventWithLatencyInfo> pending_async_touchmove_;
211
212 // For uncancelable touch moves, not only we send a fake ack, but also a real
213 // ack from render, which we use to decide when to send the next async
214 // touchmove. This can help avoid the touch event queue keep growing when
215 // render handles touchmove slow. We use
216 // uncancelable_touch_moves_pending_ack_count_ to count the number of
217 // dispatched uncancelable touchmoves which are still waiting for their acks
218 // back from render.
219 int uncancelable_touch_moves_pending_ack_count_;
205 double last_sent_touch_timestamp_sec_; 220 double last_sent_touch_timestamp_sec_;
206 221
207 // Event is saved to compare pointer positions for new touchmove events. 222 // Event is saved to compare pointer positions for new touchmove events.
208 scoped_ptr<blink::WebTouchEvent> last_sent_touchevent_; 223 scoped_ptr<blink::WebTouchEvent> last_sent_touchevent_;
209 224
210 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); 225 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue);
211 }; 226 };
212 227
213 } // namespace content 228 } // namespace content
214 229
215 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ 230 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698