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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
(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_MAIN_THREAD_EVENT_QUEUE_H_
6 #define CONTENT_RENDERER_INPUT_MAIN_THREAD_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/input_event_ack_state.h"
12 #include "content/common/input/input_event_dispatch_type.h"
13 #include "content/common/input/web_input_event_queue.h"
14 #include "third_party/WebKit/public/web/WebInputEvent.h"
15 #include "ui/events/latency_info.h"
16
17 namespace content {
18
19 template <typename C, typename T>
20 class EventWithDispatchTypeAndLatencyInfo : public C {
21 public:
22 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.
23 const ui::LatencyInfo& l,
24 InputEventDispatchType t)
25 : C(e, l), type(t) {}
26
27 InputEventDispatchType type;
28
29 bool CanCoalesceWith(const EventWithDispatchTypeAndLatencyInfo& other) const
30 WARN_UNUSED_RESULT {
31 return other.type == type && C::CanCoalesceWith(other);
32 }
33
34 void CoalesceWith(const EventWithDispatchTypeAndLatencyInfo& other) {
35 C::CoalesceWith(other);
36 }
37 };
38
39 using PendingMouseWheelEvent =
40 EventWithDispatchTypeAndLatencyInfo<MouseWheelEventWithLatencyInfo,
41 blink::WebMouseWheelEvent>;
42
43 using PendingTouchEvent =
44 EventWithDispatchTypeAndLatencyInfo<TouchEventWithLatencyInfo,
45 blink::WebTouchEvent>;
46
47 class CONTENT_EXPORT MainThreadEventQueueClient {
48 public:
49 // Send an |event| that was previously queued (possibly
50 // coalesced with another event) to the |routing_id|'s
51 // channel. Implementors must implement this callback.
52 virtual void SendEventToMainThread(int routing_id,
53 const blink::WebInputEvent* event,
54 const ui::LatencyInfo& latency,
55 InputEventDispatchType dispatch_type) = 0;
56 };
57
58 // MainThreadEventQueue implements a series of queues (one touch
59 // and one mouse wheel) for events that need to be queued between
60 // the compositor and main threads. When an event is sent
61 // from the compositor to main it can either be sent directly if no
62 // outstanding events of that type are in flight; or it needs to
63 // wait in a queue until the main thread has finished processing
64 // the in-flight event. This class tracks the state and queues
65 // for the event types. Methods on this class should only be called
66 // from the compositor thread.
67 class CONTENT_EXPORT MainThreadEventQueue {
68 public:
69 MainThreadEventQueue(int routing_id, MainThreadEventQueueClient* client);
70 ~MainThreadEventQueue();
71
72 // 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.
73 // a non-blocking event to be queued to the main thread.
74 bool HandleEvent(const blink::WebInputEvent* event,
75 const ui::LatencyInfo& latency,
76 InputEventAckState ack_result);
77
78 // 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.
79 void EventHandled(blink::WebInputEvent::Type type);
80
81 private:
82 friend class MainThreadEventQueueTest;
83 int routing_id_;
84 MainThreadEventQueueClient* client_;
85 WebInputEventQueue<PendingMouseWheelEvent> wheel_events_;
86 WebInputEventQueue<PendingTouchEvent> touch_events_;
87
88 DISALLOW_COPY_AND_ASSIGN(MainThreadEventQueue);
89 };
90
91 } // namespace content
92
93 #endif // CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698