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

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

Issue 2813683002: Allow MainThreadEventQueue to call the RenderWidget directly. (Closed)
Patch Set: Created 3 years, 8 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
index 42edd0cfeaf5ee946f3baaaa70e26e9d685997e2..bc607903563030f0a8f5cd8963513ebdeb03a3af 100644
--- a/content/renderer/input/main_thread_event_queue.h
+++ b/content/renderer/input/main_thread_event_queue.h
@@ -7,6 +7,7 @@
#include <deque>
#include "base/feature_list.h"
+#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "content/common/input/input_event_ack_state.h"
#include "content/common/input/input_event_dispatch_type.h"
@@ -20,23 +21,7 @@
namespace content {
-class CONTENT_EXPORT MainThreadEventQueueClient {
- public:
- // Handle an |event| that was previously queued (possibly
- // coalesced with another event) to the |routing_id|'s
- // channel. Implementors must implement this callback.
- virtual void HandleEventOnMainThread(
- int routing_id,
- const blink::WebCoalescedInputEvent* event,
- const ui::LatencyInfo& latency,
- InputEventDispatchType dispatch_type) = 0;
-
- virtual void SendInputEventAck(int routing_id,
- blink::WebInputEvent::Type type,
- InputEventAckState ack_result,
- uint32_t touch_event_id) = 0;
- virtual void NeedsMainFrame(int routing_id) = 0;
-};
+class RenderWidget;
// MainThreadEventQueue implements a queue for events that need to be
// queued between the compositor and main threads. This queue is managed
@@ -78,8 +63,6 @@ class CONTENT_EXPORT MainThreadEventQueue
: public base::RefCountedThreadSafe<MainThreadEventQueue> {
public:
MainThreadEventQueue(
- int routing_id,
- MainThreadEventQueueClient* client,
const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
blink::scheduler::RendererScheduler* renderer_scheduler);
@@ -92,15 +75,22 @@ class CONTENT_EXPORT MainThreadEventQueue
void DispatchRafAlignedInput(base::TimeTicks frame_time);
void QueueClosure(const base::Closure& closure);
- // Call once the main thread has handled an outstanding |type| event
- // in flight.
- void EventHandled(blink::WebInputEvent::Type type,
- blink::WebInputEventResult result,
- InputEventAckState ack_result);
+ void NotifySchedulerOfEventHandled(const blink::WebInputEvent& event,
+ InputEventAckState ack_result);
- private:
+ virtual InputEventAckState HandleEventOnMainThread(
+ const blink::WebCoalescedInputEvent& event,
+ const ui::LatencyInfo& latency,
+ InputEventDispatchType dispatch_type) = 0;
+
+ virtual void SendInputEventAck(blink::WebInputEvent::Type type,
+ InputEventAckState ack_result,
+ uint32_t touch_event_id) = 0;
tdresser 2017/04/10 15:54:17 Why is SendInputEventAck separate from NotifySched
dtapuska 2017/04/10 16:08:05 Mainly for the tests. There is a mock renderer sch
+ virtual void NeedsMainFrame() = 0;
+
+ protected:
friend class base::RefCountedThreadSafe<MainThreadEventQueue>;
- ~MainThreadEventQueue();
+ virtual ~MainThreadEventQueue();
void QueueEvent(std::unique_ptr<MainThreadEventQueueTask> event);
void PostTaskToMainThread();
void DispatchEvents();
@@ -117,8 +107,6 @@ class CONTENT_EXPORT MainThreadEventQueue
friend class MainThreadEventQueueTest;
friend class MainThreadEventQueueInitializationTest;
- int routing_id_;
- MainThreadEventQueueClient* client_;
std::unique_ptr<MainThreadEventQueueTask> in_flight_event_;
bool last_touch_start_forced_nonblocking_due_to_fling_;
bool enable_fling_passive_listener_flag_;
@@ -150,6 +138,31 @@ class CONTENT_EXPORT MainThreadEventQueue
DISALLOW_COPY_AND_ASSIGN(MainThreadEventQueue);
};
+class MainThreadEventQueueWithRenderWidget : public MainThreadEventQueue {
tdresser 2017/04/10 15:54:17 Why doesn't the MainThreadEventQueue just have a w
dtapuska 2017/04/10 16:08:05 I could do it that way but the abstraction is for
tdresser 2017/04/10 16:25:01 Could we add a new interface which RenderWidget im
dtapuska 2017/04/13 16:56:24 Done.
+ public:
+ MainThreadEventQueueWithRenderWidget(
+ const base::WeakPtr<RenderWidget>& widget,
+ blink::scheduler::RendererScheduler* renderer_scheduler);
+
+ InputEventAckState HandleEventOnMainThread(
+ const blink::WebCoalescedInputEvent& event,
+ const ui::LatencyInfo& latency,
+ InputEventDispatchType dispatch_type) override;
+
+ void SendInputEventAck(blink::WebInputEvent::Type type,
+ InputEventAckState ack_result,
+ uint32_t touch_event_id) override;
+
+ void NeedsMainFrame() override;
+
+ private:
+ ~MainThreadEventQueueWithRenderWidget() override;
+
+ base::WeakPtr<RenderWidget> widget_;
+
+ DISALLOW_COPY_AND_ASSIGN(MainThreadEventQueueWithRenderWidget);
+};
+
} // namespace content
#endif // CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_

Powered by Google App Engine
This is Rietveld 408576698