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 "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
13 | 13 |
14 class MockRenderWidgetHost; | |
15 | |
16 namespace content { | 14 namespace content { |
17 | 15 |
18 class CoalescedWebTouchEvent; | 16 class CoalescedWebTouchEvent; |
| 17 class MockRenderWidgetHost; |
19 class RenderWidgetHostImpl; | 18 class RenderWidgetHostImpl; |
20 | 19 |
21 // A queue for throttling and coalescing touch-events. | 20 // A queue for throttling and coalescing touch-events. |
22 class TouchEventQueue { | 21 class TouchEventQueue { |
23 public: | 22 public: |
24 explicit TouchEventQueue(RenderWidgetHostImpl* host); | 23 explicit TouchEventQueue(RenderWidgetHostImpl* host); |
25 virtual ~TouchEventQueue(); | 24 virtual ~TouchEventQueue(); |
26 | 25 |
27 // Adds an event to the queue. The event may be coalesced with previously | 26 // Adds an event to the queue. The event may be coalesced with previously |
28 // queued events (e.g. consecutive touch-move events can be coalesced into a | 27 // queued events (e.g. consecutive touch-move events can be coalesced into a |
(...skipping 13 matching lines...) Expand all Loading... |
42 // Resets all internal state. This does not trigger any touch or gesture | 41 // Resets all internal state. This does not trigger any touch or gesture |
43 // events to be sent. | 42 // events to be sent. |
44 void Reset(); | 43 void Reset(); |
45 | 44 |
46 // Returns whether the event-queue is empty. | 45 // Returns whether the event-queue is empty. |
47 bool empty() const WARN_UNUSED_RESULT { | 46 bool empty() const WARN_UNUSED_RESULT { |
48 return touch_queue_.empty(); | 47 return touch_queue_.empty(); |
49 } | 48 } |
50 | 49 |
51 private: | 50 private: |
52 friend class ::MockRenderWidgetHost; | 51 friend class MockRenderWidgetHost; |
53 | 52 |
54 CONTENT_EXPORT size_t GetQueueSize() const; | 53 CONTENT_EXPORT size_t GetQueueSize() const; |
55 CONTENT_EXPORT const WebKit::WebTouchEvent& GetLatestEvent() const; | 54 CONTENT_EXPORT const WebKit::WebTouchEvent& GetLatestEvent() const; |
56 | 55 |
57 // Pops the touch-event from the top of the queue and sends it to the | 56 // Pops the touch-event from the top of the queue and sends it to the |
58 // RenderWidgetHostView. This reduces the size of the queue by one. | 57 // RenderWidgetHostView. This reduces the size of the queue by one. |
59 void PopTouchEventToView(bool processed); | 58 void PopTouchEventToView(bool processed); |
60 | 59 |
61 // The RenderWidgetHost that owns this event-queue. | 60 // The RenderWidgetHost that owns this event-queue. |
62 RenderWidgetHostImpl* render_widget_host_; | 61 RenderWidgetHostImpl* render_widget_host_; |
63 | 62 |
64 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; | 63 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; |
65 TouchQueue touch_queue_; | 64 TouchQueue touch_queue_; |
66 | 65 |
67 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); | 66 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); |
68 }; | 67 }; |
69 | 68 |
70 } // namespace content | 69 } // namespace content |
71 | 70 |
72 #endif // CONTENT_BROWSER_RENDERER_HOST_TOUCH_EVENT_QUEUE_H_ | 71 #endif // CONTENT_BROWSER_RENDERER_HOST_TOUCH_EVENT_QUEUE_H_ |
OLD | NEW |