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 #ifndef UI_EVENTS_BLINK_EVENT_WITH_CALLBACK_H_ | 5 #ifndef UI_EVENTS_BLINK_EVENT_WITH_CALLBACK_H_ |
6 #define UI_EVENTS_BLINK_EVENT_WITH_CALLBACK_H_ | 6 #define UI_EVENTS_BLINK_EVENT_WITH_CALLBACK_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "ui/events/blink/input_handler_proxy.h" | 10 #include "ui/events/blink/input_handler_proxy.h" |
11 #include "ui/events/latency_info.h" | 11 #include "ui/events/latency_info.h" |
12 | 12 |
13 namespace ui { | 13 namespace ui { |
14 | 14 |
15 namespace test { | 15 namespace test { |
16 class InputHandlerProxyEventQueueTest; | 16 class InputHandlerProxyEventQueueTest; |
17 } | 17 } |
18 | 18 |
19 class EventWithCallback { | 19 class EventWithCallback { |
20 public: | 20 public: |
| 21 struct OriginalEventWithCallback { |
| 22 OriginalEventWithCallback( |
| 23 ScopedWebInputEvent event, |
| 24 const InputHandlerProxy::EventDispositionCallback& callback); |
| 25 ~OriginalEventWithCallback(); |
| 26 ScopedWebInputEvent event_; |
| 27 InputHandlerProxy::EventDispositionCallback callback_; |
| 28 }; |
| 29 using OriginalEventList = std::list<OriginalEventWithCallback>; |
| 30 |
21 EventWithCallback( | 31 EventWithCallback( |
22 ScopedWebInputEvent event, | 32 ScopedWebInputEvent event, |
23 const LatencyInfo& latency, | 33 const LatencyInfo& latency, |
24 base::TimeTicks timestamp_now, | 34 base::TimeTicks timestamp_now, |
25 const InputHandlerProxy::EventDispositionCallback& callback); | 35 const InputHandlerProxy::EventDispositionCallback& callback); |
| 36 EventWithCallback(ScopedWebInputEvent event, |
| 37 const LatencyInfo& latency, |
| 38 base::TimeTicks creation_timestamp, |
| 39 base::TimeTicks last_coalesced_timestamp, |
| 40 std::unique_ptr<OriginalEventList> original_events); |
26 ~EventWithCallback(); | 41 ~EventWithCallback(); |
27 | 42 |
28 bool CanCoalesceWith(const EventWithCallback& other) const WARN_UNUSED_RESULT; | 43 bool CanCoalesceWith(const EventWithCallback& other) const WARN_UNUSED_RESULT; |
29 void CoalesceWith(EventWithCallback* other, base::TimeTicks timestamp_now); | 44 void CoalesceWith(EventWithCallback* other, base::TimeTicks timestamp_now); |
30 | 45 |
31 void RunCallbacks(InputHandlerProxy::EventDisposition, | 46 void RunCallbacks(InputHandlerProxy::EventDisposition, |
32 const LatencyInfo& latency, | 47 const LatencyInfo& latency, |
33 std::unique_ptr<DidOverscrollParams>); | 48 std::unique_ptr<DidOverscrollParams>); |
34 | 49 |
35 const blink::WebInputEvent& event() const { return *event_; } | 50 const blink::WebInputEvent& event() const { return *event_; } |
36 const LatencyInfo latency_info() const { return latency_; } | 51 const LatencyInfo latency_info() const { return latency_; } |
37 base::TimeTicks creation_timestamp() const { return creation_timestamp_; } | 52 base::TimeTicks creation_timestamp() const { return creation_timestamp_; } |
38 base::TimeTicks last_coalesced_timestamp() const { | 53 base::TimeTicks last_coalesced_timestamp() const { |
39 return last_coalesced_timestamp_; | 54 return last_coalesced_timestamp_; |
40 } | 55 } |
41 size_t coalesced_count() const { return original_events_.size(); } | 56 size_t coalesced_count() const { return original_events_.size(); } |
| 57 OriginalEventList& original_events() { return original_events_; } |
42 | 58 |
43 private: | 59 private: |
44 friend class test::InputHandlerProxyEventQueueTest; | 60 friend class test::InputHandlerProxyEventQueueTest; |
45 struct OriginalEventWithCallback { | |
46 OriginalEventWithCallback( | |
47 ScopedWebInputEvent event, | |
48 const InputHandlerProxy::EventDispositionCallback& callback); | |
49 ~OriginalEventWithCallback(); | |
50 ScopedWebInputEvent event_; | |
51 InputHandlerProxy::EventDispositionCallback callback_; | |
52 }; | |
53 | 61 |
54 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); | 62 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); |
55 | 63 |
56 ScopedWebInputEvent event_; | 64 ScopedWebInputEvent event_; |
57 LatencyInfo latency_; | 65 LatencyInfo latency_; |
58 std::list<OriginalEventWithCallback> original_events_; | 66 OriginalEventList original_events_; |
59 | 67 |
60 base::TimeTicks creation_timestamp_; | 68 base::TimeTicks creation_timestamp_; |
61 base::TimeTicks last_coalesced_timestamp_; | 69 base::TimeTicks last_coalesced_timestamp_; |
62 }; | 70 }; |
63 | 71 |
64 } // namespace ui | 72 } // namespace ui |
65 | 73 |
66 #endif // UI_EVENTS_BLINK_EVENT_WITH_CALLBACK_H_ | 74 #endif // UI_EVENTS_BLINK_EVENT_WITH_CALLBACK_H_ |
OLD | NEW |