| 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 | 66 |
| 66 CONTENT_EXPORT size_t GetQueueSize() const; | 67 CONTENT_EXPORT size_t GetQueueSize() const; |
| 67 CONTENT_EXPORT const TouchEventWithLatencyInfo& GetLatestEvent() const; | 68 CONTENT_EXPORT const TouchEventWithLatencyInfo& GetLatestEvent() const; |
| 68 | 69 |
| 69 // Pops the touch-event from the top of the queue and sends it to the | 70 // Pops the touch-event from the top of the queue and sends it to the |
| 70 // TouchEventQueueClient. This reduces the size of the queue by one. | 71 // TouchEventQueueClient. This reduces the size of the queue by one. |
| 71 void PopTouchEventWithAck(InputEventAckState ack_result); | 72 void PopTouchEventToClient(InputEventAckState ack_result, |
| 73 const ui::LatencyInfo& renderer_latency_info); |
| 72 | 74 |
| 73 bool ShouldForwardToRenderer(const WebKit::WebTouchEvent& event) const; | 75 bool ShouldForwardToRenderer(const WebKit::WebTouchEvent& event) const; |
| 74 | 76 |
| 75 // Handles touch event forwarding and ack'ed event dispatch. | 77 // Handles touch event forwarding and ack'ed event dispatch. |
| 76 TouchEventQueueClient* client_; | 78 TouchEventQueueClient* client_; |
| 77 | 79 |
| 78 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; | 80 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; |
| 79 TouchQueue touch_queue_; | 81 TouchQueue touch_queue_; |
| 80 | 82 |
| 81 // Maintain the ACK status for each touch point. | 83 // Maintain the ACK status for each touch point. |
| 82 typedef std::map<int, InputEventAckState> TouchPointAckStates; | 84 typedef std::map<int, InputEventAckState> TouchPointAckStates; |
| 83 TouchPointAckStates touch_ack_states_; | 85 TouchPointAckStates touch_ack_states_; |
| 84 | 86 |
| 85 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. | 87 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. |
| 86 bool dispatching_touch_ack_; | 88 bool dispatching_touch_ack_; |
| 87 | 89 |
| 88 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 90 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
| 89 }; | 91 }; |
| 90 | 92 |
| 91 } // namespace content | 93 } // namespace content |
| 92 | 94 |
| 93 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ | 95 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ |
| OLD | NEW |