| 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/browser/renderer_host/input/buffered_input_router.h" | 5 #include "content/browser/renderer_host/input/buffered_input_router.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "content/browser/renderer_host/input/browser_input_event.h" | 8 #include "content/browser/renderer_host/input/browser_input_event.h" |
| 9 #include "content/browser/renderer_host/input/input_ack_handler.h" | 9 #include "content/browser/renderer_host/input/input_ack_handler.h" |
| 10 #include "content/browser/renderer_host/input/input_queue.h" | 10 #include "content/browser/renderer_host/input/input_queue.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 BufferedInputRouter::BufferedInputRouter(IPC::Sender* sender, | 26 BufferedInputRouter::BufferedInputRouter(IPC::Sender* sender, |
| 27 InputRouterClient* client, | 27 InputRouterClient* client, |
| 28 InputAckHandler* ack_handler, | 28 InputAckHandler* ack_handler, |
| 29 int routing_id) | 29 int routing_id) |
| 30 : client_(client), | 30 : client_(client), |
| 31 ack_handler_(ack_handler), | 31 ack_handler_(ack_handler), |
| 32 sender_(sender), | 32 sender_(sender), |
| 33 routing_id_(routing_id), | 33 routing_id_(routing_id), |
| 34 queued_gesture_count_(0), | |
| 35 has_touch_handler_(false), | 34 has_touch_handler_(false), |
| 36 queued_touch_count_(0), | 35 queued_touch_count_(0), |
| 37 input_queue_override_(NULL), | 36 input_queue_override_(NULL), |
| 38 next_input_id_(1), | 37 next_input_id_(1), |
| 39 in_flight_packet_id_(0) { | 38 in_flight_packet_id_(0) { |
| 40 input_queue_.reset(new InputQueue(this)); | 39 input_queue_.reset(new InputQueue(this)); |
| 41 } | 40 } |
| 42 | 41 |
| 43 BufferedInputRouter::~BufferedInputRouter() {} | 42 BufferedInputRouter::~BufferedInputRouter() {} |
| 44 | 43 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 if (event_id) { | 81 if (event_id) { |
| 83 DCHECK(queued_key_map_.find(event_id) == queued_key_map_.end()); | 82 DCHECK(queued_key_map_.find(event_id) == queued_key_map_.end()); |
| 84 queued_key_map_[event_id] = key_event; | 83 queued_key_map_[event_id] = key_event; |
| 85 } | 84 } |
| 86 } | 85 } |
| 87 | 86 |
| 88 void BufferedInputRouter::SendGestureEvent( | 87 void BufferedInputRouter::SendGestureEvent( |
| 89 const GestureEventWithLatencyInfo& gesture_event) { | 88 const GestureEventWithLatencyInfo& gesture_event) { |
| 90 if (!client_->OnSendGestureEvent(gesture_event)) | 89 if (!client_->OnSendGestureEvent(gesture_event)) |
| 91 return; | 90 return; |
| 92 if (QueueWebEvent(gesture_event.event, gesture_event.latency, false)) | 91 QueueWebEvent(gesture_event.event, gesture_event.latency, false); |
| 93 ++queued_gesture_count_; | |
| 94 } | 92 } |
| 95 | 93 |
| 96 void BufferedInputRouter::SendTouchEvent( | 94 void BufferedInputRouter::SendTouchEvent( |
| 97 const TouchEventWithLatencyInfo& touch_event) { | 95 const TouchEventWithLatencyInfo& touch_event) { |
| 98 if (!client_->OnSendTouchEvent(touch_event)) | 96 if (!client_->OnSendTouchEvent(touch_event)) |
| 99 return; | 97 return; |
| 100 if (QueueWebEvent(touch_event.event, touch_event.latency, false)) | 98 if (QueueWebEvent(touch_event.event, touch_event.latency, false)) |
| 101 ++queued_touch_count_; | 99 ++queued_touch_count_; |
| 102 } | 100 } |
| 103 | 101 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 198 |
| 201 bool BufferedInputRouter::ShouldForwardTouchEvent() const { | 199 bool BufferedInputRouter::ShouldForwardTouchEvent() const { |
| 202 return has_touch_handler_ && queued_touch_count_ > 0; | 200 return has_touch_handler_ && queued_touch_count_ > 0; |
| 203 } | 201 } |
| 204 | 202 |
| 205 bool BufferedInputRouter::ShouldForwardGestureEvent( | 203 bool BufferedInputRouter::ShouldForwardGestureEvent( |
| 206 const GestureEventWithLatencyInfo& touch_event) const { | 204 const GestureEventWithLatencyInfo& touch_event) const { |
| 207 return true; | 205 return true; |
| 208 } | 206 } |
| 209 | 207 |
| 210 bool BufferedInputRouter::HasQueuedGestureEvents() const { | |
| 211 return queued_gesture_count_ > 0; | |
| 212 } | |
| 213 | |
| 214 void BufferedInputRouter::OnWebInputEventAck( | 208 void BufferedInputRouter::OnWebInputEventAck( |
| 215 int64 event_id, | 209 int64 event_id, |
| 216 const WebKit::WebInputEvent& web_event, | 210 const WebKit::WebInputEvent& web_event, |
| 217 const ui::LatencyInfo& latency_info, | 211 const ui::LatencyInfo& latency_info, |
| 218 InputEventAckState acked_result, | 212 InputEventAckState acked_result, |
| 219 bool ack_from_input_queue) { | 213 bool ack_from_input_queue) { |
| 220 if (WebInputEvent::isKeyboardEventType(web_event.type)) { | 214 if (WebInputEvent::isKeyboardEventType(web_event.type)) { |
| 221 if (ack_from_input_queue) { | 215 if (ack_from_input_queue) { |
| 222 KeyMap::iterator key_it = queued_key_map_.find(event_id); | 216 KeyMap::iterator key_it = queued_key_map_.find(event_id); |
| 223 DCHECK(key_it != queued_key_map_.end()); | 217 DCHECK(key_it != queued_key_map_.end()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 238 } else if (WebInputEvent::isTouchEventType(web_event.type)) { | 232 } else if (WebInputEvent::isTouchEventType(web_event.type)) { |
| 239 if (ack_from_input_queue) { | 233 if (ack_from_input_queue) { |
| 240 DCHECK_GT(queued_touch_count_, 0); | 234 DCHECK_GT(queued_touch_count_, 0); |
| 241 --queued_touch_count_; | 235 --queued_touch_count_; |
| 242 } | 236 } |
| 243 ack_handler_->OnTouchEventAck( | 237 ack_handler_->OnTouchEventAck( |
| 244 TouchEventWithLatencyInfo(static_cast<const WebTouchEvent&>(web_event), | 238 TouchEventWithLatencyInfo(static_cast<const WebTouchEvent&>(web_event), |
| 245 latency_info), | 239 latency_info), |
| 246 acked_result); | 240 acked_result); |
| 247 } else if (WebInputEvent::isGestureEventType(web_event.type)) { | 241 } else if (WebInputEvent::isGestureEventType(web_event.type)) { |
| 248 if (ack_from_input_queue) { | |
| 249 DCHECK_GT(queued_gesture_count_, 0); | |
| 250 --queued_gesture_count_; | |
| 251 } | |
| 252 ack_handler_->OnGestureEventAck( | 242 ack_handler_->OnGestureEventAck( |
| 253 static_cast<const WebGestureEvent&>(web_event), acked_result); | 243 static_cast<const WebGestureEvent&>(web_event), acked_result); |
| 254 } else | 244 } else |
| 255 NOTREACHED() << "Unexpected WebInputEvent in OnWebInputEventAck"; | 245 NOTREACHED() << "Unexpected WebInputEvent in OnWebInputEventAck"; |
| 256 } | 246 } |
| 257 | 247 |
| 258 void BufferedInputRouter::OnEventPacketAck( | 248 void BufferedInputRouter::OnEventPacketAck( |
| 259 int64 packet_id, | 249 int64 packet_id, |
| 260 const InputEventDispositions& dispositions) { | 250 const InputEventDispositions& dispositions) { |
| 261 TRACE_EVENT2("input", "BufferedInputRouter::OnEventPacketAck", | 251 TRACE_EVENT2("input", "BufferedInputRouter::OnEventPacketAck", |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 default: | 327 default: |
| 338 break; | 328 break; |
| 339 }; | 329 }; |
| 340 | 330 |
| 341 return false; | 331 return false; |
| 342 } | 332 } |
| 343 | 333 |
| 344 int64 BufferedInputRouter::NextInputID() { return next_input_id_++; } | 334 int64 BufferedInputRouter::NextInputID() { return next_input_id_++; } |
| 345 | 335 |
| 346 } // namespace content | 336 } // namespace content |
| OLD | NEW |