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 #ifndef CONTENT_RENDERER_INPUT_NON_BLOCKING_EVENT_QUEUE_H_ | |
6 #define CONTENT_RENDERER_INPUT_NON_BLOCKING_EVENT_QUEUE_H_ | |
7 | |
8 #include <deque> | |
9 #include "content/common/content_export.h" | |
10 #include "content/common/input/event_with_latency_info.h" | |
11 #include "content/common/input/web_input_event_queue.h" | |
12 #include "third_party/WebKit/public/web/WebInputEvent.h" | |
13 #include "ui/events/latency_info.h" | |
14 | |
15 namespace content { | |
16 | |
17 class CONTENT_EXPORT NonBlockingEventQueueClient { | |
18 public: | |
19 // Send an |event| that was previously queued (possibly | |
20 // coalesced with another event) to the |routing_id|'s | |
21 // channel. Implementors must implement this callback. | |
22 virtual void SendNonBlockingEvent(int routing_id, | |
23 const blink::WebInputEvent* event, | |
24 const ui::LatencyInfo& latency) = 0; | |
25 }; | |
26 | |
27 // NonBlockingEventQueue implements a series of queues (one touch | |
28 // and one mouse wheel) for events that need to be queued between | |
29 // the compositor and main threads. When a non-blocking event is sent | |
30 // from the compositor to main it can either be sent directly if no | |
31 // outstanding events of that type are in flight; or it needs to | |
32 // wait in a queue until the main thread has finished processing | |
33 // the in-flight event. This class tracks the state and queues | |
34 // for the event types. Methods on this class should only be called | |
35 // from the compositor thread. | |
36 // | |
37 class CONTENT_EXPORT NonBlockingEventQueue { | |
38 public: | |
39 NonBlockingEventQueue(int routing_id, NonBlockingEventQueueClient* client); | |
40 ~NonBlockingEventQueue(); | |
41 | |
42 // Called once compositor has handled |event| and indicated that it is | |
43 // a non-blocking event to be queued to the main thread. | |
44 void HandleEvent(const blink::WebInputEvent* event, | |
45 const ui::LatencyInfo& latency); | |
46 | |
47 // Call once main thread has handled outstanding |type| event in flight. | |
48 void EventHandled(blink::WebInputEvent::Type type); | |
49 | |
50 private: | |
51 friend class NonBlockingEventQueueTest; | |
52 int routing_id_; | |
53 NonBlockingEventQueueClient* client_; | |
54 WebInputEventQueue<MouseWheelEventWithLatencyInfo> wheel_events_; | |
55 WebInputEventQueue<TouchEventWithLatencyInfo> touch_events_; | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(NonBlockingEventQueue); | |
58 }; | |
59 | |
60 } // namespace content | |
61 | |
62 #endif // CONTENT_RENDERER_INPUT_NON_BLOCKING_EVENT_QUEUE_H_ | |
OLD | NEW |