| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "cc/input/input_handler.h" | 10 #include "cc/input/input_handler.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 InputHandlerManager::~InputHandlerManager() { | 47 InputHandlerManager::~InputHandlerManager() { |
| 48 client_->SetBoundHandler(InputHandlerManagerClient::Handler()); | 48 client_->SetBoundHandler(InputHandlerManagerClient::Handler()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void InputHandlerManager::AddInputHandler( | 51 void InputHandlerManager::AddInputHandler( |
| 52 int routing_id, | 52 int routing_id, |
| 53 const base::WeakPtr<cc::InputHandler>& input_handler, | 53 const base::WeakPtr<cc::InputHandler>& input_handler, |
| 54 const base::WeakPtr<RenderViewImpl>& render_view_impl, | 54 const base::WeakPtr<RenderViewImpl>& render_view_impl, |
| 55 RendererScheduler* render_scheduler) { | 55 RendererScheduler* renderer_scheduler) { |
| 56 if (message_loop_proxy_->BelongsToCurrentThread()) { | 56 if (message_loop_proxy_->BelongsToCurrentThread()) { |
| 57 AddInputHandlerOnCompositorThread(routing_id, | 57 AddInputHandlerOnCompositorThread(routing_id, |
| 58 base::MessageLoopProxy::current(), | 58 base::MessageLoopProxy::current(), |
| 59 input_handler, | 59 input_handler, |
| 60 render_view_impl, | 60 render_view_impl, |
| 61 render_scheduler); | 61 renderer_scheduler); |
| 62 } else { | 62 } else { |
| 63 message_loop_proxy_->PostTask( | 63 message_loop_proxy_->PostTask( |
| 64 FROM_HERE, | 64 FROM_HERE, |
| 65 base::Bind(&InputHandlerManager::AddInputHandlerOnCompositorThread, | 65 base::Bind(&InputHandlerManager::AddInputHandlerOnCompositorThread, |
| 66 base::Unretained(this), | 66 base::Unretained(this), |
| 67 routing_id, | 67 routing_id, |
| 68 base::MessageLoopProxy::current(), | 68 base::MessageLoopProxy::current(), |
| 69 input_handler, | 69 input_handler, |
| 70 render_view_impl, | 70 render_view_impl, |
| 71 render_scheduler)); | 71 renderer_scheduler)); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 void InputHandlerManager::AddInputHandlerOnCompositorThread( | 75 void InputHandlerManager::AddInputHandlerOnCompositorThread( |
| 76 int routing_id, | 76 int routing_id, |
| 77 const scoped_refptr<base::MessageLoopProxy>& main_loop, | 77 const scoped_refptr<base::MessageLoopProxy>& main_loop, |
| 78 const base::WeakPtr<cc::InputHandler>& input_handler, | 78 const base::WeakPtr<cc::InputHandler>& input_handler, |
| 79 const base::WeakPtr<RenderViewImpl>& render_view_impl, | 79 const base::WeakPtr<RenderViewImpl>& render_view_impl, |
| 80 RendererScheduler* render_scheduler) { | 80 RendererScheduler* renderer_scheduler) { |
| 81 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); | 81 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); |
| 82 | 82 |
| 83 // The handler could be gone by this point if the compositor has shut down. | 83 // The handler could be gone by this point if the compositor has shut down. |
| 84 if (!input_handler) | 84 if (!input_handler) |
| 85 return; | 85 return; |
| 86 | 86 |
| 87 // The same handler may be registered for a route multiple times. | 87 // The same handler may be registered for a route multiple times. |
| 88 if (input_handlers_.count(routing_id) != 0) | 88 if (input_handlers_.count(routing_id) != 0) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 TRACE_EVENT1("input", | 91 TRACE_EVENT1("input", |
| 92 "InputHandlerManager::AddInputHandlerOnCompositorThread", | 92 "InputHandlerManager::AddInputHandlerOnCompositorThread", |
| 93 "result", "AddingRoute"); | 93 "result", "AddingRoute"); |
| 94 client_->DidAddInputHandler(routing_id, input_handler.get()); | 94 client_->DidAddInputHandler(routing_id, input_handler.get()); |
| 95 input_handlers_.add( | 95 input_handlers_.add( |
| 96 routing_id, | 96 routing_id, |
| 97 make_scoped_ptr(new InputHandlerWrapper(this, | 97 make_scoped_ptr(new InputHandlerWrapper(this, |
| 98 routing_id, | 98 routing_id, |
| 99 main_loop, | 99 main_loop, |
| 100 input_handler, | 100 input_handler, |
| 101 render_view_impl, | 101 render_view_impl, |
| 102 render_scheduler))); | 102 renderer_scheduler))); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void InputHandlerManager::RemoveInputHandler(int routing_id) { | 105 void InputHandlerManager::RemoveInputHandler(int routing_id) { |
| 106 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); | 106 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); |
| 107 DCHECK(input_handlers_.contains(routing_id)); | 107 DCHECK(input_handlers_.contains(routing_id)); |
| 108 | 108 |
| 109 TRACE_EVENT0("input", "InputHandlerManager::RemoveInputHandler"); | 109 TRACE_EVENT0("input", "InputHandlerManager::RemoveInputHandler"); |
| 110 | 110 |
| 111 client_->DidRemoveInputHandler(routing_id); | 111 client_->DidRemoveInputHandler(routing_id); |
| 112 input_handlers_.erase(routing_id); | 112 input_handlers_.erase(routing_id); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 134 void InputHandlerManager::DidOverscroll(int routing_id, | 134 void InputHandlerManager::DidOverscroll(int routing_id, |
| 135 const DidOverscrollParams& params) { | 135 const DidOverscrollParams& params) { |
| 136 client_->DidOverscroll(routing_id, params); | 136 client_->DidOverscroll(routing_id, params); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void InputHandlerManager::DidStopFlinging(int routing_id) { | 139 void InputHandlerManager::DidStopFlinging(int routing_id) { |
| 140 client_->DidStopFlinging(routing_id); | 140 client_->DidStopFlinging(routing_id); |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace content | 143 } // namespace content |
| OLD | NEW |