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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 | 61 |
62 InputHandlerManager::~InputHandlerManager() { | 62 InputHandlerManager::~InputHandlerManager() { |
63 client_->SetBoundHandler(InputHandlerManagerClient::Handler()); | 63 client_->SetBoundHandler(InputHandlerManagerClient::Handler()); |
64 } | 64 } |
65 | 65 |
66 void InputHandlerManager::AddInputHandler( | 66 void InputHandlerManager::AddInputHandler( |
67 int routing_id, | 67 int routing_id, |
68 const base::WeakPtr<cc::InputHandler>& input_handler, | 68 const base::WeakPtr<cc::InputHandler>& input_handler, |
69 const base::WeakPtr<RenderViewImpl>& render_view_impl, | 69 const base::WeakPtr<RenderViewImpl>& render_view_impl, |
70 bool enable_smooth_scrolling, | 70 bool enable_smooth_scrolling) { |
71 bool enable_wheel_gestures) { | |
72 if (task_runner_->BelongsToCurrentThread()) { | 71 if (task_runner_->BelongsToCurrentThread()) { |
73 AddInputHandlerOnCompositorThread( | 72 AddInputHandlerOnCompositorThread( |
74 routing_id, base::ThreadTaskRunnerHandle::Get(), input_handler, | 73 routing_id, base::ThreadTaskRunnerHandle::Get(), input_handler, |
75 render_view_impl, enable_smooth_scrolling, enable_wheel_gestures); | 74 render_view_impl, enable_smooth_scrolling); |
76 } else { | 75 } else { |
77 task_runner_->PostTask( | 76 task_runner_->PostTask( |
78 FROM_HERE, | 77 FROM_HERE, |
79 base::Bind(&InputHandlerManager::AddInputHandlerOnCompositorThread, | 78 base::Bind(&InputHandlerManager::AddInputHandlerOnCompositorThread, |
80 base::Unretained(this), routing_id, | 79 base::Unretained(this), routing_id, |
81 base::ThreadTaskRunnerHandle::Get(), input_handler, | 80 base::ThreadTaskRunnerHandle::Get(), input_handler, |
82 render_view_impl, enable_smooth_scrolling, | 81 render_view_impl, enable_smooth_scrolling)); |
83 enable_wheel_gestures)); | |
84 } | 82 } |
85 } | 83 } |
86 | 84 |
87 void InputHandlerManager::AddInputHandlerOnCompositorThread( | 85 void InputHandlerManager::AddInputHandlerOnCompositorThread( |
88 int routing_id, | 86 int routing_id, |
89 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, | 87 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, |
90 const base::WeakPtr<cc::InputHandler>& input_handler, | 88 const base::WeakPtr<cc::InputHandler>& input_handler, |
91 const base::WeakPtr<RenderViewImpl>& render_view_impl, | 89 const base::WeakPtr<RenderViewImpl>& render_view_impl, |
92 bool enable_smooth_scrolling, | 90 bool enable_smooth_scrolling) { |
93 bool enable_wheel_gestures) { | |
94 DCHECK(task_runner_->BelongsToCurrentThread()); | 91 DCHECK(task_runner_->BelongsToCurrentThread()); |
95 | 92 |
96 // The handler could be gone by this point if the compositor has shut down. | 93 // The handler could be gone by this point if the compositor has shut down. |
97 if (!input_handler) | 94 if (!input_handler) |
98 return; | 95 return; |
99 | 96 |
100 // The same handler may be registered for a route multiple times. | 97 // The same handler may be registered for a route multiple times. |
101 if (input_handlers_.count(routing_id) != 0) | 98 if (input_handlers_.count(routing_id) != 0) |
102 return; | 99 return; |
103 | 100 |
104 TRACE_EVENT1("input", | 101 TRACE_EVENT1("input", |
105 "InputHandlerManager::AddInputHandlerOnCompositorThread", | 102 "InputHandlerManager::AddInputHandlerOnCompositorThread", |
106 "result", "AddingRoute"); | 103 "result", "AddingRoute"); |
107 std::unique_ptr<InputHandlerWrapper> wrapper(new InputHandlerWrapper( | 104 std::unique_ptr<InputHandlerWrapper> wrapper( |
108 this, routing_id, main_task_runner, input_handler, render_view_impl, | 105 new InputHandlerWrapper(this, routing_id, main_task_runner, input_handler, |
109 enable_smooth_scrolling, enable_wheel_gestures)); | 106 render_view_impl, enable_smooth_scrolling)); |
110 client_->DidAddInputHandler(routing_id); | 107 client_->DidAddInputHandler(routing_id); |
111 if (synchronous_handler_proxy_client_) { | 108 if (synchronous_handler_proxy_client_) { |
112 synchronous_handler_proxy_client_->DidAddSynchronousHandlerProxy( | 109 synchronous_handler_proxy_client_->DidAddSynchronousHandlerProxy( |
113 routing_id, wrapper->input_handler_proxy()); | 110 routing_id, wrapper->input_handler_proxy()); |
114 } | 111 } |
115 input_handlers_.add(routing_id, std::move(wrapper)); | 112 input_handlers_.add(routing_id, std::move(wrapper)); |
116 } | 113 } |
117 | 114 |
118 void InputHandlerManager::RemoveInputHandler(int routing_id) { | 115 void InputHandlerManager::RemoveInputHandler(int routing_id) { |
119 DCHECK(task_runner_->BelongsToCurrentThread()); | 116 DCHECK(task_runner_->BelongsToCurrentThread()); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 248 |
252 void InputHandlerManager::DidStopFlinging(int routing_id) { | 249 void InputHandlerManager::DidStopFlinging(int routing_id) { |
253 client_->DidStopFlinging(routing_id); | 250 client_->DidStopFlinging(routing_id); |
254 } | 251 } |
255 | 252 |
256 void InputHandlerManager::DidAnimateForInput() { | 253 void InputHandlerManager::DidAnimateForInput() { |
257 renderer_scheduler_->DidAnimateForInputOnCompositorThread(); | 254 renderer_scheduler_->DidAnimateForInputOnCompositorThread(); |
258 } | 255 } |
259 | 256 |
260 } // namespace content | 257 } // namespace content |
OLD | NEW |