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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 target_task_runner_(target_task_runner), | 52 target_task_runner_(target_task_runner), |
53 current_overscroll_params_(NULL) { | 53 current_overscroll_params_(NULL) { |
54 DCHECK(target_task_runner_.get()); | 54 DCHECK(target_task_runner_.get()); |
55 } | 55 } |
56 | 56 |
57 void InputEventFilter::SetBoundHandler(const Handler& handler) { | 57 void InputEventFilter::SetBoundHandler(const Handler& handler) { |
58 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 58 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
59 handler_ = handler; | 59 handler_ = handler; |
60 } | 60 } |
61 | 61 |
| 62 void InputEventFilter::SetIsFlingInMainThreadEventQueue(int routing_id, |
| 63 bool is_flinging) { |
| 64 RouteQueueMap::iterator iter = route_queues_.find(routing_id); |
| 65 if (iter == route_queues_.end() || !iter->second) |
| 66 return; |
| 67 |
| 68 iter->second->set_is_flinging(is_flinging); |
| 69 } |
| 70 |
62 void InputEventFilter::DidAddInputHandler(int routing_id) { | 71 void InputEventFilter::DidAddInputHandler(int routing_id) { |
63 base::AutoLock locked(routes_lock_); | 72 base::AutoLock locked(routes_lock_); |
64 routes_.insert(routing_id); | 73 routes_.insert(routing_id); |
65 route_queues_[routing_id].reset(new MainThreadEventQueue(routing_id, this)); | 74 route_queues_[routing_id].reset(new MainThreadEventQueue(routing_id, this)); |
66 } | 75 } |
67 | 76 |
68 void InputEventFilter::DidRemoveInputHandler(int routing_id) { | 77 void InputEventFilter::DidRemoveInputHandler(int routing_id) { |
69 base::AutoLock locked(routes_lock_); | 78 base::AutoLock locked(routes_lock_); |
70 routes_.erase(routing_id); | 79 routes_.erase(routing_id); |
71 route_queues_.erase(routing_id); | 80 route_queues_.erase(routing_id); |
72 } | 81 } |
73 | 82 |
74 void InputEventFilter::DidOverscroll(int routing_id, | 83 void InputEventFilter::DidOverscroll(int routing_id, |
75 const DidOverscrollParams& params) { | 84 const DidOverscrollParams& params) { |
76 if (current_overscroll_params_) { | 85 if (current_overscroll_params_) { |
77 current_overscroll_params_->reset(new DidOverscrollParams(params)); | 86 current_overscroll_params_->reset(new DidOverscrollParams(params)); |
78 return; | 87 return; |
79 } | 88 } |
80 | 89 |
81 SendMessage(std::unique_ptr<IPC::Message>( | 90 SendMessage(std::unique_ptr<IPC::Message>( |
82 new InputHostMsg_DidOverscroll(routing_id, params))); | 91 new InputHostMsg_DidOverscroll(routing_id, params))); |
83 } | 92 } |
84 | 93 |
| 94 void InputEventFilter::DidStartFlinging(int routing_id) { |
| 95 SetIsFlingInMainThreadEventQueue(routing_id, true); |
| 96 } |
| 97 |
85 void InputEventFilter::DidStopFlinging(int routing_id) { | 98 void InputEventFilter::DidStopFlinging(int routing_id) { |
| 99 SetIsFlingInMainThreadEventQueue(routing_id, false); |
86 SendMessage(base::WrapUnique(new InputHostMsg_DidStopFlinging(routing_id))); | 100 SendMessage(base::WrapUnique(new InputHostMsg_DidStopFlinging(routing_id))); |
87 } | 101 } |
88 | 102 |
89 void InputEventFilter::NotifyInputEventHandled( | 103 void InputEventFilter::NotifyInputEventHandled( |
90 int routing_id, | 104 int routing_id, |
91 blink::WebInputEvent::Type type) { | 105 blink::WebInputEvent::Type type) { |
92 DCHECK(target_task_runner_->BelongsToCurrentThread()); | 106 DCHECK(target_task_runner_->BelongsToCurrentThread()); |
93 RouteQueueMap::iterator iter = route_queues_.find(routing_id); | 107 RouteQueueMap::iterator iter = route_queues_.find(routing_id); |
94 if (iter == route_queues_.end() || !iter->second) | 108 if (iter == route_queues_.end() || !iter->second) |
95 return; | 109 return; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 InputEventDispatchType dispatch_type) { | 236 InputEventDispatchType dispatch_type) { |
223 TRACE_EVENT_INSTANT0( | 237 TRACE_EVENT_INSTANT0( |
224 "input", "InputEventFilter::ForwardToHandler::SendEventToMainThread", | 238 "input", "InputEventFilter::ForwardToHandler::SendEventToMainThread", |
225 TRACE_EVENT_SCOPE_THREAD); | 239 TRACE_EVENT_SCOPE_THREAD); |
226 IPC::Message new_msg = | 240 IPC::Message new_msg = |
227 InputMsg_HandleInputEvent(routing_id, event, latency_info, dispatch_type); | 241 InputMsg_HandleInputEvent(routing_id, event, latency_info, dispatch_type); |
228 main_task_runner_->PostTask(FROM_HERE, base::Bind(main_listener_, new_msg)); | 242 main_task_runner_->PostTask(FROM_HERE, base::Bind(main_listener_, new_msg)); |
229 } | 243 } |
230 | 244 |
231 } // namespace content | 245 } // namespace content |
OLD | NEW |