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

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

Issue 2259823007: Add a unit test expection for calling the render scheduler on coalesced events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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 #include "content/renderer/input/main_thread_event_queue.h" 5 #include "content/renderer/input/main_thread_event_queue.h"
6 6
7 #include "content/common/input/event_with_latency_info.h" 7 #include "content/common/input/event_with_latency_info.h"
8 #include "content/common/input_messages.h" 8 #include "content/common/input_messages.h"
9 #include "content/renderer/render_thread_impl.h"
10 9
11 namespace content { 10 namespace content {
12 11
13 EventWithDispatchType::EventWithDispatchType( 12 EventWithDispatchType::EventWithDispatchType(
14 ui::ScopedWebInputEvent event, 13 ui::ScopedWebInputEvent event,
15 const ui::LatencyInfo& latency, 14 const ui::LatencyInfo& latency,
16 InputEventDispatchType dispatch_type) 15 InputEventDispatchType dispatch_type)
17 : ScopedWebInputEventWithLatencyInfo(std::move(event), latency), 16 : ScopedWebInputEventWithLatencyInfo(std::move(event), latency),
18 dispatch_type_(dispatch_type) {} 17 dispatch_type_(dispatch_type) {}
19 18
(...skipping 12 matching lines...) Expand all
32 // We should only have blocking touch events that need coalescing. 31 // We should only have blocking touch events that need coalescing.
33 eventsToAck_.push_back( 32 eventsToAck_.push_back(
34 ui::WebInputEventTraits::GetUniqueTouchEventId(other.event())); 33 ui::WebInputEventTraits::GetUniqueTouchEventId(other.event()));
35 } 34 }
36 ScopedWebInputEventWithLatencyInfo::CoalesceWith(other); 35 ScopedWebInputEventWithLatencyInfo::CoalesceWith(other);
37 } 36 }
38 37
39 MainThreadEventQueue::MainThreadEventQueue( 38 MainThreadEventQueue::MainThreadEventQueue(
40 int routing_id, 39 int routing_id,
41 MainThreadEventQueueClient* client, 40 MainThreadEventQueueClient* client,
42 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner) 41 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
42 blink::scheduler::RendererScheduler* renderer_scheduler)
43 : routing_id_(routing_id), 43 : routing_id_(routing_id),
44 client_(client), 44 client_(client),
45 is_flinging_(false), 45 is_flinging_(false),
46 last_touch_start_forced_nonblocking_due_to_fling_(false), 46 last_touch_start_forced_nonblocking_due_to_fling_(false),
47 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( 47 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled(
48 features::kPassiveEventListenersDueToFling)), 48 features::kPassiveEventListenersDueToFling)),
49 main_task_runner_(main_task_runner) {} 49 main_task_runner_(main_task_runner),
50 renderer_scheduler_(renderer_scheduler) {}
50 51
51 MainThreadEventQueue::~MainThreadEventQueue() {} 52 MainThreadEventQueue::~MainThreadEventQueue() {}
52 53
53 bool MainThreadEventQueue::HandleEvent( 54 bool MainThreadEventQueue::HandleEvent(
54 ui::ScopedWebInputEvent event, 55 ui::ScopedWebInputEvent event,
55 const ui::LatencyInfo& latency, 56 const ui::LatencyInfo& latency,
56 InputEventDispatchType original_dispatch_type, 57 InputEventDispatchType original_dispatch_type,
57 InputEventAckState ack_result) { 58 InputEventAckState ack_result) {
58 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || 59 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING ||
59 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); 60 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 in_flight_event_->latencyInfo(), 128 in_flight_event_->latencyInfo(),
128 dispatch_type); 129 dispatch_type);
129 } 130 }
130 131
131 in_flight_event_.reset(); 132 in_flight_event_.reset();
132 } 133 }
133 134
134 void MainThreadEventQueue::EventHandled(blink::WebInputEvent::Type type, 135 void MainThreadEventQueue::EventHandled(blink::WebInputEvent::Type type,
135 InputEventAckState ack_result) { 136 InputEventAckState ack_result) {
136 if (in_flight_event_) { 137 if (in_flight_event_) {
137 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current();
138 // Send acks for blocking touch events. 138 // Send acks for blocking touch events.
139 for (const auto id : in_flight_event_->eventsToAck()) { 139 for (const auto id : in_flight_event_->eventsToAck()) {
140 client_->SendInputEventAck(routing_id_, type, ack_result, id); 140 client_->SendInputEventAck(routing_id_, type, ack_result, id);
141 if (render_thread_impl) { 141 if (renderer_scheduler_) {
142 render_thread_impl->GetRendererScheduler() 142 renderer_scheduler_->DidHandleInputEventOnMainThread(
143 ->DidHandleInputEventOnMainThread(in_flight_event_->event()); 143 in_flight_event_->event());
144 } 144 }
145 } 145 }
146 } 146 }
147 } 147 }
148 148
149 void MainThreadEventQueue::SendEventNotificationToMainThread() { 149 void MainThreadEventQueue::SendEventNotificationToMainThread() {
150 main_task_runner_->PostTask( 150 main_task_runner_->PostTask(
151 FROM_HERE, base::Bind(&MainThreadEventQueue::PopEventOnMainThread, 151 FROM_HERE, base::Bind(&MainThreadEventQueue::PopEventOnMainThread,
152 this)); 152 this));
153 } 153 }
154 154
155 void MainThreadEventQueue::QueueEvent( 155 void MainThreadEventQueue::QueueEvent(
156 std::unique_ptr<EventWithDispatchType> event) { 156 std::unique_ptr<EventWithDispatchType> event) {
157 bool send_notification = false; 157 bool send_notification = false;
158 { 158 {
159 base::AutoLock lock(event_queue_lock_); 159 base::AutoLock lock(event_queue_lock_);
160 size_t size_before = events_.size(); 160 size_t size_before = events_.size();
161 events_.Queue(std::move(event)); 161 events_.Queue(std::move(event));
162 send_notification = events_.size() != size_before; 162 send_notification = events_.size() != size_before;
163 } 163 }
164 if (send_notification) 164 if (send_notification)
165 SendEventNotificationToMainThread(); 165 SendEventNotificationToMainThread();
166 } 166 }
167 167
168 } // namespace content 168 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/main_thread_event_queue.h ('k') | content/renderer/input/main_thread_event_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698