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

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

Issue 19670007: Send input event's LatencyInfo back from renderer to browser when acked (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase & remove CrackMessage() Created 7 years, 4 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 #include "content/browser/renderer_host/input/touch_event_queue.h" 5 #include "content/browser/renderer_host/input/touch_event_queue.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (last_event.touches[i].state == WebKit::WebTouchPoint::StateMoved) 58 if (last_event.touches[i].state == WebKit::WebTouchPoint::StateMoved)
59 coalesced_event_.event.touches[i].state = 59 coalesced_event_.event.touches[i].state =
60 WebKit::WebTouchPoint::StateMoved; 60 WebKit::WebTouchPoint::StateMoved;
61 } 61 }
62 return true; 62 return true;
63 } 63 }
64 64
65 return false; 65 return false;
66 } 66 }
67 67
68 void SetLatencyInfoForCoalescedEvent(const ui::LatencyInfo& latency_info) {
69 coalesced_event_.latency = latency_info;
70 }
71
68 const TouchEventWithLatencyInfo& coalesced_event() const { 72 const TouchEventWithLatencyInfo& coalesced_event() const {
69 return coalesced_event_; 73 return coalesced_event_;
70 } 74 }
71 75
72 WebTouchEventWithLatencyList::const_iterator begin() const { 76 WebTouchEventWithLatencyList::const_iterator begin() const {
73 return events_.begin(); 77 return events_.begin();
74 } 78 }
75 79
76 WebTouchEventWithLatencyList::const_iterator end() const { 80 WebTouchEventWithLatencyList::const_iterator end() const {
77 return events_.end(); 81 return events_.end();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // If the last queued touch-event was a touch-move, and the current event is 121 // If the last queued touch-event was a touch-move, and the current event is
118 // also a touch-move, then the events can be coalesced into a single event. 122 // also a touch-move, then the events can be coalesced into a single event.
119 if (touch_queue_.size() > 1) { 123 if (touch_queue_.size() > 1) {
120 CoalescedWebTouchEvent* last_event = touch_queue_.back(); 124 CoalescedWebTouchEvent* last_event = touch_queue_.back();
121 if (last_event->CoalesceEventIfPossible(event)) 125 if (last_event->CoalesceEventIfPossible(event))
122 return; 126 return;
123 } 127 }
124 touch_queue_.push_back(new CoalescedWebTouchEvent(event)); 128 touch_queue_.push_back(new CoalescedWebTouchEvent(event));
125 } 129 }
126 130
127 void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result) { 131 void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result,
132 const ui::LatencyInfo& latency_info) {
128 DCHECK(!dispatching_touch_ack_); 133 DCHECK(!dispatching_touch_ack_);
129 if (touch_queue_.empty()) 134 if (touch_queue_.empty())
130 return; 135 return;
131 136
137 touch_queue_.front()->SetLatencyInfoForCoalescedEvent(latency_info);
sadrul 2013/08/06 19:08:27 Instead of doing this, can you send |latency_info|
Yufeng Shen (Slow to review) 2013/08/06 19:36:14 Done.
138
132 // Update the ACK status for each touch point in the ACKed event. 139 // Update the ACK status for each touch point in the ACKed event.
133 const WebKit::WebTouchEvent& event = 140 const WebKit::WebTouchEvent& event =
134 touch_queue_.front()->coalesced_event().event; 141 touch_queue_.front()->coalesced_event().event;
135 if (event.type == WebKit::WebInputEvent::TouchEnd || 142 if (event.type == WebKit::WebInputEvent::TouchEnd ||
136 event.type == WebKit::WebInputEvent::TouchCancel) { 143 event.type == WebKit::WebInputEvent::TouchCancel) {
137 // The points have been released. Erase the ACK states. 144 // The points have been released. Erase the ACK states.
138 for (unsigned i = 0; i < event.touchesLength; ++i) { 145 for (unsigned i = 0; i < event.touchesLength; ++i) {
139 const WebKit::WebTouchPoint& point = event.touches[i]; 146 const WebKit::WebTouchPoint& point = event.touches[i];
140 if (point.state == WebKit::WebTouchPoint::StateReleased || 147 if (point.state == WebKit::WebTouchPoint::StateReleased ||
141 point.state == WebKit::WebTouchPoint::StateCancelled) 148 point.state == WebKit::WebTouchPoint::StateCancelled)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 touch_queue_.pop_front(); 192 touch_queue_.pop_front();
186 193
187 // Note that acking the touch-event may result in multiple gestures being sent 194 // Note that acking the touch-event may result in multiple gestures being sent
188 // to the renderer, or touch-events being queued. 195 // to the renderer, or touch-events being queued.
189 base::AutoReset<bool> dispatching_touch_ack(&dispatching_touch_ack_, true); 196 base::AutoReset<bool> dispatching_touch_ack(&dispatching_touch_ack_, true);
190 197
191 for (WebTouchEventWithLatencyList::const_iterator iter = acked_event->begin(), 198 for (WebTouchEventWithLatencyList::const_iterator iter = acked_event->begin(),
192 end = acked_event->end(); 199 end = acked_event->end();
193 iter != end; ++iter) { 200 iter != end; ++iter) {
194 ui::LatencyInfo* latency = const_cast<ui::LatencyInfo*>(&(iter->latency)); 201 ui::LatencyInfo* latency = const_cast<ui::LatencyInfo*>(&(iter->latency));
202 latency->AddNewLatencyFrom(acked_event->coalesced_event().latency);
195 latency->AddLatencyNumber( 203 latency->AddLatencyNumber(
196 ui::INPUT_EVENT_LATENCY_ACKED_COMPONENT, 0, 0); 204 ui::INPUT_EVENT_LATENCY_ACKED_COMPONENT, 0, 0);
197 client_->OnTouchEventAck((*iter), ack_result); 205 client_->OnTouchEventAck((*iter), ack_result);
198 } 206 }
199 } 207 }
200 208
201 bool TouchEventQueue::ShouldForwardToRenderer( 209 bool TouchEventQueue::ShouldForwardToRenderer(
202 const WebKit::WebTouchEvent& event) const { 210 const WebKit::WebTouchEvent& event) const {
203 // Touch press events should always be forwarded to the renderer. 211 // Touch press events should always be forwarded to the renderer.
204 if (event.type == WebKit::WebInputEvent::TouchStart) 212 if (event.type == WebKit::WebInputEvent::TouchStart)
(...skipping 13 matching lines...) Expand all
218 // If the ACK status of a point is unknown, then the event should be 226 // If the ACK status of a point is unknown, then the event should be
219 // forwarded to the renderer. 227 // forwarded to the renderer.
220 return true; 228 return true;
221 } 229 }
222 } 230 }
223 231
224 return false; 232 return false;
225 } 233 }
226 234
227 } // namespace content 235 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/touch_event_queue.h ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698