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

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

Issue 2557153002: Fix issues related to a continuous event getting coalesced with a discrete event. (Closed)
Patch Set: Fix nits Created 4 years 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 "base/feature_list.h" 9 #include "base/feature_list.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 #include "content/common/input/event_with_latency_info.h" 11 #include "content/common/input/event_with_latency_info.h"
12 #include "content/common/input/input_event_ack_state.h" 12 #include "content/common/input/input_event_ack_state.h"
13 #include "content/common/input/input_event_dispatch_type.h" 13 #include "content/common/input/input_event_dispatch_type.h"
14 #include "content/common/input/web_input_event_queue.h" 14 #include "content/common/input/web_input_event_queue.h"
15 #include "content/public/common/content_features.h" 15 #include "content/public/common/content_features.h"
16 #include "third_party/WebKit/public/platform/WebInputEvent.h" 16 #include "third_party/WebKit/public/platform/WebInputEvent.h"
17 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul er.h" 17 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul er.h"
18 #include "ui/events/blink/web_input_event_traits.h" 18 #include "ui/events/blink/web_input_event_traits.h"
19 #include "ui/events/latency_info.h" 19 #include "ui/events/latency_info.h"
20 20
21 namespace content { 21 namespace content {
22 22
23 class EventWithDispatchType : public ScopedWebInputEventWithLatencyInfo { 23 class EventWithDispatchType : public ScopedWebInputEventWithLatencyInfo {
24 public: 24 public:
25 EventWithDispatchType(ui::ScopedWebInputEvent event, 25 EventWithDispatchType(ui::ScopedWebInputEvent event,
26 const ui::LatencyInfo& latency, 26 const ui::LatencyInfo& latency,
27 InputEventDispatchType dispatch_type); 27 InputEventDispatchType dispatch_type);
28 ~EventWithDispatchType(); 28 ~EventWithDispatchType();
29 bool CanCoalesceWith(const EventWithDispatchType& other) const
30 WARN_UNUSED_RESULT;
31 void CoalesceWith(const EventWithDispatchType& other); 29 void CoalesceWith(const EventWithDispatchType& other);
32 30
33 const std::deque<uint32_t>& coalescedEventIds() const { 31 const std::deque<uint32_t>& blockingCoalescedEventIds() const {
34 return coalesced_event_ids_; 32 return blocking_coalesced_event_ids_;
35 } 33 }
36 InputEventDispatchType dispatchType() const { return dispatch_type_; } 34 InputEventDispatchType dispatchType() const { return dispatch_type_; }
37 base::TimeTicks creationTimestamp() const { return creation_timestamp_; } 35 base::TimeTicks creationTimestamp() const { return creation_timestamp_; }
38 base::TimeTicks lastCoalescedTimestamp() const { 36 base::TimeTicks lastCoalescedTimestamp() const {
39 return last_coalesced_timestamp_; 37 return last_coalesced_timestamp_;
40 } 38 }
41 39
40 size_t coalescedCount() const {
41 return non_blocking_coalesced_count_ + blocking_coalesced_event_ids_.size();
42 }
43
42 private: 44 private:
43 InputEventDispatchType dispatch_type_; 45 InputEventDispatchType dispatch_type_;
44 46
45 // |coalesced_event_ids_| contains the unique touch event ids to be acked. If 47 // Contains the unique touch event ids to be acked. If
46 // the events are not TouchEvents the values will be 0. More importantly for 48 // the events are not TouchEvents the values will be 0. More importantly for
47 // those cases the deque ends up containing how many additional ACKs 49 // those cases the deque ends up containing how many additional ACKs
48 // need to be sent. 50 // need to be sent.
49 std::deque<uint32_t> coalesced_event_ids_; 51 std::deque<uint32_t> blocking_coalesced_event_ids_;
52 // Contains the number of non-blocking events coalesced.
53 size_t non_blocking_coalesced_count_;
50 base::TimeTicks creation_timestamp_; 54 base::TimeTicks creation_timestamp_;
51 base::TimeTicks last_coalesced_timestamp_; 55 base::TimeTicks last_coalesced_timestamp_;
52 }; 56 };
53 57
54 class CONTENT_EXPORT MainThreadEventQueueClient { 58 class CONTENT_EXPORT MainThreadEventQueueClient {
55 public: 59 public:
56 // Handle an |event| that was previously queued (possibly 60 // Handle an |event| that was previously queued (possibly
57 // coalesced with another event) to the |routing_id|'s 61 // coalesced with another event) to the |routing_id|'s
58 // channel. Implementors must implement this callback. 62 // channel. Implementors must implement this callback.
59 virtual void HandleEventOnMainThread( 63 virtual void HandleEventOnMainThread(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void SendEventNotificationToMainThread(); 138 void SendEventNotificationToMainThread();
135 void DispatchSingleEvent(); 139 void DispatchSingleEvent();
136 void DispatchInFlightEvent(); 140 void DispatchInFlightEvent();
137 void PossiblyScheduleMainFrame(); 141 void PossiblyScheduleMainFrame();
138 142
139 void SendEventToMainThread(const blink::WebInputEvent* event, 143 void SendEventToMainThread(const blink::WebInputEvent* event,
140 const ui::LatencyInfo& latency, 144 const ui::LatencyInfo& latency,
141 InputEventDispatchType original_dispatch_type); 145 InputEventDispatchType original_dispatch_type);
142 146
143 bool IsRafAlignedInputDisabled(); 147 bool IsRafAlignedInputDisabled();
144 bool IsRafAlignedEvent(const std::unique_ptr<EventWithDispatchType>& event); 148 bool IsRafAlignedEvent(const blink::WebInputEvent& event);
145 149
146 friend class MainThreadEventQueueTest; 150 friend class MainThreadEventQueueTest;
147 int routing_id_; 151 int routing_id_;
148 MainThreadEventQueueClient* client_; 152 MainThreadEventQueueClient* client_;
149 std::unique_ptr<EventWithDispatchType> in_flight_event_; 153 std::unique_ptr<EventWithDispatchType> in_flight_event_;
150 bool last_touch_start_forced_nonblocking_due_to_fling_; 154 bool last_touch_start_forced_nonblocking_due_to_fling_;
151 bool enable_fling_passive_listener_flag_; 155 bool enable_fling_passive_listener_flag_;
152 bool handle_raf_aligned_touch_input_; 156 bool handle_raf_aligned_touch_input_;
153 bool handle_raf_aligned_mouse_input_; 157 bool handle_raf_aligned_mouse_input_;
154 158
(...skipping 12 matching lines...) Expand all
167 171
168 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 172 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
169 blink::scheduler::RendererScheduler* renderer_scheduler_; 173 blink::scheduler::RendererScheduler* renderer_scheduler_;
170 174
171 DISALLOW_COPY_AND_ASSIGN(MainThreadEventQueue); 175 DISALLOW_COPY_AND_ASSIGN(MainThreadEventQueue);
172 }; 176 };
173 177
174 } // namespace content 178 } // namespace content
175 179
176 #endif // CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_ 180 #endif // CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_
OLDNEW
« no previous file with comments | « content/common/input/input_event_dispatch_type.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