| 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 // Adds an event to the queue. The event may be coalesced with previously | 43 // Adds an event to the queue. The event may be coalesced with previously |
| 44 // queued events (e.g. consecutive touch-move events can be coalesced into a | 44 // queued events (e.g. consecutive touch-move events can be coalesced into a |
| 45 // single touch-move event). The event may also be immediately forwarded to | 45 // single touch-move event). The event may also be immediately forwarded to |
| 46 // the renderer (e.g. when there are no other queued touch event). | 46 // the renderer (e.g. when there are no other queued touch event). |
| 47 void QueueEvent(const TouchEventWithLatencyInfo& event); | 47 void QueueEvent(const TouchEventWithLatencyInfo& event); |
| 48 | 48 |
| 49 // Notifies the queue that a touch-event has been processed by the renderer. | 49 // Notifies the queue that a touch-event has been processed by the renderer. |
| 50 // At this point, the queue may send one or more gesture events and/or | 50 // At this point, the queue may send one or more gesture events and/or |
| 51 // additional queued touch-events to the renderer. | 51 // additional queued touch-events to the renderer. |
| 52 void ProcessTouchAck(InputEventAckState ack_result); | 52 void ProcessTouchAck(InputEventAckState ack_result, |
| 53 const ui::LatencyInfo& latency_info); |
| 53 | 54 |
| 54 // Empties the queue of touch events. This may result in any number of gesture | 55 // Empties the queue of touch events. This may result in any number of gesture |
| 55 // events being sent to the renderer. | 56 // events being sent to the renderer. |
| 56 void FlushQueue(); | 57 void FlushQueue(); |
| 57 | 58 |
| 58 // Returns whether the event-queue is empty. | 59 // Returns whether the event-queue is empty. |
| 59 bool empty() const WARN_UNUSED_RESULT { | 60 bool empty() const WARN_UNUSED_RESULT { |
| 60 return touch_queue_.empty(); | 61 return touch_queue_.empty(); |
| 61 } | 62 } |
| 62 | 63 |
| 63 private: | 64 private: |
| 64 friend class MockRenderWidgetHost; | 65 friend class MockRenderWidgetHost; |
| 65 friend class ImmediateInputRouterTest; | 66 friend class ImmediateInputRouterTest; |
| 66 | 67 |
| 67 CONTENT_EXPORT size_t GetQueueSize() const; | 68 CONTENT_EXPORT size_t GetQueueSize() const; |
| 68 CONTENT_EXPORT const TouchEventWithLatencyInfo& GetLatestEvent() const; | 69 CONTENT_EXPORT const TouchEventWithLatencyInfo& GetLatestEvent() const; |
| 69 | 70 |
| 70 // Pops the touch-event from the top of the queue and sends it to the | 71 // Pops the touch-event from the top of the queue and sends it to the |
| 71 // TouchEventQueueClient. This reduces the size of the queue by one. | 72 // TouchEventQueueClient. This reduces the size of the queue by one. |
| 72 void PopTouchEventWithAck(InputEventAckState ack_result); | 73 void PopTouchEventToClient(InputEventAckState ack_result, |
| 74 const ui::LatencyInfo& renderer_latency_info); |
| 73 | 75 |
| 74 bool ShouldForwardToRenderer(const WebKit::WebTouchEvent& event) const; | 76 bool ShouldForwardToRenderer(const WebKit::WebTouchEvent& event) const; |
| 75 | 77 |
| 76 // Handles touch event forwarding and ack'ed event dispatch. | 78 // Handles touch event forwarding and ack'ed event dispatch. |
| 77 TouchEventQueueClient* client_; | 79 TouchEventQueueClient* client_; |
| 78 | 80 |
| 79 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; | 81 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; |
| 80 TouchQueue touch_queue_; | 82 TouchQueue touch_queue_; |
| 81 | 83 |
| 82 // Maintain the ACK status for each touch point. | 84 // Maintain the ACK status for each touch point. |
| 83 typedef std::map<int, InputEventAckState> TouchPointAckStates; | 85 typedef std::map<int, InputEventAckState> TouchPointAckStates; |
| 84 TouchPointAckStates touch_ack_states_; | 86 TouchPointAckStates touch_ack_states_; |
| 85 | 87 |
| 86 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. | 88 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. |
| 87 bool dispatching_touch_ack_; | 89 bool dispatching_touch_ack_; |
| 88 | 90 |
| 89 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 91 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
| 90 }; | 92 }; |
| 91 | 93 |
| 92 } // namespace content | 94 } // namespace content |
| 93 | 95 |
| 94 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 96 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
| OLD | NEW |