Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1310)

Side by Side Diff: content/renderer/input/input_handler_manager.cc

Issue 2060713002: Respect the order of input messages from browser to renderer (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@2743
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // The same handler may be registered for a route multiple times. 100 // The same handler may be registered for a route multiple times.
101 if (input_handlers_.count(routing_id) != 0) 101 if (input_handlers_.count(routing_id) != 0)
102 return; 102 return;
103 103
104 TRACE_EVENT1("input", 104 TRACE_EVENT1("input",
105 "InputHandlerManager::AddInputHandlerOnCompositorThread", 105 "InputHandlerManager::AddInputHandlerOnCompositorThread",
106 "result", "AddingRoute"); 106 "result", "AddingRoute");
107 std::unique_ptr<InputHandlerWrapper> wrapper(new InputHandlerWrapper( 107 std::unique_ptr<InputHandlerWrapper> wrapper(new InputHandlerWrapper(
108 this, routing_id, main_task_runner, input_handler, render_view_impl, 108 this, routing_id, main_task_runner, input_handler, render_view_impl,
109 enable_smooth_scrolling, enable_wheel_gestures)); 109 enable_smooth_scrolling, enable_wheel_gestures));
110 client_->DidAddInputHandler(routing_id); 110 client_->RegisterRoutingID(routing_id);
111 if (synchronous_handler_proxy_client_) { 111 if (synchronous_handler_proxy_client_) {
112 synchronous_handler_proxy_client_->DidAddSynchronousHandlerProxy( 112 synchronous_handler_proxy_client_->DidAddSynchronousHandlerProxy(
113 routing_id, wrapper->input_handler_proxy()); 113 routing_id, wrapper->input_handler_proxy());
114 } 114 }
115 input_handlers_.add(routing_id, std::move(wrapper)); 115 input_handlers_.add(routing_id, std::move(wrapper));
116 } 116 }
117 117
118 void InputHandlerManager::RemoveInputHandler(int routing_id) { 118 void InputHandlerManager::RemoveInputHandler(int routing_id) {
119 DCHECK(task_runner_->BelongsToCurrentThread()); 119 DCHECK(task_runner_->BelongsToCurrentThread());
120 DCHECK(input_handlers_.contains(routing_id)); 120 DCHECK(input_handlers_.contains(routing_id));
121 121
122 TRACE_EVENT0("input", "InputHandlerManager::RemoveInputHandler"); 122 TRACE_EVENT0("input", "InputHandlerManager::RemoveInputHandler");
123 123
124 client_->DidRemoveInputHandler(routing_id); 124 client_->UnregisterRoutingID(routing_id);
125 if (synchronous_handler_proxy_client_) { 125 if (synchronous_handler_proxy_client_) {
126 synchronous_handler_proxy_client_->DidRemoveSynchronousHandlerProxy( 126 synchronous_handler_proxy_client_->DidRemoveSynchronousHandlerProxy(
127 routing_id); 127 routing_id);
128 } 128 }
129 input_handlers_.erase(routing_id); 129 input_handlers_.erase(routing_id);
130 } 130 }
131 131
132 void InputHandlerManager::RegisterRoutingID(int routing_id) {
133 if (task_runner_->BelongsToCurrentThread()) {
134 RegisterRoutingIDOnCompositorThread(routing_id);
135 } else {
136 task_runner_->PostTask(
137 FROM_HERE,
138 base::Bind(&InputHandlerManager::RegisterRoutingIDOnCompositorThread,
139 base::Unretained(this), routing_id));
140 }
141 }
142
143 void InputHandlerManager::RegisterRoutingIDOnCompositorThread(int routing_id) {
144 DCHECK(task_runner_->BelongsToCurrentThread());
145 client_->RegisterRoutingID(routing_id);
146 }
147
148 void InputHandlerManager::UnregisterRoutingID(int routing_id) {
149 if (task_runner_->BelongsToCurrentThread()) {
150 UnregisterRoutingIDOnCompositorThread(routing_id);
151 } else {
152 task_runner_->PostTask(
153 FROM_HERE,
154 base::Bind(&InputHandlerManager::UnregisterRoutingIDOnCompositorThread,
155 base::Unretained(this), routing_id));
156 }
157 }
158
159 void InputHandlerManager::UnregisterRoutingIDOnCompositorThread(
160 int routing_id) {
161 DCHECK(task_runner_->BelongsToCurrentThread());
162 client_->UnregisterRoutingID(routing_id);
163 }
164
132 void InputHandlerManager::ObserveWheelEventAndResultOnMainThread( 165 void InputHandlerManager::ObserveWheelEventAndResultOnMainThread(
133 int routing_id, 166 int routing_id,
134 const blink::WebMouseWheelEvent& wheel_event, 167 const blink::WebMouseWheelEvent& wheel_event,
135 const cc::InputHandlerScrollResult& scroll_result) { 168 const cc::InputHandlerScrollResult& scroll_result) {
136 task_runner_->PostTask( 169 task_runner_->PostTask(
137 FROM_HERE, 170 FROM_HERE,
138 base::Bind( 171 base::Bind(
139 &InputHandlerManager::ObserveWheelEventAndResultOnCompositorThread, 172 &InputHandlerManager::ObserveWheelEventAndResultOnCompositorThread,
140 base::Unretained(this), routing_id, wheel_event, scroll_result)); 173 base::Unretained(this), routing_id, wheel_event, scroll_result));
141 } 174 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 284
252 void InputHandlerManager::DidStopFlinging(int routing_id) { 285 void InputHandlerManager::DidStopFlinging(int routing_id) {
253 client_->DidStopFlinging(routing_id); 286 client_->DidStopFlinging(routing_id);
254 } 287 }
255 288
256 void InputHandlerManager::DidAnimateForInput() { 289 void InputHandlerManager::DidAnimateForInput() {
257 renderer_scheduler_->DidAnimateForInputOnCompositorThread(); 290 renderer_scheduler_->DidAnimateForInputOnCompositorThread();
258 } 291 }
259 292
260 } // namespace content 293 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/input_handler_manager.h ('k') | content/renderer/input/input_handler_manager_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698