| OLD | NEW |
| 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 #include "content/common/input/event_with_latency_info.h" | 7 #include "content/common/input/event_with_latency_info.h" |
| 7 #include "content/common/input_messages.h" | 8 #include "content/common/input_messages.h" |
| 9 #include "content/renderer/render_thread_impl.h" |
| 8 | 10 |
| 9 namespace content { | 11 namespace content { |
| 10 | 12 |
| 11 EventWithDispatchType::EventWithDispatchType( | 13 EventWithDispatchType::EventWithDispatchType( |
| 12 ui::ScopedWebInputEvent event, | 14 ui::ScopedWebInputEvent event, |
| 13 const ui::LatencyInfo& latency, | 15 const ui::LatencyInfo& latency, |
| 14 InputEventDispatchType dispatch_type) | 16 InputEventDispatchType dispatch_type) |
| 15 : ScopedWebInputEventWithLatencyInfo(std::move(event), latency), | 17 : ScopedWebInputEventWithLatencyInfo(std::move(event), latency), |
| 16 dispatch_type_(dispatch_type) {} | 18 dispatch_type_(dispatch_type) {} |
| 17 | 19 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 in_flight_event_->latencyInfo(), | 111 in_flight_event_->latencyInfo(), |
| 110 dispatch_type); | 112 dispatch_type); |
| 111 } | 113 } |
| 112 | 114 |
| 113 in_flight_event_.reset(); | 115 in_flight_event_.reset(); |
| 114 } | 116 } |
| 115 | 117 |
| 116 void MainThreadEventQueue::EventHandled(blink::WebInputEvent::Type type, | 118 void MainThreadEventQueue::EventHandled(blink::WebInputEvent::Type type, |
| 117 InputEventAckState ack_result) { | 119 InputEventAckState ack_result) { |
| 118 if (in_flight_event_) { | 120 if (in_flight_event_) { |
| 121 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); |
| 119 // Send acks for blocking touch events. | 122 // Send acks for blocking touch events. |
| 120 for (const auto id : in_flight_event_->eventsToAck()) | 123 for (const auto id : in_flight_event_->eventsToAck()) { |
| 121 client_->SendInputEventAck(routing_id_, type, ack_result, id); | 124 client_->SendInputEventAck(routing_id_, type, ack_result, id); |
| 125 if (render_thread_impl) { |
| 126 render_thread_impl->GetRendererScheduler() |
| 127 ->DidHandleInputEventOnMainThread(in_flight_event_->event()); |
| 128 } |
| 129 } |
| 122 } | 130 } |
| 123 } | 131 } |
| 124 | 132 |
| 125 void MainThreadEventQueue::SendEventNotificationToMainThread() { | 133 void MainThreadEventQueue::SendEventNotificationToMainThread() { |
| 126 main_task_runner_->PostTask( | 134 main_task_runner_->PostTask( |
| 127 FROM_HERE, base::Bind(&MainThreadEventQueue::PopEventOnMainThread, | 135 FROM_HERE, base::Bind(&MainThreadEventQueue::PopEventOnMainThread, |
| 128 this)); | 136 this)); |
| 129 } | 137 } |
| 130 | 138 |
| 131 void MainThreadEventQueue::QueueEvent( | 139 void MainThreadEventQueue::QueueEvent( |
| 132 std::unique_ptr<EventWithDispatchType> event) { | 140 std::unique_ptr<EventWithDispatchType> event) { |
| 133 bool send_notification = false; | 141 bool send_notification = false; |
| 134 { | 142 { |
| 135 base::AutoLock lock(event_queue_lock_); | 143 base::AutoLock lock(event_queue_lock_); |
| 136 size_t size_before = events_.size(); | 144 size_t size_before = events_.size(); |
| 137 events_.Queue(std::move(event)); | 145 events_.Queue(std::move(event)); |
| 138 send_notification = events_.size() != size_before; | 146 send_notification = events_.size() != size_before; |
| 139 } | 147 } |
| 140 if (send_notification) | 148 if (send_notification) |
| 141 SendEventNotificationToMainThread(); | 149 SendEventNotificationToMainThread(); |
| 142 } | 150 } |
| 143 | 151 |
| 144 } // namespace content | 152 } // namespace content |
| OLD | NEW |