OLD | NEW |
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 #include "content/renderer/input/input_event_filter.h" | 5 #include "content/renderer/input/input_event_filter.h" |
6 | 6 |
7 #include <tuple> | 7 #include <tuple> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 void InputEventFilter::DidOverscroll(int routing_id, | 88 void InputEventFilter::DidOverscroll(int routing_id, |
89 const DidOverscrollParams& params) { | 89 const DidOverscrollParams& params) { |
90 SendMessage(std::unique_ptr<IPC::Message>( | 90 SendMessage(std::unique_ptr<IPC::Message>( |
91 new InputHostMsg_DidOverscroll(routing_id, params))); | 91 new InputHostMsg_DidOverscroll(routing_id, params))); |
92 } | 92 } |
93 | 93 |
94 void InputEventFilter::DidStopFlinging(int routing_id) { | 94 void InputEventFilter::DidStopFlinging(int routing_id) { |
95 SendMessage(base::MakeUnique<InputHostMsg_DidStopFlinging>(routing_id)); | 95 SendMessage(base::MakeUnique<InputHostMsg_DidStopFlinging>(routing_id)); |
96 } | 96 } |
97 | 97 |
| 98 void InputEventFilter::QueueClosureForMainThreadEventQueue( |
| 99 int routing_id, |
| 100 const base::Closure& closure) { |
| 101 DCHECK(target_task_runner_->BelongsToCurrentThread()); |
| 102 RouteQueueMap::iterator iter = route_queues_.find(routing_id); |
| 103 if (iter != route_queues_.end()) |
| 104 iter->second->QueueClosure(closure); |
| 105 } |
| 106 |
98 void InputEventFilter::DispatchNonBlockingEventToMainThread( | 107 void InputEventFilter::DispatchNonBlockingEventToMainThread( |
99 int routing_id, | 108 int routing_id, |
100 ui::WebScopedInputEvent event, | 109 ui::WebScopedInputEvent event, |
101 const ui::LatencyInfo& latency_info) { | 110 const ui::LatencyInfo& latency_info) { |
102 DCHECK(target_task_runner_->BelongsToCurrentThread()); | 111 DCHECK(target_task_runner_->BelongsToCurrentThread()); |
103 RouteQueueMap::iterator iter = route_queues_.find(routing_id); | 112 RouteQueueMap::iterator iter = route_queues_.find(routing_id); |
104 if (iter != route_queues_.end()) { | 113 if (iter != route_queues_.end()) { |
105 iter->second->HandleEvent(std::move(event), latency_info, | 114 iter->second->HandleEvent(std::move(event), latency_info, |
106 DISPATCH_TYPE_NON_BLOCKING, | 115 DISPATCH_TYPE_NON_BLOCKING, |
107 INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 116 INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 200 |
192 InputEventFilter::~InputEventFilter() {} | 201 InputEventFilter::~InputEventFilter() {} |
193 | 202 |
194 void InputEventFilter::ForwardToHandler(const IPC::Message& message, | 203 void InputEventFilter::ForwardToHandler(const IPC::Message& message, |
195 base::TimeTicks received_time) { | 204 base::TimeTicks received_time) { |
196 DCHECK(input_handler_manager_); | 205 DCHECK(input_handler_manager_); |
197 DCHECK(target_task_runner_->BelongsToCurrentThread()); | 206 DCHECK(target_task_runner_->BelongsToCurrentThread()); |
198 TRACE_EVENT1("input", "InputEventFilter::ForwardToHandler", | 207 TRACE_EVENT1("input", "InputEventFilter::ForwardToHandler", |
199 "message_type", GetInputMessageTypeName(message)); | 208 "message_type", GetInputMessageTypeName(message)); |
200 | 209 |
| 210 int routing_id = message.routing_id(); |
201 if (message.type() != InputMsg_HandleInputEvent::ID) { | 211 if (message.type() != InputMsg_HandleInputEvent::ID) { |
202 TRACE_EVENT_INSTANT0( | 212 TRACE_EVENT_INSTANT0( |
203 "input", | 213 "input", |
204 "InputEventFilter::ForwardToHandler::ForwardToMainListener", | 214 "InputEventFilter::ForwardToHandler::ForwardToMainListener", |
205 TRACE_EVENT_SCOPE_THREAD); | 215 TRACE_EVENT_SCOPE_THREAD); |
206 CHECK(main_task_runner_->PostTask(FROM_HERE, | 216 input_handler_manager_->QueueClosureForMainThreadEventQueue( |
207 base::Bind(main_listener_, message))) | 217 routing_id, base::Bind(main_listener_, message)); |
208 << "PostTask failed"; | |
209 return; | 218 return; |
210 } | 219 } |
211 | 220 |
212 int routing_id = message.routing_id(); | |
213 InputMsg_HandleInputEvent::Param params; | 221 InputMsg_HandleInputEvent::Param params; |
214 if (!InputMsg_HandleInputEvent::Read(&message, ¶ms)) | 222 if (!InputMsg_HandleInputEvent::Read(&message, ¶ms)) |
215 return; | 223 return; |
216 ui::WebScopedInputEvent event = | 224 ui::WebScopedInputEvent event = |
217 ui::WebInputEventTraits::Clone(*std::get<0>(params)); | 225 ui::WebInputEventTraits::Clone(*std::get<0>(params)); |
218 ui::LatencyInfo latency_info = std::get<2>(params); | 226 ui::LatencyInfo latency_info = std::get<2>(params); |
219 InputEventDispatchType dispatch_type = std::get<3>(params); | 227 InputEventDispatchType dispatch_type = std::get<3>(params); |
220 | 228 |
221 DCHECK(event); | 229 DCHECK(event); |
222 DCHECK(dispatch_type == DISPATCH_TYPE_BLOCKING || | 230 DCHECK(dispatch_type == DISPATCH_TYPE_BLOCKING || |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 return; | 326 return; |
319 } | 327 } |
320 | 328 |
321 CHECK(target_task_runner_->PostTask( | 329 CHECK(target_task_runner_->PostTask( |
322 FROM_HERE, | 330 FROM_HERE, |
323 base::Bind(&InputEventFilter::NeedsMainFrame, this, routing_id))) | 331 base::Bind(&InputEventFilter::NeedsMainFrame, this, routing_id))) |
324 << "PostTask failed"; | 332 << "PostTask failed"; |
325 } | 333 } |
326 | 334 |
327 } // namespace content | 335 } // namespace content |
OLD | NEW |