| 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_handler_manager.h" | 5 #include "content/renderer/input/input_handler_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // The same handler may be registered for a route multiple times. | 97 // The same handler may be registered for a route multiple times. |
| 98 if (input_handlers_.count(routing_id) != 0) | 98 if (input_handlers_.count(routing_id) != 0) |
| 99 return; | 99 return; |
| 100 | 100 |
| 101 TRACE_EVENT1("input", | 101 TRACE_EVENT1("input", |
| 102 "InputHandlerManager::AddInputHandlerOnCompositorThread", | 102 "InputHandlerManager::AddInputHandlerOnCompositorThread", |
| 103 "result", "AddingRoute"); | 103 "result", "AddingRoute"); |
| 104 std::unique_ptr<InputHandlerWrapper> wrapper( | 104 std::unique_ptr<InputHandlerWrapper> wrapper( |
| 105 new InputHandlerWrapper(this, routing_id, main_task_runner, input_handler, | 105 new InputHandlerWrapper(this, routing_id, main_task_runner, input_handler, |
| 106 render_view_impl, enable_smooth_scrolling)); | 106 render_view_impl, enable_smooth_scrolling)); |
| 107 client_->DidAddInputHandler(routing_id); | 107 client_->RegisterRoutingID(routing_id); |
| 108 if (synchronous_handler_proxy_client_) { | 108 if (synchronous_handler_proxy_client_) { |
| 109 synchronous_handler_proxy_client_->DidAddSynchronousHandlerProxy( | 109 synchronous_handler_proxy_client_->DidAddSynchronousHandlerProxy( |
| 110 routing_id, wrapper->input_handler_proxy()); | 110 routing_id, wrapper->input_handler_proxy()); |
| 111 } | 111 } |
| 112 input_handlers_.add(routing_id, std::move(wrapper)); | 112 input_handlers_.add(routing_id, std::move(wrapper)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void InputHandlerManager::RemoveInputHandler(int routing_id) { | 115 void InputHandlerManager::RemoveInputHandler(int routing_id) { |
| 116 DCHECK(task_runner_->BelongsToCurrentThread()); | 116 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 117 DCHECK(input_handlers_.contains(routing_id)); | 117 DCHECK(input_handlers_.contains(routing_id)); |
| 118 | 118 |
| 119 TRACE_EVENT0("input", "InputHandlerManager::RemoveInputHandler"); | 119 TRACE_EVENT0("input", "InputHandlerManager::RemoveInputHandler"); |
| 120 | 120 |
| 121 client_->DidRemoveInputHandler(routing_id); | 121 client_->UnregisterRoutingID(routing_id); |
| 122 if (synchronous_handler_proxy_client_) { | 122 if (synchronous_handler_proxy_client_) { |
| 123 synchronous_handler_proxy_client_->DidRemoveSynchronousHandlerProxy( | 123 synchronous_handler_proxy_client_->DidRemoveSynchronousHandlerProxy( |
| 124 routing_id); | 124 routing_id); |
| 125 } | 125 } |
| 126 input_handlers_.erase(routing_id); | 126 input_handlers_.erase(routing_id); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void InputHandlerManager::RegisterRoutingID(int routing_id) { |
| 130 if (task_runner_->BelongsToCurrentThread()) { |
| 131 RegisterRoutingIDOnCompositorThread(routing_id); |
| 132 } else { |
| 133 task_runner_->PostTask( |
| 134 FROM_HERE, |
| 135 base::Bind(&InputHandlerManager::RegisterRoutingIDOnCompositorThread, |
| 136 base::Unretained(this), routing_id)); |
| 137 } |
| 138 } |
| 139 |
| 140 void InputHandlerManager::RegisterRoutingIDOnCompositorThread(int routing_id) { |
| 141 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 142 client_->RegisterRoutingID(routing_id); |
| 143 } |
| 144 |
| 145 void InputHandlerManager::UnregisterRoutingID(int routing_id) { |
| 146 if (task_runner_->BelongsToCurrentThread()) { |
| 147 UnregisterRoutingIDOnCompositorThread(routing_id); |
| 148 } else { |
| 149 task_runner_->PostTask( |
| 150 FROM_HERE, |
| 151 base::Bind(&InputHandlerManager::UnregisterRoutingIDOnCompositorThread, |
| 152 base::Unretained(this), routing_id)); |
| 153 } |
| 154 } |
| 155 |
| 156 void InputHandlerManager::UnregisterRoutingIDOnCompositorThread( |
| 157 int routing_id) { |
| 158 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 159 client_->UnregisterRoutingID(routing_id); |
| 160 } |
| 161 |
| 129 void InputHandlerManager::ObserveWheelEventAndResultOnMainThread( | 162 void InputHandlerManager::ObserveWheelEventAndResultOnMainThread( |
| 130 int routing_id, | 163 int routing_id, |
| 131 const blink::WebMouseWheelEvent& wheel_event, | 164 const blink::WebMouseWheelEvent& wheel_event, |
| 132 const cc::InputHandlerScrollResult& scroll_result) { | 165 const cc::InputHandlerScrollResult& scroll_result) { |
| 133 task_runner_->PostTask( | 166 task_runner_->PostTask( |
| 134 FROM_HERE, | 167 FROM_HERE, |
| 135 base::Bind( | 168 base::Bind( |
| 136 &InputHandlerManager::ObserveWheelEventAndResultOnCompositorThread, | 169 &InputHandlerManager::ObserveWheelEventAndResultOnCompositorThread, |
| 137 base::Unretained(this), routing_id, wheel_event, scroll_result)); | 170 base::Unretained(this), routing_id, wheel_event, scroll_result)); |
| 138 } | 171 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 281 |
| 249 void InputHandlerManager::DidStopFlinging(int routing_id) { | 282 void InputHandlerManager::DidStopFlinging(int routing_id) { |
| 250 client_->DidStopFlinging(routing_id); | 283 client_->DidStopFlinging(routing_id); |
| 251 } | 284 } |
| 252 | 285 |
| 253 void InputHandlerManager::DidAnimateForInput() { | 286 void InputHandlerManager::DidAnimateForInput() { |
| 254 renderer_scheduler_->DidAnimateForInputOnCompositorThread(); | 287 renderer_scheduler_->DidAnimateForInputOnCompositorThread(); |
| 255 } | 288 } |
| 256 | 289 |
| 257 } // namespace content | 290 } // namespace content |
| OLD | NEW |