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

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

Issue 2094323002: Ensure acks are sent for all blocking events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits Created 4 years, 5 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 #include "content/renderer/input/main_thread_event_queue.h" 5 #include "content/renderer/input/main_thread_event_queue.h"
6 6
7 namespace content { 7 namespace content {
8 8
9 MainThreadEventQueue::MainThreadEventQueue(int routing_id, 9 MainThreadEventQueue::MainThreadEventQueue(int routing_id,
10 MainThreadEventQueueClient* client) 10 MainThreadEventQueueClient* client)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 } else { 92 } else {
93 client_->SendEventToMainThread(routing_id_, event, latency, 93 client_->SendEventToMainThread(routing_id_, event, latency,
94 original_dispatch_type); 94 original_dispatch_type);
95 } 95 }
96 96
97 // send an ack when we are non-blocking. 97 // send an ack when we are non-blocking.
98 return non_blocking; 98 return non_blocking;
99 } 99 }
100 100
101 void MainThreadEventQueue::EventHandled(blink::WebInputEvent::Type type) { 101 void MainThreadEventQueue::EventHandled(blink::WebInputEvent::Type type,
102 InputEventAckState ack_result) {
102 if (type == blink::WebInputEvent::MouseWheel) { 103 if (type == blink::WebInputEvent::MouseWheel) {
104 // There should not be two blocking wheel events in flight.
105 DCHECK(!in_flight_wheel_event_ ||
106 in_flight_wheel_event_->eventsToAck.size() == 0);
107
103 if (!wheel_events_.empty()) { 108 if (!wheel_events_.empty()) {
104 std::unique_ptr<PendingMouseWheelEvent> event = wheel_events_.Pop(); 109 in_flight_wheel_event_ = wheel_events_.Pop();
105 client_->SendEventToMainThread(routing_id_, &event->event, event->latency, 110 client_->SendEventToMainThread(
106 event->type); 111 routing_id_, &in_flight_wheel_event_->event,
112 in_flight_wheel_event_->latency, in_flight_wheel_event_->type);
107 } else { 113 } else {
114 in_flight_wheel_event_.reset();
108 wheel_events_.set_state(WebInputEventQueueState::ITEM_NOT_PENDING); 115 wheel_events_.set_state(WebInputEventQueueState::ITEM_NOT_PENDING);
109 } 116 }
110 } else if (blink::WebInputEvent::isTouchEventType(type)) { 117 } else if (blink::WebInputEvent::isTouchEventType(type)) {
118 if (in_flight_touch_event_) {
119 // Send acks for blocking touch events.
120 for (const auto id : in_flight_touch_event_->eventsToAck)
121 client_->SendInputEventAck(routing_id_, type, ack_result, id);
122 }
123
111 if (!touch_events_.empty()) { 124 if (!touch_events_.empty()) {
112 std::unique_ptr<PendingTouchEvent> event = touch_events_.Pop(); 125 in_flight_touch_event_ = touch_events_.Pop();
113 client_->SendEventToMainThread(routing_id_, &event->event, event->latency, 126 client_->SendEventToMainThread(
114 event->type); 127 routing_id_, &in_flight_touch_event_->event,
128 in_flight_touch_event_->latency, in_flight_touch_event_->type);
115 } else { 129 } else {
130 in_flight_touch_event_.reset();
116 touch_events_.set_state(WebInputEventQueueState::ITEM_NOT_PENDING); 131 touch_events_.set_state(WebInputEventQueueState::ITEM_NOT_PENDING);
117 } 132 }
118 } else { 133 } else {
119 NOTREACHED() << "Invalid passive event type"; 134 NOTREACHED() << "Invalid passive event type";
120 } 135 }
121 } 136 }
122 137
123 } // namespace content 138 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698