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

Side by Side Diff: content/renderer/input/input_event_filter.h

Issue 2765583002: Teach main thread event queue about closures. (Closed)
Patch Set: Add comments 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_INPUT_INPUT_EVENT_FILTER_H_ 5 #ifndef CONTENT_RENDERER_INPUT_INPUT_EVENT_FILTER_H_
6 #define CONTENT_RENDERER_INPUT_INPUT_EVENT_FILTER_H_ 6 #define CONTENT_RENDERER_INPUT_INPUT_EVENT_FILTER_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <set> 9 #include <set>
10 #include <unordered_map> 10 #include <unordered_map>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // If INPUT_EVENT_ACK_STATE_NOT_CONSUMED is returned by the handler, 56 // If INPUT_EVENT_ACK_STATE_NOT_CONSUMED is returned by the handler,
57 // the original InputMsg_HandleInputEvent message will be delivered to 57 // the original InputMsg_HandleInputEvent message will be delivered to
58 // |main_listener| on the main thread. (The "main thread" in this context is 58 // |main_listener| on the main thread. (The "main thread" in this context is
59 // the thread where the InputEventFilter was constructed.) The responsibility 59 // the thread where the InputEventFilter was constructed.) The responsibility
60 // is left to the eventual handler to deliver the corresponding 60 // is left to the eventual handler to deliver the corresponding
61 // InputHostMsg_HandleInputEvent_ACK. 61 // InputHostMsg_HandleInputEvent_ACK.
62 // 62 //
63 void SetInputHandlerManager(InputHandlerManager*) override; 63 void SetInputHandlerManager(InputHandlerManager*) override;
64 void RegisterRoutingID(int routing_id) override; 64 void RegisterRoutingID(int routing_id) override;
65 void UnregisterRoutingID(int routing_id) override; 65 void UnregisterRoutingID(int routing_id) override;
66 void AssociateRenderFrameRoutingID(int render_frame_routing_id,
67 int render_view_routing_id) override;
tdresser 2017/03/30 17:46:16 RegisterAssociatedRenderFrameRoutingID?
dtapuska 2017/03/30 19:45:51 Done.
68 void QueueClosureForMainThreadEventQueue(
69 int routing_id,
70 const base::Closure& closure) override;
66 void DidOverscroll(int routing_id, 71 void DidOverscroll(int routing_id,
67 const ui::DidOverscrollParams& params) override; 72 const ui::DidOverscrollParams& params) override;
68 void DidStopFlinging(int routing_id) override; 73 void DidStopFlinging(int routing_id) override;
69 void DispatchNonBlockingEventToMainThread( 74 void DispatchNonBlockingEventToMainThread(
70 int routing_id, 75 int routing_id,
71 ui::WebScopedInputEvent event, 76 ui::WebScopedInputEvent event,
72 const ui::LatencyInfo& latency_info) override; 77 const ui::LatencyInfo& latency_info) override;
73 78
74 void NotifyInputEventHandled(int routing_id, 79 void NotifyInputEventHandled(int routing_id,
75 blink::WebInputEvent::Type type, 80 blink::WebInputEvent::Type type,
(...skipping 19 matching lines...) Expand all
95 void SendInputEventAck(int routing_id, 100 void SendInputEventAck(int routing_id,
96 blink::WebInputEvent::Type type, 101 blink::WebInputEvent::Type type,
97 InputEventAckState ack_result, 102 InputEventAckState ack_result,
98 uint32_t touch_event_id) override; 103 uint32_t touch_event_id) override;
99 104
100 void NeedsMainFrame(int routing_id) override; 105 void NeedsMainFrame(int routing_id) override;
101 106
102 private: 107 private:
103 ~InputEventFilter() override; 108 ~InputEventFilter() override;
104 109
105 void ForwardToHandler(const IPC::Message& message, 110 void ForwardToHandler(int routing_id,
111 const IPC::Message& message,
106 base::TimeTicks received_time); 112 base::TimeTicks received_time);
107 void DidForwardToHandlerAndOverscroll( 113 void DidForwardToHandlerAndOverscroll(
108 int routing_id, 114 int routing_id,
109 InputEventDispatchType dispatch_type, 115 InputEventDispatchType dispatch_type,
110 InputEventAckState ack_state, 116 InputEventAckState ack_state,
111 ui::WebScopedInputEvent event, 117 ui::WebScopedInputEvent event,
112 const ui::LatencyInfo& latency_info, 118 const ui::LatencyInfo& latency_info,
113 std::unique_ptr<ui::DidOverscrollParams> overscroll_params); 119 std::unique_ptr<ui::DidOverscrollParams> overscroll_params);
114 void SendMessage(std::unique_ptr<IPC::Message> message); 120 void SendMessage(std::unique_ptr<IPC::Message> message);
115 void SendMessageOnIOThread(std::unique_ptr<IPC::Message> message); 121 void SendMessageOnIOThread(std::unique_ptr<IPC::Message> message);
116 122
117 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 123 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
118 base::Callback<void(const IPC::Message&)> main_listener_; 124 base::Callback<void(const IPC::Message&)> main_listener_;
119 125
120 // The sender_ only gets invoked on the thread corresponding to io_loop_. 126 // The sender_ only gets invoked on the thread corresponding to io_loop_.
121 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 127 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
122 IPC::Sender* sender_; 128 IPC::Sender* sender_;
123 129
124 // The |input_handler_manager_| should outlive this class and 130 // The |input_handler_manager_| should outlive this class and
125 // should only be called back on the |target_task_runner_|. 131 // should only be called back on the |target_task_runner_|.
126 scoped_refptr<base::SingleThreadTaskRunner> target_task_runner_; 132 scoped_refptr<base::SingleThreadTaskRunner> target_task_runner_;
127 InputHandlerManager* input_handler_manager_; 133 InputHandlerManager* input_handler_manager_;
128 134
129 // Protects access to routes_. 135 // Protects access to routes_.
130 base::Lock routes_lock_; 136 base::Lock routes_lock_;
131 137
132 // Indicates the routing_ids for which input events should be filtered. 138 // Indicates the routing ids for RenderViews for which input events
139 // should be filtered.
133 std::set<int> routes_; 140 std::set<int> routes_;
134 141
135 using RouteQueueMap = 142 using RouteQueueMap =
136 std::unordered_map<int, scoped_refptr<MainThreadEventQueue>>; 143 std::unordered_map<int, scoped_refptr<MainThreadEventQueue>>;
144 // Maps RenderView routing ids to a MainThreadEventQueue.
137 RouteQueueMap route_queues_; 145 RouteQueueMap route_queues_;
138 146
147 using AssociatedRoutes = std::unordered_map<int, int>;
148 // Maps RenderFrame routing ids to RenderView routing ids so that
149 // events sent down the two routing pipes can be handled synchronously.
150 AssociatedRoutes associated_routes_;
151
139 blink::scheduler::RendererScheduler* renderer_scheduler_; 152 blink::scheduler::RendererScheduler* renderer_scheduler_;
140 }; 153 };
141 154
142 } // namespace content 155 } // namespace content
143 156
144 #endif // CONTENT_RENDERER_INPUT_INPUT_EVENT_FILTER_H_ 157 #endif // CONTENT_RENDERER_INPUT_INPUT_EVENT_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698