| 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 #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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 return true; | 62 return true; |
| 63 } | 63 } |
| 64 | 64 |
| 65 return false; | 65 return false; |
| 66 } | 66 } |
| 67 | 67 |
| 68 const TouchEventWithLatencyInfo& coalesced_event() const { | 68 const TouchEventWithLatencyInfo& coalesced_event() const { |
| 69 return coalesced_event_; | 69 return coalesced_event_; |
| 70 } | 70 } |
| 71 | 71 |
| 72 WebTouchEventWithLatencyList::const_iterator begin() const { | 72 WebTouchEventWithLatencyList::iterator begin() { |
| 73 return events_.begin(); | 73 return events_.begin(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 WebTouchEventWithLatencyList::const_iterator end() const { | 76 WebTouchEventWithLatencyList::iterator end() { |
| 77 return events_.end(); | 77 return events_.end(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 size_t size() const { return events_.size(); } | 80 size_t size() const { return events_.size(); } |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 // This is the event that is forwarded to the renderer. | 83 // This is the event that is forwarded to the renderer. |
| 84 TouchEventWithLatencyInfo coalesced_event_; | 84 TouchEventWithLatencyInfo coalesced_event_; |
| 85 | 85 |
| 86 // This is the list of the original events that were coalesced. | 86 // This is the list of the original events that were coalesced. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 const ui::LatencyInfo& renderer_latency_info) { | 187 const ui::LatencyInfo& renderer_latency_info) { |
| 188 if (touch_queue_.empty()) | 188 if (touch_queue_.empty()) |
| 189 return; | 189 return; |
| 190 scoped_ptr<CoalescedWebTouchEvent> acked_event(touch_queue_.front()); | 190 scoped_ptr<CoalescedWebTouchEvent> acked_event(touch_queue_.front()); |
| 191 touch_queue_.pop_front(); | 191 touch_queue_.pop_front(); |
| 192 | 192 |
| 193 // Note that acking the touch-event may result in multiple gestures being sent | 193 // Note that acking the touch-event may result in multiple gestures being sent |
| 194 // to the renderer, or touch-events being queued. | 194 // to the renderer, or touch-events being queued. |
| 195 base::AutoReset<bool> dispatching_touch_ack(&dispatching_touch_ack_, true); | 195 base::AutoReset<bool> dispatching_touch_ack(&dispatching_touch_ack_, true); |
| 196 | 196 |
| 197 base::TimeTicks now = base::TimeTicks::HighResNow(); | 197 for (WebTouchEventWithLatencyList::iterator iter = acked_event->begin(), |
| 198 for (WebTouchEventWithLatencyList::const_iterator iter = acked_event->begin(), | |
| 199 end = acked_event->end(); | 198 end = acked_event->end(); |
| 200 iter != end; ++iter) { | 199 iter != end; ++iter) { |
| 201 ui::LatencyInfo* latency = const_cast<ui::LatencyInfo*>(&(iter->latency)); | 200 iter->latency.AddNewLatencyFrom(renderer_latency_info); |
| 202 latency->AddNewLatencyFrom(renderer_latency_info); | |
| 203 latency->AddLatencyNumberWithTimestamp( | |
| 204 ui::INPUT_EVENT_LATENCY_ACKED_COMPONENT, 0, 0, now, 1); | |
| 205 client_->OnTouchEventAck((*iter), ack_result); | 201 client_->OnTouchEventAck((*iter), ack_result); |
| 206 } | 202 } |
| 207 } | 203 } |
| 208 | 204 |
| 209 bool TouchEventQueue::ShouldForwardToRenderer( | 205 bool TouchEventQueue::ShouldForwardToRenderer( |
| 210 const WebKit::WebTouchEvent& event) const { | 206 const WebKit::WebTouchEvent& event) const { |
| 211 // Touch press events should always be forwarded to the renderer. | 207 // Touch press events should always be forwarded to the renderer. |
| 212 if (event.type == WebKit::WebInputEvent::TouchStart) | 208 if (event.type == WebKit::WebInputEvent::TouchStart) |
| 213 return true; | 209 return true; |
| 214 | 210 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 230 // 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 |
| 231 // forwarded to the renderer. | 227 // forwarded to the renderer. |
| 232 return true; | 228 return true; |
| 233 } | 229 } |
| 234 } | 230 } |
| 235 | 231 |
| 236 return false; | 232 return false; |
| 237 } | 233 } |
| 238 | 234 |
| 239 } // namespace content | 235 } // namespace content |
| OLD | NEW |