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

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: Fix nits 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return event.unique_touch_event_id < other.event.unique_touch_event_id; 52 return event.unique_touch_event_id < other.event.unique_touch_event_id;
53 } 53 }
54 54
55 PassthroughTouchEventQueue::PassthroughTouchEventQueue( 55 PassthroughTouchEventQueue::PassthroughTouchEventQueue(
56 TouchEventQueueClient* client, 56 TouchEventQueueClient* client,
57 const Config& config) 57 const Config& config)
58 : client_(client), 58 : client_(client),
59 has_handlers_(true), 59 has_handlers_(true),
60 maybe_has_handler_for_current_sequence_(false), 60 maybe_has_handler_for_current_sequence_(false),
61 drop_remaining_touches_in_sequence_(false), 61 drop_remaining_touches_in_sequence_(false),
62 send_touch_events_async_(false) { 62 send_touch_events_async_(false),
63 processing_acks_(false) {
63 if (config.touch_ack_timeout_supported) { 64 if (config.touch_ack_timeout_supported) {
64 timeout_handler_.reset( 65 timeout_handler_.reset(
65 new TouchTimeoutHandler(this, config.desktop_touch_ack_timeout_delay, 66 new TouchTimeoutHandler(this, config.desktop_touch_ack_timeout_delay,
66 config.mobile_touch_ack_timeout_delay)); 67 config.mobile_touch_ack_timeout_delay));
67 } 68 }
68 } 69 }
69 70
70 PassthroughTouchEventQueue::~PassthroughTouchEventQueue() {} 71 PassthroughTouchEventQueue::~PassthroughTouchEventQueue() {}
71 72
72 void PassthroughTouchEventQueue::SendTouchCancelEventForTouchEvent( 73 void PassthroughTouchEventQueue::SendTouchCancelEventForTouchEvent(
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 auto iter = outstanding_touches_.begin(); 199 auto iter = outstanding_touches_.begin();
199 TouchEventWithLatencyInfoAndAckState event = *iter; 200 TouchEventWithLatencyInfoAndAckState event = *iter;
200 outstanding_touches_.erase(iter); 201 outstanding_touches_.erase(iter);
201 if (event.ack_state() == INPUT_EVENT_ACK_STATE_UNKNOWN) 202 if (event.ack_state() == INPUT_EVENT_ACK_STATE_UNKNOWN)
202 event.set_ack_state(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 203 event.set_ack_state(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
203 AckTouchEventToClient(event, event.ack_state()); 204 AckTouchEventToClient(event, event.ack_state());
204 } 205 }
205 } 206 }
206 207
207 void PassthroughTouchEventQueue::AckCompletedEvents() { 208 void PassthroughTouchEventQueue::AckCompletedEvents() {
209 // Don't allow re-entrancy into this method otherwise
210 // the ordering of acks won't be preserved.
211 if (processing_acks_)
212 return;
213 base::AutoReset<bool> process_acks(&processing_acks_, true);
208 while (!outstanding_touches_.empty()) { 214 while (!outstanding_touches_.empty()) {
209 auto iter = outstanding_touches_.begin(); 215 auto iter = outstanding_touches_.begin();
210 if (iter->ack_state() == INPUT_EVENT_ACK_STATE_UNKNOWN) 216 if (iter->ack_state() == INPUT_EVENT_ACK_STATE_UNKNOWN)
211 break; 217 break;
212 TouchEventWithLatencyInfoAndAckState event = *iter; 218 TouchEventWithLatencyInfoAndAckState event = *iter;
213 outstanding_touches_.erase(iter); 219 outstanding_touches_.erase(iter);
214 AckTouchEventToClient(event, event.ack_state()); 220 AckTouchEventToClient(event, event.ack_state());
215 } 221 }
216 } 222 }
217 223
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 bool PassthroughTouchEventQueue::IsTimeoutRunningForTesting() const { 380 bool PassthroughTouchEventQueue::IsTimeoutRunningForTesting() const {
375 return timeout_handler_ && timeout_handler_->IsTimeoutTimerRunning(); 381 return timeout_handler_ && timeout_handler_->IsTimeoutTimerRunning();
376 } 382 }
377 383
378 const TouchEventWithLatencyInfo& 384 const TouchEventWithLatencyInfo&
379 PassthroughTouchEventQueue::GetLatestEventForTesting() const { 385 PassthroughTouchEventQueue::GetLatestEventForTesting() const {
380 return *outstanding_touches_.rbegin(); 386 return *outstanding_touches_.rbegin();
381 } 387 }
382 388
383 } // namespace content 389 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698