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

Side by Side Diff: content/renderer/input/main_thread_event_queue.h

Issue 2094323002: Ensure acks are sent for all blocking events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments Created 4 years, 5 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 CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_ 5 #ifndef CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_
6 #define CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_ 6 #define CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include "content/common/content_export.h" 9 #include "content/common/content_export.h"
10 #include "content/common/input/event_with_latency_info.h" 10 #include "content/common/input/event_with_latency_info.h"
11 #include "content/common/input/input_event_ack_state.h" 11 #include "content/common/input/input_event_ack_state.h"
12 #include "content/common/input/input_event_dispatch_type.h" 12 #include "content/common/input/input_event_dispatch_type.h"
13 #include "content/common/input/web_input_event_queue.h" 13 #include "content/common/input/web_input_event_queue.h"
14 #include "third_party/WebKit/public/web/WebInputEvent.h" 14 #include "third_party/WebKit/public/web/WebInputEvent.h"
15 #include "ui/events/latency_info.h" 15 #include "ui/events/latency_info.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 template <typename BaseClass, typename BaseType> 19 template <typename BaseClass, typename BaseType>
20 class EventWithDispatchType : public BaseClass { 20 class EventWithDispatchType : public BaseClass {
21 public: 21 public:
22 EventWithDispatchType(const BaseType& e, 22 EventWithDispatchType(const BaseType& e,
23 const ui::LatencyInfo& l, 23 const ui::LatencyInfo& l,
24 InputEventDispatchType t) 24 InputEventDispatchType t)
25 : BaseClass(e, l), type(t) {} 25 : BaseClass(e, l), type(t) {}
26 26
27 InputEventDispatchType type; 27 InputEventDispatchType type;
28 std::deque<uint32_t> eventsToAck;
28 29
29 bool CanCoalesceWith(const EventWithDispatchType& other) const 30 bool CanCoalesceWith(const EventWithDispatchType& other) const
30 WARN_UNUSED_RESULT { 31 WARN_UNUSED_RESULT {
31 return other.type == type && BaseClass::CanCoalesceWith(other); 32 return other.type == type && BaseClass::CanCoalesceWith(other);
32 } 33 }
33 34
34 void CoalesceWith(const EventWithDispatchType& other) { 35 void CoalesceWith(const EventWithDispatchType& other) {
36 // If we are blocking and are coalescing touch, make sure to keep
37 // the touch ids that need to be acked.
38 if (type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN) {
39 // We should only have blocking touch events that need coalescing.
40 DCHECK(blink::WebInputEvent::isTouchEventType(other.event.type));
41 eventsToAck.push_back(
42 WebInputEventTraits::GetUniqueTouchEventId(other.event));
43 }
35 BaseClass::CoalesceWith(other); 44 BaseClass::CoalesceWith(other);
36 } 45 }
37 }; 46 };
38 47
39 using PendingMouseWheelEvent = 48 using PendingMouseWheelEvent =
40 EventWithDispatchType<MouseWheelEventWithLatencyInfo, 49 EventWithDispatchType<MouseWheelEventWithLatencyInfo,
41 blink::WebMouseWheelEvent>; 50 blink::WebMouseWheelEvent>;
42 51
43 using PendingTouchEvent = 52 using PendingTouchEvent =
44 EventWithDispatchType<TouchEventWithLatencyInfo, blink::WebTouchEvent>; 53 EventWithDispatchType<TouchEventWithLatencyInfo, blink::WebTouchEvent>;
45 54
46 class CONTENT_EXPORT MainThreadEventQueueClient { 55 class CONTENT_EXPORT MainThreadEventQueueClient {
47 public: 56 public:
48 // Send an |event| that was previously queued (possibly 57 // Send an |event| that was previously queued (possibly
49 // coalesced with another event) to the |routing_id|'s 58 // coalesced with another event) to the |routing_id|'s
50 // channel. Implementors must implement this callback. 59 // channel. Implementors must implement this callback.
51 virtual void SendEventToMainThread(int routing_id, 60 virtual void SendEventToMainThread(int routing_id,
52 const blink::WebInputEvent* event, 61 const blink::WebInputEvent* event,
53 const ui::LatencyInfo& latency, 62 const ui::LatencyInfo& latency,
54 InputEventDispatchType dispatch_type) = 0; 63 InputEventDispatchType dispatch_type) = 0;
64
65 virtual void SendInputEventAck(int routing_id,
66 blink::WebInputEvent::Type type,
67 InputEventAckState ack_result,
68 uint32_t touch_event_id) = 0;
55 }; 69 };
56 70
57 // MainThreadEventQueue implements a series of queues (one touch 71 // MainThreadEventQueue implements a series of queues (one touch
58 // and one mouse wheel) for events that need to be queued between 72 // and one mouse wheel) for events that need to be queued between
59 // the compositor and main threads. When an event is sent 73 // the compositor and main threads. When an event is sent
60 // from the compositor to main it can either be sent directly if no 74 // from the compositor to main it can either be sent directly if no
61 // outstanding events of that type are in flight; or it needs to 75 // outstanding events of that type are in flight; or it needs to
62 // wait in a queue until the main thread has finished processing 76 // wait in a queue until the main thread has finished processing
63 // the in-flight event. This class tracks the state and queues 77 // the in-flight event. This class tracks the state and queues
64 // for the event types. Methods on this class should only be called 78 // for the event types. Methods on this class should only be called
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 111
98 // Called once the compositor has handled |event| and indicated that it is 112 // Called once the compositor has handled |event| and indicated that it is
99 // a non-blocking event to be queued to the main thread. 113 // a non-blocking event to be queued to the main thread.
100 bool HandleEvent(const blink::WebInputEvent* event, 114 bool HandleEvent(const blink::WebInputEvent* event,
101 const ui::LatencyInfo& latency, 115 const ui::LatencyInfo& latency,
102 InputEventDispatchType dispatch_type, 116 InputEventDispatchType dispatch_type,
103 InputEventAckState ack_result); 117 InputEventAckState ack_result);
104 118
105 // Call once the main thread has handled an outstanding |type| event 119 // Call once the main thread has handled an outstanding |type| event
106 // in flight. 120 // in flight.
107 void EventHandled(blink::WebInputEvent::Type type); 121 void EventHandled(blink::WebInputEvent::Type type,
122 InputEventAckState ack_result);
108 123
109 void set_is_flinging(bool is_flinging) { is_flinging_ = is_flinging; } 124 void set_is_flinging(bool is_flinging) { is_flinging_ = is_flinging; }
110 125
111 private: 126 private:
112 friend class MainThreadEventQueueTest; 127 friend class MainThreadEventQueueTest;
113 int routing_id_; 128 int routing_id_;
114 MainThreadEventQueueClient* client_; 129 MainThreadEventQueueClient* client_;
115 WebInputEventQueue<PendingMouseWheelEvent> wheel_events_; 130 WebInputEventQueue<PendingMouseWheelEvent> wheel_events_;
116 WebInputEventQueue<PendingTouchEvent> touch_events_; 131 WebInputEventQueue<PendingTouchEvent> touch_events_;
117 bool is_flinging_; 132 bool is_flinging_;
118 133
134 // TODO(dtapuska): These can be removed when the queues are dequeued
135 // on the main thread. See crbug.com/624021
136 std::unique_ptr<PendingMouseWheelEvent> in_flight_wheel_event_;
137 std::unique_ptr<PendingTouchEvent> in_flight_touch_event_;
138
119 DISALLOW_COPY_AND_ASSIGN(MainThreadEventQueue); 139 DISALLOW_COPY_AND_ASSIGN(MainThreadEventQueue);
120 }; 140 };
121 141
122 } // namespace content 142 } // namespace content
123 143
124 #endif // CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_ 144 #endif // CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_
OLDNEW
« no previous file with comments | « content/renderer/input/input_handler_manager_client.h ('k') | content/renderer/input/main_thread_event_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698