Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_EVENTS_BLINK_EVENT_WITH_CALLBACK_H_ | |
| 6 #define UI_EVENTS_BLINK_EVENT_WITH_CALLBACK_H_ | |
| 7 | |
| 8 #include <list> | |
| 9 | |
| 10 #include "ui/events/blink/input_handler_proxy.h" | |
| 11 #include "ui/events/latency_info.h" | |
| 12 | |
| 13 namespace ui { | |
| 14 | |
| 15 namespace test { | |
| 16 class InputHandlerProxyEventQueueTest; | |
| 17 } | |
| 18 | |
| 19 class EventWithCallback { | |
| 20 public: | |
| 21 EventWithCallback( | |
| 22 ScopedWebInputEvent event, | |
| 23 const LatencyInfo& latency, | |
| 24 const InputHandlerProxy::EventDispositionCallback& callback); | |
| 25 ~EventWithCallback(); | |
| 26 | |
| 27 bool CanCoalesceWith(const EventWithCallback& other) const WARN_UNUSED_RESULT; | |
| 28 void CoalesceWith(EventWithCallback* other); | |
| 29 | |
| 30 const blink::WebInputEvent& event() const { return *event_; } | |
| 31 const LatencyInfo latencyInfo() const { return latency_; } | |
| 32 base::TimeTicks creationTimestamp() const { return creation_timestamp_; } | |
| 33 base::TimeTicks lastCoalescedTimestamp() const { | |
| 34 return last_coalesced_timestamp_; | |
| 35 } | |
| 36 size_t coalescedCount() const { return original_events_.size(); } | |
| 37 | |
| 38 void RunCallbacks(InputHandlerProxy::EventDisposition, | |
| 39 const LatencyInfo& latency, | |
| 40 std::unique_ptr<DidOverscrollParams>); | |
| 41 | |
| 42 private: | |
| 43 friend class test::InputHandlerProxyEventQueueTest; | |
| 44 struct OriginalEventWithCallback { | |
| 45 OriginalEventWithCallback( | |
| 46 ScopedWebInputEvent event, | |
| 47 const InputHandlerProxy::EventDispositionCallback& callback); | |
| 48 ~OriginalEventWithCallback(); | |
| 49 ScopedWebInputEvent event_; | |
| 50 InputHandlerProxy::EventDispositionCallback callback_; | |
| 51 }; | |
| 52 | |
| 53 ScopedWebInputEvent event_; | |
| 54 LatencyInfo latency_; | |
| 55 std::list<OriginalEventWithCallback> original_events_; | |
| 56 | |
| 57 base::TimeTicks creation_timestamp_; | |
| 58 base::TimeTicks last_coalesced_timestamp_; | |
| 59 | |
| 60 // Testing only | |
| 61 static std::unique_ptr<base::TimeTicks> testing_timestamp_now_; | |
|
dtapuska
2016/11/09 21:28:05
This is kind of clunky. I'd prefer and examples I
chongz
2016/11/11 21:52:04
Done.
| |
| 62 }; | |
| 63 | |
| 64 } // namespace ui | |
| 65 | |
| 66 #endif // UI_EVENTS_BLINK_EVENT_WITH_CALLBACK_H_ | |
| OLD | NEW |