Chromium Code Reviews| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 RouteQueueMap::iterator iter = route_queues_.find(routing_id); | 65 RouteQueueMap::iterator iter = route_queues_.find(routing_id); |
| 66 if (iter == route_queues_.end() || !iter->second) | 66 if (iter == route_queues_.end() || !iter->second) |
| 67 return; | 67 return; |
| 68 | 68 |
| 69 iter->second->set_is_flinging(is_flinging); | 69 iter->second->set_is_flinging(is_flinging); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void InputEventFilter::RegisterRoutingID(int routing_id) { | 72 void InputEventFilter::RegisterRoutingID(int routing_id) { |
| 73 base::AutoLock locked(routes_lock_); | 73 base::AutoLock locked(routes_lock_); |
| 74 routes_.insert(routing_id); | 74 routes_.insert(routing_id); |
| 75 route_queues_[routing_id].reset(new MainThreadEventQueue(routing_id, this)); | 75 route_queues_[routing_id] = |
| 76 new MainThreadEventQueue(routing_id, this, main_task_runner_); | |
| 76 } | 77 } |
| 77 | 78 |
| 78 void InputEventFilter::UnregisterRoutingID(int routing_id) { | 79 void InputEventFilter::UnregisterRoutingID(int routing_id) { |
| 79 base::AutoLock locked(routes_lock_); | 80 base::AutoLock locked(routes_lock_); |
| 80 routes_.erase(routing_id); | 81 routes_.erase(routing_id); |
| 81 route_queues_.erase(routing_id); | 82 route_queues_.erase(routing_id); |
| 82 } | 83 } |
| 83 | 84 |
| 84 void InputEventFilter::DidOverscroll(int routing_id, | 85 void InputEventFilter::DidOverscroll(int routing_id, |
| 85 const DidOverscrollParams& params) { | 86 const DidOverscrollParams& params) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 97 } | 98 } |
| 98 | 99 |
| 99 void InputEventFilter::DidStopFlinging(int routing_id) { | 100 void InputEventFilter::DidStopFlinging(int routing_id) { |
| 100 SetIsFlingingInMainThreadEventQueue(routing_id, false); | 101 SetIsFlingingInMainThreadEventQueue(routing_id, false); |
| 101 SendMessage(base::WrapUnique(new InputHostMsg_DidStopFlinging(routing_id))); | 102 SendMessage(base::WrapUnique(new InputHostMsg_DidStopFlinging(routing_id))); |
| 102 } | 103 } |
| 103 | 104 |
| 104 void InputEventFilter::NotifyInputEventHandled(int routing_id, | 105 void InputEventFilter::NotifyInputEventHandled(int routing_id, |
| 105 blink::WebInputEvent::Type type, | 106 blink::WebInputEvent::Type type, |
| 106 InputEventAckState ack_result) { | 107 InputEventAckState ack_result) { |
| 107 DCHECK(target_task_runner_->BelongsToCurrentThread()); | 108 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 108 RouteQueueMap::iterator iter = route_queues_.find(routing_id); | 109 scoped_refptr<MainThreadEventQueue> queue; |
| 109 if (iter == route_queues_.end() || !iter->second) | 110 { |
| 110 return; | 111 base::AutoLock locked(routes_lock_); |
| 112 RouteQueueMap::iterator iter = route_queues_.find(routing_id); | |
| 113 if (iter == route_queues_.end() || !iter->second) | |
| 114 return; | |
| 115 queue = iter->second; | |
| 116 } | |
| 111 | 117 |
| 112 iter->second->EventHandled(type, ack_result); | 118 queue->EventHandled(type, ack_result); |
|
tdresser
2016/07/20 20:52:27
Does the queue really need to be refptr?
dtapuska
2016/07/27 05:29:00
yes for thread safety.
| |
| 113 } | 119 } |
| 114 | 120 |
| 115 void InputEventFilter::OnFilterAdded(IPC::Sender* sender) { | 121 void InputEventFilter::OnFilterAdded(IPC::Sender* sender) { |
| 116 io_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 122 io_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| 117 sender_ = sender; | 123 sender_ = sender; |
| 118 } | 124 } |
| 119 | 125 |
| 120 void InputEventFilter::OnFilterRemoved() { | 126 void InputEventFilter::OnFilterRemoved() { |
| 121 sender_ = NULL; | 127 sender_ = NULL; |
| 122 } | 128 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 void InputEventFilter::SendMessageOnIOThread( | 229 void InputEventFilter::SendMessageOnIOThread( |
| 224 std::unique_ptr<IPC::Message> message) { | 230 std::unique_ptr<IPC::Message> message) { |
| 225 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 231 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
| 226 | 232 |
| 227 if (!sender_) | 233 if (!sender_) |
| 228 return; // Filter was removed. | 234 return; // Filter was removed. |
| 229 | 235 |
| 230 sender_->Send(message.release()); | 236 sender_->Send(message.release()); |
| 231 } | 237 } |
| 232 | 238 |
| 233 void InputEventFilter::SendEventToMainThread( | 239 void InputEventFilter::HandleEventOnMainThread( |
| 234 int routing_id, | 240 int routing_id, |
| 235 const blink::WebInputEvent* event, | 241 const blink::WebInputEvent* event, |
| 236 const ui::LatencyInfo& latency_info, | 242 const ui::LatencyInfo& latency_info, |
| 237 InputEventDispatchType dispatch_type) { | 243 InputEventDispatchType dispatch_type) { |
| 238 TRACE_EVENT_INSTANT0( | 244 TRACE_EVENT_INSTANT0("input", "InputEventFilter::HandlEventOnMainThread", |
| 239 "input", "InputEventFilter::ForwardToHandler::SendEventToMainThread", | 245 TRACE_EVENT_SCOPE_THREAD); |
|
tdresser
2016/07/20 20:52:27
This rename could potentially break some telemetry
dtapuska
2016/07/27 05:29:00
I grepped catapult and didn't see any use of the s
| |
| 240 TRACE_EVENT_SCOPE_THREAD); | |
| 241 IPC::Message new_msg = | 246 IPC::Message new_msg = |
| 242 InputMsg_HandleInputEvent(routing_id, event, latency_info, dispatch_type); | 247 InputMsg_HandleInputEvent(routing_id, event, latency_info, dispatch_type); |
| 243 main_task_runner_->PostTask(FROM_HERE, base::Bind(main_listener_, new_msg)); | 248 main_listener_.Run(new_msg); |
| 244 } | 249 } |
| 245 | 250 |
| 246 void InputEventFilter::SendInputEventAck(int routing_id, | 251 void InputEventFilter::SendInputEventAck(int routing_id, |
| 247 blink::WebInputEvent::Type type, | 252 blink::WebInputEvent::Type type, |
| 248 InputEventAckState ack_result, | 253 InputEventAckState ack_result, |
| 249 uint32_t touch_event_id) { | 254 uint32_t touch_event_id) { |
| 250 InputEventAck ack(type, ack_result, touch_event_id); | 255 InputEventAck ack(type, ack_result, touch_event_id); |
| 251 SendMessage(std::unique_ptr<IPC::Message>( | 256 SendMessage(std::unique_ptr<IPC::Message>( |
| 252 new InputHostMsg_HandleInputEvent_ACK(routing_id, ack))); | 257 new InputHostMsg_HandleInputEvent_ACK(routing_id, ack))); |
| 253 } | 258 } |
| 254 | 259 |
| 255 } // namespace content | 260 } // namespace content |
| OLD | NEW |