| 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 #ifndef CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_ | 5 #ifndef CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_ |
| 6 #define CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_ | 6 #define CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 EventWithLatencyInfo(blink::WebInputEvent::Type type, | 51 EventWithLatencyInfo(blink::WebInputEvent::Type type, |
| 52 int modifiers, | 52 int modifiers, |
| 53 double timeStampSeconds, | 53 double timeStampSeconds, |
| 54 const ui::LatencyInfo& l) | 54 const ui::LatencyInfo& l) |
| 55 : event(type, modifiers, timeStampSeconds), latency(l) {} | 55 : event(type, modifiers, timeStampSeconds), latency(l) {} |
| 56 | 56 |
| 57 EventWithLatencyInfo() {} | 57 EventWithLatencyInfo() {} |
| 58 | 58 |
| 59 bool CanCoalesceWith(const EventWithLatencyInfo& other) | 59 bool CanCoalesceWith(const EventWithLatencyInfo& other) |
| 60 const WARN_UNUSED_RESULT { | 60 const WARN_UNUSED_RESULT { |
| 61 if (other.event.type != event.type) | 61 if (other.event.type() != event.type()) |
| 62 return false; | 62 return false; |
| 63 | 63 |
| 64 DCHECK_EQ(sizeof(T), event.size); | 64 DCHECK_EQ(sizeof(T), event.size()); |
| 65 DCHECK_EQ(sizeof(T), other.event.size); | 65 DCHECK_EQ(sizeof(T), other.event.size()); |
| 66 | 66 |
| 67 return ui::CanCoalesce(other.event, event); | 67 return ui::CanCoalesce(other.event, event); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void CoalesceWith(const EventWithLatencyInfo& other) { | 70 void CoalesceWith(const EventWithLatencyInfo& other) { |
| 71 // |other| should be a newer event than |this|. | 71 // |other| should be a newer event than |this|. |
| 72 if (other.latency.trace_id() >= 0 && latency.trace_id() >= 0) | 72 if (other.latency.trace_id() >= 0 && latency.trace_id() >= 0) |
| 73 DCHECK_GT(other.latency.trace_id(), latency.trace_id()); | 73 DCHECK_GT(other.latency.trace_id(), latency.trace_id()); |
| 74 | 74 |
| 75 // New events get coalesced into older events, and the newer timestamp | 75 // New events get coalesced into older events, and the newer timestamp |
| 76 // should always be preserved. | 76 // should always be preserved. |
| 77 const double time_stamp_seconds = other.event.timeStampSeconds; | 77 const double time_stamp_seconds = other.event.timeStampSeconds(); |
| 78 ui::Coalesce(other.event, &event); | 78 ui::Coalesce(other.event, &event); |
| 79 event.setTimeStampSeconds(time_stamp_seconds); | 79 event.setTimeStampSeconds(time_stamp_seconds); |
| 80 | 80 |
| 81 // When coalescing two input events, we keep the oldest LatencyInfo | 81 // When coalescing two input events, we keep the oldest LatencyInfo |
| 82 // for Telemetry latency tests, since it will represent the longest | 82 // for Telemetry latency tests, since it will represent the longest |
| 83 // latency. | 83 // latency. |
| 84 other.latency = latency; | 84 other.latency = latency; |
| 85 other.latency.set_coalesced(); | 85 other.latency.set_coalesced(); |
| 86 } | 86 } |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 typedef EventWithLatencyInfo<blink::WebGestureEvent> | 89 typedef EventWithLatencyInfo<blink::WebGestureEvent> |
| 90 GestureEventWithLatencyInfo; | 90 GestureEventWithLatencyInfo; |
| 91 typedef EventWithLatencyInfo<blink::WebMouseWheelEvent> | 91 typedef EventWithLatencyInfo<blink::WebMouseWheelEvent> |
| 92 MouseWheelEventWithLatencyInfo; | 92 MouseWheelEventWithLatencyInfo; |
| 93 typedef EventWithLatencyInfo<blink::WebMouseEvent> | 93 typedef EventWithLatencyInfo<blink::WebMouseEvent> |
| 94 MouseEventWithLatencyInfo; | 94 MouseEventWithLatencyInfo; |
| 95 typedef EventWithLatencyInfo<blink::WebTouchEvent> | 95 typedef EventWithLatencyInfo<blink::WebTouchEvent> |
| 96 TouchEventWithLatencyInfo; | 96 TouchEventWithLatencyInfo; |
| 97 | 97 |
| 98 } // namespace content | 98 } // namespace content |
| 99 | 99 |
| 100 #endif // CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_ | 100 #endif // CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_ |
| OLD | NEW |