OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_TOUCH_EVENT_QUEUE_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_TOUCH_EVENT_QUEUE_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_TOUCH_EVENT_QUEUE_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_TOUCH_EVENT_QUEUE_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
12 | 12 |
| 13 class MockRenderWidgetHost; |
| 14 |
13 namespace content { | 15 namespace content { |
14 | 16 |
15 class RenderWidgetHostImpl; | 17 class RenderWidgetHostImpl; |
16 | 18 |
17 // A queue for throttling and coalescing touch-events. | 19 // A queue for throttling and coalescing touch-events. |
18 class TouchEventQueue { | 20 class TouchEventQueue { |
19 public: | 21 public: |
20 explicit TouchEventQueue(RenderWidgetHostImpl* host); | 22 explicit TouchEventQueue(RenderWidgetHostImpl* host); |
21 virtual ~TouchEventQueue(); | 23 virtual ~TouchEventQueue(); |
22 | 24 |
23 // Adds an event to the queue. The event may be coalesced with previously | 25 // Adds an event to the queue. The event may be coalesced with previously |
24 // queued events (e.g. consecutive touch-move events can be coalesced into a | 26 // queued events (e.g. consecutive touch-move events can be coalesced into a |
25 // single touch-move event). The event may also be immediately forwarded to | 27 // single touch-move event). The event may also be immediately forwarded to |
26 // the renderer (e.g. when there are no other queued touch event). | 28 // the renderer (e.g. when there are no other queued touch event). |
27 void QueueEvent(const WebKit::WebTouchEvent& event); | 29 void QueueEvent(const WebKit::WebTouchEvent& event); |
28 | 30 |
29 // Notifies the queue that a touch-event has been processed by the renderer. | 31 // Notifies the queue that a touch-event has been processed by the renderer. |
30 // At this point, the queue may send one or more gesture events and/or | 32 // At this point, the queue may send one or more gesture events and/or |
31 // additional queued touch-events to the renderer. | 33 // additional queued touch-events to the renderer. |
32 void ProcessTouchAck(bool processed); | 34 void ProcessTouchAck(bool processed); |
33 | 35 |
| 36 // Empties the queue of touch events. This may result in any number of gesture |
| 37 // events being sent to the renderer. |
| 38 void FlushQueue(); |
| 39 |
| 40 // Resets all internal state. This does not trigger any touch or gesture |
| 41 // events to be sent. |
| 42 void Reset(); |
| 43 |
| 44 // Returns whether the event-queue is empty. |
| 45 bool empty() const WARN_UNUSED_RESULT { |
| 46 return touch_queue_.empty(); |
| 47 } |
| 48 |
34 private: | 49 private: |
| 50 friend class ::MockRenderWidgetHost; |
| 51 |
| 52 // Pops the touch-event from the top of the queue and sends it to the |
| 53 // RenderWidgetHostView. This reduces the size of the queue by one. |
| 54 void PopTouchEventToView(bool processed); |
| 55 |
35 // The RenderWidgetHost that owns this event-queue. | 56 // The RenderWidgetHost that owns this event-queue. |
36 RenderWidgetHostImpl* render_widget_host_; | 57 RenderWidgetHostImpl* render_widget_host_; |
37 | 58 |
38 typedef std::deque<WebKit::WebTouchEvent> TouchQueue; | 59 typedef std::deque<WebKit::WebTouchEvent> TouchQueue; |
39 TouchQueue touch_queue_; | 60 TouchQueue touch_queue_; |
40 | 61 |
41 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 62 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
42 }; | 63 }; |
43 | 64 |
44 } // namespace content | 65 } // namespace content |
45 | 66 |
46 #endif // CONTENT_BROWSER_RENDERER_HOST_TOUCH_EVENT_QUEUE_H_ | 67 #endif // CONTENT_BROWSER_RENDERER_HOST_TOUCH_EVENT_QUEUE_H_ |
OLD | NEW |