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

Unified Diff: content/renderer/input/input_event_filter.cc

Issue 1631963002: Plumb firing passive event listeners. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_wheel_passive_listeners_2a
Patch Set: Set dependency correctly Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/input/input_event_filter.cc
diff --git a/content/renderer/input/input_event_filter.cc b/content/renderer/input/input_event_filter.cc
index c85586272fd1a36742db5e8fda60b93802b6c9fe..f28b0886cf182ef3036d685f4223b4c9fbc909ef 100644
--- a/content/renderer/input/input_event_filter.cc
+++ b/content/renderer/input/input_event_filter.cc
@@ -69,6 +69,11 @@ void InputEventFilter::DidAddInputHandler(
void InputEventFilter::DidRemoveInputHandler(int routing_id) {
base::AutoLock locked(routes_lock_);
routes_.erase(routing_id);
+ auto iter = route_queues_.find(routing_id);
+ if (iter != route_queues_.end()) {
+ delete iter->second;
aelias_OOO_until_Jul13 2016/01/26 04:50:41 Can we avoid this via RAII? Used to be scoped_ptr
dtapuska 2016/01/26 16:53:15 Done.
+ route_queues_.erase(iter);
+ }
}
void InputEventFilter::DidOverscroll(int routing_id,
@@ -86,6 +91,17 @@ void InputEventFilter::DidStopFlinging(int routing_id) {
SendMessage(make_scoped_ptr(new InputHostMsg_DidStopFlinging(routing_id)));
}
+void InputEventFilter::PassiveInputEventHandled(
+ int routing_id,
+ blink::WebInputEvent::Type type) {
+ DCHECK(target_task_runner_->BelongsToCurrentThread());
+ RouteQueueMap::iterator iter = route_queues_.find(routing_id);
+ if (iter == route_queues_.end() || !iter->second)
+ return;
+
+ iter->second->EventHandled(type);
+}
+
void InputEventFilter::OnFilterAdded(IPC::Sender* sender) {
io_task_runner_ = base::ThreadTaskRunnerHandle::Get();
sender_ = sender;
@@ -128,6 +144,10 @@ bool InputEventFilter::OnMessageReceived(const IPC::Message& message) {
InputEventFilter::~InputEventFilter() {
DCHECK(!current_overscroll_params_);
+ for (auto iter = route_queues_.begin(); iter != route_queues_.end(); iter++) {
+ delete iter->second;
+ }
+ route_queues_.clear();
}
void InputEventFilter::ForwardToHandler(const IPC::Message& message) {
@@ -151,7 +171,9 @@ void InputEventFilter::ForwardToHandler(const IPC::Message& message) {
return;
const WebInputEvent* event = base::get<0>(params);
ui::LatencyInfo latency_info = base::get<1>(params);
+ bool passive = base::get<2>(params);
DCHECK(event);
+ DCHECK(!passive);
const bool send_ack = WebInputEventTraits::WillReceiveAckFromRenderer(*event);
@@ -164,14 +186,22 @@ void InputEventFilter::ForwardToHandler(const IPC::Message& message) {
InputEventAckState ack_state = handler_.Run(routing_id, event, &latency_info);
- if (ack_state == INPUT_EVENT_ACK_STATE_NOT_CONSUMED) {
+ if (ack_state == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING) {
+ DCHECK(!overscroll_params);
+ RouteQueueMap::iterator iter = route_queues_.find(routing_id);
aelias_OOO_until_Jul13 2016/01/26 04:50:41 Is this multiple-queue scenario a possibility toda
dtapuska 2016/01/26 16:53:15 There can exist multiple routing_id's and the queu
+ if (iter == route_queues_.end()) {
+ route_queues_[routing_id] = new PassiveEventQueue(routing_id, this);
+ iter = route_queues_.find(routing_id);
+ }
+ iter->second->HandleNonBlockingEvent(event, latency_info);
+ } else if (ack_state == INPUT_EVENT_ACK_STATE_NOT_CONSUMED) {
DCHECK(!overscroll_params);
TRACE_EVENT_INSTANT0(
- "input",
- "InputEventFilter::ForwardToHandler::ForwardToMainListener",
+ "input", "InputEventFilter::ForwardToHandler::ForwardToMainListener",
TRACE_EVENT_SCOPE_THREAD);
- IPC::Message new_msg =
- InputMsg_HandleInputEvent(routing_id, event, latency_info);
+ IPC::Message new_msg = InputMsg_HandleInputEvent(
+ routing_id, event, latency_info,
+ ack_state == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING);
main_task_runner_->PostTask(FROM_HERE, base::Bind(main_listener_, new_msg));
return;
aelias_OOO_until_Jul13 2016/01/26 04:50:41 This 'return' (and the absence of the 'return' in
dtapuska 2016/01/26 16:53:15 Done.
}
@@ -203,4 +233,15 @@ void InputEventFilter::SendMessageOnIOThread(scoped_ptr<IPC::Message> message) {
sender_->Send(message.release());
}
+void InputEventFilter::SendPassiveEvent(int routing_id,
+ const blink::WebInputEvent* event,
+ const ui::LatencyInfo& latency) {
+ TRACE_EVENT_INSTANT0(
+ "input", "InputEventFilter::ForwardToHandler::ForwardToMainListener",
+ TRACE_EVENT_SCOPE_THREAD);
+ IPC::Message new_msg =
+ InputMsg_HandleInputEvent(routing_id, event, latency, true);
+ main_task_runner_->PostTask(FROM_HERE, base::Bind(main_listener_, new_msg));
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698