Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(911)

Side by Side Diff: content/browser/renderer_host/input/touch_event_queue.h

Issue 25022003: Report LatencyInfo through trace buffer (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix nits Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 10 matching lines...) Expand all
21 // Interface with which TouchEventQueue can forward touch events, and dispatch 21 // Interface with which TouchEventQueue can forward touch events, and dispatch
22 // touch event responses. 22 // touch event responses.
23 class CONTENT_EXPORT TouchEventQueueClient { 23 class CONTENT_EXPORT TouchEventQueueClient {
24 public: 24 public:
25 virtual ~TouchEventQueueClient() {} 25 virtual ~TouchEventQueueClient() {}
26 26
27 virtual void SendTouchEventImmediately( 27 virtual void SendTouchEventImmediately(
28 const TouchEventWithLatencyInfo& event) = 0; 28 const TouchEventWithLatencyInfo& event) = 0;
29 29
30 virtual void OnTouchEventAck( 30 virtual void OnTouchEventAck(
31 const TouchEventWithLatencyInfo& event, 31 const WebKit::WebTouchEvent& event,
32 InputEventAckState ack_result) = 0; 32 InputEventAckState ack_result,
33 ui::LatencyInfo* latency) = 0;
33 }; 34 };
34 35
35 // A queue for throttling and coalescing touch-events. 36 // A queue for throttling and coalescing touch-events.
36 class CONTENT_EXPORT TouchEventQueue { 37 class CONTENT_EXPORT TouchEventQueue {
37 public: 38 public:
38 39
39 // The |client| must outlive the TouchEventQueue. 40 // The |client| must outlive the TouchEventQueue.
40 explicit TouchEventQueue(TouchEventQueueClient* client); 41 explicit TouchEventQueue(TouchEventQueueClient* client);
41 virtual ~TouchEventQueue(); 42 virtual ~TouchEventQueue();
42 43
43 // Adds an event to the queue. The event may be coalesced with previously 44 // 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 45 // 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 46 // 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). 47 // the renderer (e.g. when there are no other queued touch event).
47 void QueueEvent(const TouchEventWithLatencyInfo& event); 48 void QueueEvent(const TouchEventWithLatencyInfo& event);
48 49
49 // Notifies the queue that a touch-event has been processed by the renderer. 50 // 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 51 // At this point, the queue may send one or more gesture events and/or
51 // additional queued touch-events to the renderer. 52 // additional queued touch-events to the renderer.
52 void ProcessTouchAck(InputEventAckState ack_result, 53 void ProcessTouchAck(InputEventAckState ack_result,
53 const ui::LatencyInfo& latency_info); 54 ui::LatencyInfo* latency_info);
54 55
55 // Empties the queue of touch events. This may result in any number of gesture 56 // Empties the queue of touch events. This may result in any number of gesture
56 // events being sent to the renderer. 57 // events being sent to the renderer.
57 void FlushQueue(); 58 void FlushQueue();
58 59
59 // Returns whether the event-queue is empty. 60 // Returns whether the event-queue is empty.
60 bool empty() const WARN_UNUSED_RESULT { 61 bool empty() const WARN_UNUSED_RESULT {
61 return touch_queue_.empty(); 62 return touch_queue_.empty();
62 } 63 }
63 64
(...skipping 11 matching lines...) Expand all
75 const TouchEventWithLatencyInfo& GetLatestEvent() const; 76 const TouchEventWithLatencyInfo& GetLatestEvent() const;
76 77
77 // Walks the queue, checking each event for |ShouldForwardToRenderer()|. 78 // Walks the queue, checking each event for |ShouldForwardToRenderer()|.
78 // If true, forwards the touch event and stops processing further events. 79 // If true, forwards the touch event and stops processing further events.
79 // If false, acks the event with |INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS|. 80 // If false, acks the event with |INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS|.
80 void TryForwardNextEventToRenderer(); 81 void TryForwardNextEventToRenderer();
81 82
82 // Pops the touch-event from the top of the queue and sends it to the 83 // Pops the touch-event from the top of the queue and sends it to the
83 // TouchEventQueueClient. This reduces the size of the queue by one. 84 // TouchEventQueueClient. This reduces the size of the queue by one.
84 void PopTouchEventToClient(InputEventAckState ack_result, 85 void PopTouchEventToClient(InputEventAckState ack_result,
85 const ui::LatencyInfo& renderer_latency_info); 86 ui::LatencyInfo* renderer_latency_info);
86 87
87 bool ShouldForwardToRenderer(const WebKit::WebTouchEvent& event) const; 88 bool ShouldForwardToRenderer(const WebKit::WebTouchEvent& event) const;
88 89
89 // Handles touch event forwarding and ack'ed event dispatch. 90 // Handles touch event forwarding and ack'ed event dispatch.
90 TouchEventQueueClient* client_; 91 TouchEventQueueClient* client_;
91 92
92 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue; 93 typedef std::deque<CoalescedWebTouchEvent*> TouchQueue;
93 TouchQueue touch_queue_; 94 TouchQueue touch_queue_;
94 95
95 // Maintain the ACK status for each touch point. 96 // Maintain the ACK status for each touch point.
96 typedef std::map<int, InputEventAckState> TouchPointAckStates; 97 typedef std::map<int, InputEventAckState> TouchPointAckStates;
97 TouchPointAckStates touch_ack_states_; 98 TouchPointAckStates touch_ack_states_;
98 99
99 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|. 100 // Used to defer touch forwarding when ack dispatch triggers |QueueEvent()|.
100 bool dispatching_touch_ack_; 101 bool dispatching_touch_ack_;
101 102
102 // Don't send touch move events to renderer. This is enabled when the page 103 // Don't send touch move events to renderer. This is enabled when the page
103 // is scrolling. This behaviour is currently enabled only on aura behind a 104 // is scrolling. This behaviour is currently enabled only on aura behind a
104 // flag. 105 // flag.
105 bool no_touch_move_to_renderer_; 106 bool no_touch_move_to_renderer_;
106 107
107 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); 108 DISALLOW_COPY_AND_ASSIGN(TouchEventQueue);
108 }; 109 };
109 110
110 } // namespace content 111 } // namespace content
111 112
112 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_ 113 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EVENT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698