Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Unified Diff: content/renderer/input/main_thread_event_queue.h

Issue 1780953003: Change the non-blocking event queue to the main thread event queue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_wheel_regression_5
Patch Set: Force ack in renderer to be solely based on the DispatchEventType Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..05c9becdcfe08e33a233afde873bca19709551fd
--- /dev/null
+++ b/content/renderer/input/main_thread_event_queue.h
@@ -0,0 +1,94 @@
+// 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 EventWithDispatchType : public C {
tdresser 2016/03/15 13:41:21 Can we replace the single letter variable/class na
dtapuska 2016/03/15 19:46:05 Done; was following other template classes; but mo
+ public:
+ EventWithDispatchType(const T& e,
+ const ui::LatencyInfo& l,
+ InputEventDispatchType t)
+ : C(e, l), type(t) {}
+
+ InputEventDispatchType type;
+
+ bool CanCoalesceWith(const EventWithDispatchType& other) const
+ WARN_UNUSED_RESULT {
+ return other.type == type && C::CanCoalesceWith(other);
+ }
+
+ void CoalesceWith(const EventWithDispatchType& other) {
+ C::CoalesceWith(other);
+ }
+};
+
+using PendingMouseWheelEvent =
+ EventWithDispatchType<MouseWheelEventWithLatencyInfo,
+ blink::WebMouseWheelEvent>;
+
+using PendingTouchEvent =
+ EventWithDispatchType<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.
tdresser 2016/03/15 13:41:22 "Implementors must implement this callback" isn't
dtapuska 2016/03/15 19:46:04 I'd agree so; but I believe creis requested it in;
tdresser 2016/03/16 15:34:47 Acknowledged.
+ 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 the compositor has handled |event| and indicated that it is
+ // a non-blocking event to be queued to the main thread.
+ bool HandleEvent(const blink::WebInputEvent* event,
+ const ui::LatencyInfo& latency,
+ InputEventDispatchType dispatch_type,
+ InputEventAckState ack_result);
+
+ // Call once the main thread has handled an outstanding |type| event
+ // in flight.
+ 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_

Powered by Google App Engine
This is Rietveld 408576698