OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/renderer/input/non_blocking_event_queue.h" | |
6 | |
7 namespace content { | |
8 | |
9 NonBlockingEventQueue::NonBlockingEventQueue( | |
10 int routing_id, | |
11 NonBlockingEventQueueClient* client) | |
12 : routing_id_(routing_id), client_(client) {} | |
13 | |
14 NonBlockingEventQueue::~NonBlockingEventQueue() {} | |
15 | |
16 void NonBlockingEventQueue::HandleEvent(const blink::WebInputEvent* event, | |
17 const ui::LatencyInfo& latency) { | |
18 if (event->type == blink::WebInputEvent::MouseWheel) { | |
19 if (wheel_events_.state() == WebInputEventQueueState::ITEM_PENDING) { | |
20 wheel_events_.Queue(MouseWheelEventWithLatencyInfo( | |
21 *static_cast<const blink::WebMouseWheelEvent*>(event), latency)); | |
22 } else { | |
23 wheel_events_.set_state(WebInputEventQueueState::ITEM_PENDING); | |
24 client_->SendNonBlockingEvent(routing_id_, event, latency); | |
25 } | |
26 } else if (blink::WebInputEvent::isTouchEventType(event->type)) { | |
27 if (touch_events_.state() == WebInputEventQueueState::ITEM_PENDING) { | |
28 touch_events_.Queue(TouchEventWithLatencyInfo( | |
29 *static_cast<const blink::WebTouchEvent*>(event), latency)); | |
30 } else { | |
31 touch_events_.set_state(WebInputEventQueueState::ITEM_PENDING); | |
32 client_->SendNonBlockingEvent(routing_id_, event, latency); | |
33 } | |
34 } else { | |
35 NOTREACHED() << "Invalid passive event type"; | |
36 } | |
37 } | |
38 | |
39 void NonBlockingEventQueue::EventHandled(blink::WebInputEvent::Type type) { | |
40 if (type == blink::WebInputEvent::MouseWheel) { | |
41 if (!wheel_events_.empty()) { | |
42 scoped_ptr<MouseWheelEventWithLatencyInfo> event = wheel_events_.Pop(); | |
43 | |
44 client_->SendNonBlockingEvent(routing_id_, &event->event, event->latency); | |
45 } else { | |
46 wheel_events_.set_state(WebInputEventQueueState::ITEM_NOT_PENDING); | |
47 } | |
48 } else if (blink::WebInputEvent::isTouchEventType(type)) { | |
49 if (!touch_events_.empty()) { | |
50 scoped_ptr<TouchEventWithLatencyInfo> event = touch_events_.Pop(); | |
51 client_->SendNonBlockingEvent(routing_id_, &event->event, event->latency); | |
52 } else { | |
53 touch_events_.set_state(WebInputEventQueueState::ITEM_NOT_PENDING); | |
54 } | |
55 } else { | |
56 NOTREACHED() << "Invalid passive event type"; | |
57 } | |
58 } | |
59 | |
60 } // namespace content | |
OLD | NEW |