Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: ui/events/blink/event_with_callback.h

Issue 2576013002: Introducing WebCoalescedInputEvent and inclusion in content/common (Closed)
Patch Set: Fix a few DCHECK hits Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 { 21 struct OriginalEventWithCallback {
22 OriginalEventWithCallback( 22 OriginalEventWithCallback(
23 ScopedWebInputEvent event, 23 blink::WebScopedInputEvent event,
24 const InputHandlerProxy::EventDispositionCallback& callback); 24 const InputHandlerProxy::EventDispositionCallback& callback);
25 ~OriginalEventWithCallback(); 25 ~OriginalEventWithCallback();
26 ScopedWebInputEvent event_; 26 blink::WebScopedInputEvent event_;
27 InputHandlerProxy::EventDispositionCallback callback_; 27 InputHandlerProxy::EventDispositionCallback callback_;
28 }; 28 };
29 using OriginalEventList = std::list<OriginalEventWithCallback>; 29 using OriginalEventList = std::list<OriginalEventWithCallback>;
30 30
31 EventWithCallback( 31 EventWithCallback(
32 ScopedWebInputEvent event, 32 blink::WebScopedInputEvent event,
33 const LatencyInfo& latency, 33 const LatencyInfo& latency,
34 base::TimeTicks timestamp_now, 34 base::TimeTicks timestamp_now,
35 const InputHandlerProxy::EventDispositionCallback& callback); 35 const InputHandlerProxy::EventDispositionCallback& callback);
36 EventWithCallback(ScopedWebInputEvent event, 36 EventWithCallback(blink::WebScopedInputEvent event,
37 const LatencyInfo& latency, 37 const LatencyInfo& latency,
38 base::TimeTicks creation_timestamp, 38 base::TimeTicks creation_timestamp,
39 base::TimeTicks last_coalesced_timestamp, 39 base::TimeTicks last_coalesced_timestamp,
40 std::unique_ptr<OriginalEventList> original_events); 40 std::unique_ptr<OriginalEventList> original_events);
41 ~EventWithCallback(); 41 ~EventWithCallback();
42 42
43 bool CanCoalesceWith(const EventWithCallback& other) const WARN_UNUSED_RESULT; 43 bool CanCoalesceWith(const EventWithCallback& other) const WARN_UNUSED_RESULT;
44 void CoalesceWith(EventWithCallback* other, base::TimeTicks timestamp_now); 44 void CoalesceWith(EventWithCallback* other, base::TimeTicks timestamp_now);
45 45
46 void RunCallbacks(InputHandlerProxy::EventDisposition, 46 void RunCallbacks(InputHandlerProxy::EventDisposition,
47 const LatencyInfo& latency, 47 const LatencyInfo& latency,
48 std::unique_ptr<DidOverscrollParams>); 48 std::unique_ptr<DidOverscrollParams>);
49 49
50 const blink::WebInputEvent& event() const { return *event_; } 50 const blink::WebInputEvent& event() const { return *event_; }
51 const LatencyInfo latency_info() const { return latency_; } 51 const LatencyInfo latency_info() const { return latency_; }
52 base::TimeTicks creation_timestamp() const { return creation_timestamp_; } 52 base::TimeTicks creation_timestamp() const { return creation_timestamp_; }
53 base::TimeTicks last_coalesced_timestamp() const { 53 base::TimeTicks last_coalesced_timestamp() const {
54 return last_coalesced_timestamp_; 54 return last_coalesced_timestamp_;
55 } 55 }
56 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_; } 57 OriginalEventList& original_events() { return original_events_; }
58 58
59 private: 59 private:
60 friend class test::InputHandlerProxyEventQueueTest; 60 friend class test::InputHandlerProxyEventQueueTest;
61 61
62 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); 62 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock);
63 63
64 ScopedWebInputEvent event_; 64 blink::WebScopedInputEvent event_;
65 LatencyInfo latency_; 65 LatencyInfo latency_;
66 OriginalEventList original_events_; 66 OriginalEventList original_events_;
67 67
68 base::TimeTicks creation_timestamp_; 68 base::TimeTicks creation_timestamp_;
69 base::TimeTicks last_coalesced_timestamp_; 69 base::TimeTicks last_coalesced_timestamp_;
70 }; 70 };
71 71
72 } // namespace ui 72 } // namespace ui
73 73
74 #endif // UI_EVENTS_BLINK_EVENT_WITH_CALLBACK_H_ 74 #endif // UI_EVENTS_BLINK_EVENT_WITH_CALLBACK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698