Index: content/renderer/input/main_thread_event_queue.h |
diff --git a/content/renderer/input/main_thread_event_queue.h b/content/renderer/input/main_thread_event_queue.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..99b76a08e6b2d648b77bc6f3fb79360ffe4eed90 |
--- /dev/null |
+++ b/content/renderer/input/main_thread_event_queue.h |
@@ -0,0 +1,93 @@ |
+// 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. |
+ |
+#ifndef CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_ |
+#define CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_ |
+ |
+#include <deque> |
+#include "content/common/content_export.h" |
+#include "content/common/input/event_with_latency_info.h" |
+#include "content/common/input/input_event_ack_state.h" |
+#include "content/common/input/input_event_dispatch_type.h" |
+#include "content/common/input/web_input_event_queue.h" |
+#include "third_party/WebKit/public/web/WebInputEvent.h" |
+#include "ui/events/latency_info.h" |
+ |
+namespace content { |
+ |
+template <typename C, typename T> |
+class EventWithDispatchTypeAndLatencyInfo : public C { |
+ public: |
+ EventWithDispatchTypeAndLatencyInfo(const T& e, |
tdresser
2016/03/10 20:12:05
This is a bit over-abbreviated for Chromium style.
dtapuska
2016/03/14 17:33:27
Done.
|
+ const ui::LatencyInfo& l, |
+ InputEventDispatchType t) |
+ : C(e, l), type(t) {} |
+ |
+ InputEventDispatchType type; |
+ |
+ bool CanCoalesceWith(const EventWithDispatchTypeAndLatencyInfo& other) const |
+ WARN_UNUSED_RESULT { |
+ return other.type == type && C::CanCoalesceWith(other); |
+ } |
+ |
+ void CoalesceWith(const EventWithDispatchTypeAndLatencyInfo& other) { |
+ C::CoalesceWith(other); |
+ } |
+}; |
+ |
+using PendingMouseWheelEvent = |
+ EventWithDispatchTypeAndLatencyInfo<MouseWheelEventWithLatencyInfo, |
+ blink::WebMouseWheelEvent>; |
+ |
+using PendingTouchEvent = |
+ EventWithDispatchTypeAndLatencyInfo<TouchEventWithLatencyInfo, |
+ blink::WebTouchEvent>; |
+ |
+class CONTENT_EXPORT MainThreadEventQueueClient { |
+ public: |
+ // Send an |event| that was previously queued (possibly |
+ // coalesced with another event) to the |routing_id|'s |
+ // channel. Implementors must implement this callback. |
+ virtual void SendEventToMainThread(int routing_id, |
+ const blink::WebInputEvent* event, |
+ const ui::LatencyInfo& latency, |
+ InputEventDispatchType dispatch_type) = 0; |
+}; |
+ |
+// MainThreadEventQueue implements a series of queues (one touch |
+// and one mouse wheel) for events that need to be queued between |
+// the compositor and main threads. When an event is sent |
+// from the compositor to main it can either be sent directly if no |
+// outstanding events of that type are in flight; or it needs to |
+// wait in a queue until the main thread has finished processing |
+// the in-flight event. This class tracks the state and queues |
+// for the event types. Methods on this class should only be called |
+// from the compositor thread. |
+class CONTENT_EXPORT MainThreadEventQueue { |
+ public: |
+ MainThreadEventQueue(int routing_id, MainThreadEventQueueClient* client); |
+ ~MainThreadEventQueue(); |
+ |
+ // Called once compositor has handled |event| and indicated that it is |
tdresser
2016/03/14 14:45:03
compositor -> the compositor
dtapuska
2016/03/14 17:33:27
Done.
|
+ // a non-blocking event to be queued to the main thread. |
+ bool HandleEvent(const blink::WebInputEvent* event, |
+ const ui::LatencyInfo& latency, |
+ InputEventAckState ack_result); |
+ |
+ // Call once main thread has handled outstanding |type| event in flight. |
tdresser
2016/03/14 14:45:03
main thread -> the main thread
outstanding -> an o
dtapuska
2016/03/14 17:33:27
Done.
|
+ void EventHandled(blink::WebInputEvent::Type type); |
+ |
+ private: |
+ friend class MainThreadEventQueueTest; |
+ int routing_id_; |
+ MainThreadEventQueueClient* client_; |
+ WebInputEventQueue<PendingMouseWheelEvent> wheel_events_; |
+ WebInputEventQueue<PendingTouchEvent> touch_events_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MainThreadEventQueue); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_ |