| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/common/input/event_with_latency_info.h" | 5 #include "content/common/input/event_with_latency_info.h" |
| 6 | 6 |
| 7 using blink::WebInputEvent; | 7 using blink::WebInputEvent; |
| 8 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 | 22 |
| 23 void ScopedWebInputEventWithLatencyInfo::CoalesceWith( | 23 void ScopedWebInputEventWithLatencyInfo::CoalesceWith( |
| 24 const ScopedWebInputEventWithLatencyInfo& other) { | 24 const ScopedWebInputEventWithLatencyInfo& other) { |
| 25 // |other| should be a newer event than |this|. | 25 // |other| should be a newer event than |this|. |
| 26 if (other.latency_.trace_id() >= 0 && latency_.trace_id() >= 0) | 26 if (other.latency_.trace_id() >= 0 && latency_.trace_id() >= 0) |
| 27 DCHECK_GT(other.latency_.trace_id(), latency_.trace_id()); | 27 DCHECK_GT(other.latency_.trace_id(), latency_.trace_id()); |
| 28 | 28 |
| 29 // New events get coalesced into older events, and the newer timestamp | 29 // New events get coalesced into older events, and the newer timestamp |
| 30 // should always be preserved. | 30 // should always be preserved. |
| 31 const double time_stamp_seconds = other.event().timeStampSeconds; | 31 const double time_stamp_seconds = other.event().timeStampSeconds(); |
| 32 ui::Coalesce(other.event(), event_.get()); | 32 ui::Coalesce(other.event(), event_.get()); |
| 33 event_->setTimeStampSeconds(time_stamp_seconds); | 33 event_->setTimeStampSeconds(time_stamp_seconds); |
| 34 | 34 |
| 35 // When coalescing two input events, we keep the oldest LatencyInfo | 35 // When coalescing two input events, we keep the oldest LatencyInfo |
| 36 // since it will represent the longest latency. | 36 // since it will represent the longest latency. |
| 37 other.latency_ = latency_; | 37 other.latency_ = latency_; |
| 38 other.latency_.set_coalesced(); | 38 other.latency_.set_coalesced(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 const blink::WebInputEvent& ScopedWebInputEventWithLatencyInfo::event() const { | 41 const blink::WebInputEvent& ScopedWebInputEventWithLatencyInfo::event() const { |
| 42 return *event_; | 42 return *event_; |
| 43 } | 43 } |
| 44 | 44 |
| 45 blink::WebInputEvent& ScopedWebInputEventWithLatencyInfo::event() { | 45 blink::WebInputEvent& ScopedWebInputEventWithLatencyInfo::event() { |
| 46 return *event_; | 46 return *event_; |
| 47 } | 47 } |
| 48 | 48 |
| 49 } // namespace content | 49 } // namespace content |
| OLD | NEW |