| Index: content/renderer/input/non_blocking_event_queue.cc
|
| diff --git a/content/renderer/input/non_blocking_event_queue.cc b/content/renderer/input/non_blocking_event_queue.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4fc5d11b6119dbb649877443a52c14f442711bb0
|
| --- /dev/null
|
| +++ b/content/renderer/input/non_blocking_event_queue.cc
|
| @@ -0,0 +1,60 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/renderer/input/non_blocking_event_queue.h"
|
| +
|
| +namespace content {
|
| +
|
| +NonBlockingEventQueue::NonBlockingEventQueue(
|
| + int routing_id,
|
| + NonBlockingEventQueueClient* client)
|
| + : routing_id_(routing_id), client_(client) {}
|
| +
|
| +NonBlockingEventQueue::~NonBlockingEventQueue() {}
|
| +
|
| +void NonBlockingEventQueue::HandleEvent(const blink::WebInputEvent* event,
|
| + const ui::LatencyInfo& latency) {
|
| + if (event->type == blink::WebInputEvent::MouseWheel) {
|
| + if (wheel_events_.state() == WebInputEventQueueState::ITEM_PENDING) {
|
| + wheel_events_.Queue(MouseWheelEventWithLatencyInfo(
|
| + *static_cast<const blink::WebMouseWheelEvent*>(event), latency));
|
| + } else {
|
| + wheel_events_.set_state(WebInputEventQueueState::ITEM_PENDING);
|
| + client_->SendNonBlockingEvent(routing_id_, event, latency);
|
| + }
|
| + } else if (blink::WebInputEvent::isTouchEventType(event->type)) {
|
| + if (touch_events_.state() == WebInputEventQueueState::ITEM_PENDING) {
|
| + touch_events_.Queue(TouchEventWithLatencyInfo(
|
| + *static_cast<const blink::WebTouchEvent*>(event), latency));
|
| + } else {
|
| + touch_events_.set_state(WebInputEventQueueState::ITEM_PENDING);
|
| + client_->SendNonBlockingEvent(routing_id_, event, latency);
|
| + }
|
| + } else {
|
| + NOTREACHED() << "Invalid passive event type";
|
| + }
|
| +}
|
| +
|
| +void NonBlockingEventQueue::EventHandled(blink::WebInputEvent::Type type) {
|
| + if (type == blink::WebInputEvent::MouseWheel) {
|
| + if (!wheel_events_.empty()) {
|
| + scoped_ptr<MouseWheelEventWithLatencyInfo> event = wheel_events_.Pop();
|
| +
|
| + client_->SendNonBlockingEvent(routing_id_, &event->event, event->latency);
|
| + } else {
|
| + wheel_events_.set_state(WebInputEventQueueState::ITEM_NOT_PENDING);
|
| + }
|
| + } else if (blink::WebInputEvent::isTouchEventType(type)) {
|
| + if (!touch_events_.empty()) {
|
| + scoped_ptr<TouchEventWithLatencyInfo> event = touch_events_.Pop();
|
| + client_->SendNonBlockingEvent(routing_id_, &event->event, event->latency);
|
| + } else {
|
| + touch_events_.set_state(WebInputEventQueueState::ITEM_NOT_PENDING);
|
| + }
|
| + } else {
|
| + NOTREACHED() << "Invalid passive event type";
|
| + }
|
| +}
|
| +
|
| +} // namespace content
|
|
|