| 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 "ui/events/blink/event_with_callback.h" | 5 #include "ui/events/blink/event_with_callback.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/trace_event/trace_event.h" |
| 8 #include "ui/events/blink/blink_event_util.h" | 9 #include "ui/events/blink/blink_event_util.h" |
| 9 #include "ui/events/blink/did_overscroll_params.h" | 10 #include "ui/events/blink/did_overscroll_params.h" |
| 10 #include "ui/events/blink/web_input_event_traits.h" | 11 #include "ui/events/blink/web_input_event_traits.h" |
| 11 | 12 |
| 12 using blink::WebInputEvent; | 13 using blink::WebInputEvent; |
| 13 using blink::WebGestureEvent; | 14 using blink::WebGestureEvent; |
| 14 | 15 |
| 15 namespace ui { | 16 namespace ui { |
| 16 | 17 |
| 17 EventWithCallback::EventWithCallback( | 18 EventWithCallback::EventWithCallback( |
| 18 WebScopedInputEvent event, | 19 WebScopedInputEvent event, |
| 19 const LatencyInfo& latency, | 20 const LatencyInfo& latency, |
| 20 base::TimeTicks timestamp_now, | 21 base::TimeTicks timestamp_now, |
| 21 const InputHandlerProxy::EventDispositionCallback& callback) | 22 const InputHandlerProxy::EventDispositionCallback& callback) |
| 22 : event_(WebInputEventTraits::Clone(*event)), | 23 : event_(WebInputEventTraits::Clone(*event)), |
| 23 latency_(latency), | 24 latency_(latency), |
| 24 creation_timestamp_(timestamp_now), | 25 creation_timestamp_(timestamp_now), |
| 25 last_coalesced_timestamp_(timestamp_now) { | 26 last_coalesced_timestamp_(timestamp_now) { |
| 27 TRACE_EVENT_ASYNC_BEGIN0("input", "InputHandlerProxy::EventWithCallback", |
| 28 this); |
| 26 original_events_.emplace_back(std::move(event), callback); | 29 original_events_.emplace_back(std::move(event), callback); |
| 27 } | 30 } |
| 28 | 31 |
| 29 EventWithCallback::EventWithCallback( | 32 EventWithCallback::EventWithCallback( |
| 30 WebScopedInputEvent event, | 33 WebScopedInputEvent event, |
| 31 const LatencyInfo& latency, | 34 const LatencyInfo& latency, |
| 32 base::TimeTicks creation_timestamp, | 35 base::TimeTicks creation_timestamp, |
| 33 base::TimeTicks last_coalesced_timestamp, | 36 base::TimeTicks last_coalesced_timestamp, |
| 34 std::unique_ptr<OriginalEventList> original_events) | 37 std::unique_ptr<OriginalEventList> original_events) |
| 35 : event_(std::move(event)), | 38 : event_(std::move(event)), |
| 36 latency_(latency), | 39 latency_(latency), |
| 37 creation_timestamp_(creation_timestamp), | 40 creation_timestamp_(creation_timestamp), |
| 38 last_coalesced_timestamp_(last_coalesced_timestamp) { | 41 last_coalesced_timestamp_(last_coalesced_timestamp) { |
| 42 TRACE_EVENT_ASYNC_BEGIN0("input", "InputHandlerProxy::EventWithCallback", |
| 43 this); |
| 39 if (original_events) | 44 if (original_events) |
| 40 original_events_.splice(original_events_.end(), *original_events); | 45 original_events_.splice(original_events_.end(), *original_events); |
| 41 } | 46 } |
| 42 | 47 |
| 43 EventWithCallback::~EventWithCallback() {} | 48 EventWithCallback::~EventWithCallback() { |
| 49 TRACE_EVENT_ASYNC_END0("input", "InputHandlerProxy::EventWithCallback", this); |
| 50 } |
| 44 | 51 |
| 45 bool EventWithCallback::CanCoalesceWith(const EventWithCallback& other) const { | 52 bool EventWithCallback::CanCoalesceWith(const EventWithCallback& other) const { |
| 46 return CanCoalesce(other.event(), event()); | 53 return CanCoalesce(other.event(), event()); |
| 47 } | 54 } |
| 48 | 55 |
| 49 void EventWithCallback::CoalesceWith(EventWithCallback* other, | 56 void EventWithCallback::CoalesceWith(EventWithCallback* other, |
| 50 base::TimeTicks timestamp_now) { | 57 base::TimeTicks timestamp_now) { |
| 51 // |other| should be a newer event than |this|. | 58 // |other| should be a newer event than |this|. |
| 52 if (other->latency_.trace_id() >= 0 && latency_.trace_id() >= 0) | 59 if (other->latency_.trace_id() >= 0 && latency_.trace_id() >= 0) |
| 53 DCHECK_GT(other->latency_.trace_id(), latency_.trace_id()); | 60 DCHECK_GT(other->latency_.trace_id(), latency_.trace_id()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 84 } | 91 } |
| 85 | 92 |
| 86 EventWithCallback::OriginalEventWithCallback::OriginalEventWithCallback( | 93 EventWithCallback::OriginalEventWithCallback::OriginalEventWithCallback( |
| 87 WebScopedInputEvent event, | 94 WebScopedInputEvent event, |
| 88 const InputHandlerProxy::EventDispositionCallback& callback) | 95 const InputHandlerProxy::EventDispositionCallback& callback) |
| 89 : event_(std::move(event)), callback_(callback) {} | 96 : event_(std::move(event)), callback_(callback) {} |
| 90 | 97 |
| 91 EventWithCallback::OriginalEventWithCallback::~OriginalEventWithCallback() {} | 98 EventWithCallback::OriginalEventWithCallback::~OriginalEventWithCallback() {} |
| 92 | 99 |
| 93 } // namespace ui | 100 } // namespace ui |
| OLD | NEW |