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

Side by Side Diff: content/browser/renderer_host/input/passthrough_touch_event_queue.cc

Issue 2826673005: Fix recursion in handling touch input events acks. (Closed)
Patch Set: Rebase Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include "content/browser/renderer_host/input/passthrough_touch_event_queue.h" 5 #include "content/browser/renderer_host/input/passthrough_touch_event_queue.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 111
112 PassthroughTouchEventQueue::PassthroughTouchEventQueue( 112 PassthroughTouchEventQueue::PassthroughTouchEventQueue(
113 TouchEventQueueClient* client, 113 TouchEventQueueClient* client,
114 const Config& config) 114 const Config& config)
115 : client_(client), 115 : client_(client),
116 has_handlers_(true), 116 has_handlers_(true),
117 maybe_has_handler_for_current_sequence_(false), 117 maybe_has_handler_for_current_sequence_(false),
118 drop_remaining_touches_in_sequence_(false), 118 drop_remaining_touches_in_sequence_(false),
119 touchmove_slop_suppressor_(new TouchMoveSlopSuppressor), 119 touchmove_slop_suppressor_(new TouchMoveSlopSuppressor),
120 send_touch_events_async_(false) { 120 send_touch_events_async_(false),
121 processing_acks_(false) {
121 if (config.touch_ack_timeout_supported) { 122 if (config.touch_ack_timeout_supported) {
122 timeout_handler_.reset( 123 timeout_handler_.reset(
123 new TouchTimeoutHandler(this, config.desktop_touch_ack_timeout_delay, 124 new TouchTimeoutHandler(this, config.desktop_touch_ack_timeout_delay,
124 config.mobile_touch_ack_timeout_delay)); 125 config.mobile_touch_ack_timeout_delay));
125 } 126 }
126 } 127 }
127 128
128 PassthroughTouchEventQueue::~PassthroughTouchEventQueue() {} 129 PassthroughTouchEventQueue::~PassthroughTouchEventQueue() {}
129 130
130 void PassthroughTouchEventQueue::SendTouchCancelEventForTouchEvent( 131 void PassthroughTouchEventQueue::SendTouchCancelEventForTouchEvent(
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 auto iter = outstanding_touches_.begin(); 259 auto iter = outstanding_touches_.begin();
259 TouchEventWithLatencyInfoAndAckState event = *iter; 260 TouchEventWithLatencyInfoAndAckState event = *iter;
260 outstanding_touches_.erase(iter); 261 outstanding_touches_.erase(iter);
261 if (event.ack_state() == INPUT_EVENT_ACK_STATE_UNKNOWN) 262 if (event.ack_state() == INPUT_EVENT_ACK_STATE_UNKNOWN)
262 event.set_ack_state(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 263 event.set_ack_state(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
263 AckTouchEventToClient(event, event.ack_state()); 264 AckTouchEventToClient(event, event.ack_state());
264 } 265 }
265 } 266 }
266 267
267 void PassthroughTouchEventQueue::AckCompletedEvents() { 268 void PassthroughTouchEventQueue::AckCompletedEvents() {
269 // Don't allow re-entrancy into this method otherwise
270 // the ordering of acks won't be preserved.
271 if (processing_acks_)
272 return;
273 base::AutoReset<bool> process_acks(&processing_acks_, true);
268 while (!outstanding_touches_.empty()) { 274 while (!outstanding_touches_.empty()) {
269 auto iter = outstanding_touches_.begin(); 275 auto iter = outstanding_touches_.begin();
270 if (iter->ack_state() == INPUT_EVENT_ACK_STATE_UNKNOWN) 276 if (iter->ack_state() == INPUT_EVENT_ACK_STATE_UNKNOWN)
271 break; 277 break;
272 TouchEventWithLatencyInfoAndAckState event = *iter; 278 TouchEventWithLatencyInfoAndAckState event = *iter;
273 outstanding_touches_.erase(iter); 279 outstanding_touches_.erase(iter);
274 AckTouchEventToClient(event, event.ack_state()); 280 AckTouchEventToClient(event, event.ack_state());
275 } 281 }
276 } 282 }
277 283
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 bool PassthroughTouchEventQueue::IsTimeoutRunningForTesting() const { 443 bool PassthroughTouchEventQueue::IsTimeoutRunningForTesting() const {
438 return timeout_handler_ && timeout_handler_->IsTimeoutTimerRunning(); 444 return timeout_handler_ && timeout_handler_->IsTimeoutTimerRunning();
439 } 445 }
440 446
441 const TouchEventWithLatencyInfo& 447 const TouchEventWithLatencyInfo&
442 PassthroughTouchEventQueue::GetLatestEventForTesting() const { 448 PassthroughTouchEventQueue::GetLatestEventForTesting() const {
443 return *outstanding_touches_.rbegin(); 449 return *outstanding_touches_.rbegin();
444 } 450 }
445 451
446 } // namespace content 452 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698