| OLD | NEW |
| 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 Loading... |
| 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 RegisterAssociatedRenderFrameRoutingID( |
| 67 int render_frame_routing_id, |
| 68 int render_view_routing_id) override; |
| 69 void QueueClosureForMainThreadEventQueue( |
| 70 int routing_id, |
| 71 const base::Closure& closure) override; |
| 66 void DidOverscroll(int routing_id, | 72 void DidOverscroll(int routing_id, |
| 67 const ui::DidOverscrollParams& params) override; | 73 const ui::DidOverscrollParams& params) override; |
| 68 void DidStopFlinging(int routing_id) override; | 74 void DidStopFlinging(int routing_id) override; |
| 69 void DispatchNonBlockingEventToMainThread( | 75 void DispatchNonBlockingEventToMainThread( |
| 70 int routing_id, | 76 int routing_id, |
| 71 ui::WebScopedInputEvent event, | 77 ui::WebScopedInputEvent event, |
| 72 const ui::LatencyInfo& latency_info) override; | 78 const ui::LatencyInfo& latency_info) override; |
| 73 | 79 |
| 74 void NotifyInputEventHandled(int routing_id, | 80 void NotifyInputEventHandled(int routing_id, |
| 75 blink::WebInputEvent::Type type, | 81 blink::WebInputEvent::Type type, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 95 void SendInputEventAck(int routing_id, | 101 void SendInputEventAck(int routing_id, |
| 96 blink::WebInputEvent::Type type, | 102 blink::WebInputEvent::Type type, |
| 97 InputEventAckState ack_result, | 103 InputEventAckState ack_result, |
| 98 uint32_t touch_event_id) override; | 104 uint32_t touch_event_id) override; |
| 99 | 105 |
| 100 void NeedsMainFrame(int routing_id) override; | 106 void NeedsMainFrame(int routing_id) override; |
| 101 | 107 |
| 102 private: | 108 private: |
| 103 ~InputEventFilter() override; | 109 ~InputEventFilter() override; |
| 104 | 110 |
| 105 void ForwardToHandler(const IPC::Message& message, | 111 void ForwardToHandler(int routing_id, |
| 112 const IPC::Message& message, |
| 106 base::TimeTicks received_time); | 113 base::TimeTicks received_time); |
| 107 void DidForwardToHandlerAndOverscroll( | 114 void DidForwardToHandlerAndOverscroll( |
| 108 int routing_id, | 115 int routing_id, |
| 109 InputEventDispatchType dispatch_type, | 116 InputEventDispatchType dispatch_type, |
| 110 InputEventAckState ack_state, | 117 InputEventAckState ack_state, |
| 111 ui::WebScopedInputEvent event, | 118 ui::WebScopedInputEvent event, |
| 112 const ui::LatencyInfo& latency_info, | 119 const ui::LatencyInfo& latency_info, |
| 113 std::unique_ptr<ui::DidOverscrollParams> overscroll_params); | 120 std::unique_ptr<ui::DidOverscrollParams> overscroll_params); |
| 114 void SendMessage(std::unique_ptr<IPC::Message> message); | 121 void SendMessage(std::unique_ptr<IPC::Message> message); |
| 115 void SendMessageOnIOThread(std::unique_ptr<IPC::Message> message); | 122 void SendMessageOnIOThread(std::unique_ptr<IPC::Message> message); |
| 116 | 123 |
| 117 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 124 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 118 base::Callback<void(const IPC::Message&)> main_listener_; | 125 base::Callback<void(const IPC::Message&)> main_listener_; |
| 119 | 126 |
| 120 // The sender_ only gets invoked on the thread corresponding to io_loop_. | 127 // The sender_ only gets invoked on the thread corresponding to io_loop_. |
| 121 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 128 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 122 IPC::Sender* sender_; | 129 IPC::Sender* sender_; |
| 123 | 130 |
| 124 // The |input_handler_manager_| should outlive this class and | 131 // The |input_handler_manager_| should outlive this class and |
| 125 // should only be called back on the |target_task_runner_|. | 132 // should only be called back on the |target_task_runner_|. |
| 126 scoped_refptr<base::SingleThreadTaskRunner> target_task_runner_; | 133 scoped_refptr<base::SingleThreadTaskRunner> target_task_runner_; |
| 127 InputHandlerManager* input_handler_manager_; | 134 InputHandlerManager* input_handler_manager_; |
| 128 | 135 |
| 129 // Protects access to routes_. | 136 // Protects access to routes_. |
| 130 base::Lock routes_lock_; | 137 base::Lock routes_lock_; |
| 131 | 138 |
| 132 // Indicates the routing_ids for which input events should be filtered. | 139 // Indicates the routing ids for RenderViews for which input events |
| 140 // should be filtered. |
| 133 std::set<int> routes_; | 141 std::set<int> routes_; |
| 134 | 142 |
| 135 using RouteQueueMap = | 143 using RouteQueueMap = |
| 136 std::unordered_map<int, scoped_refptr<MainThreadEventQueue>>; | 144 std::unordered_map<int, scoped_refptr<MainThreadEventQueue>>; |
| 145 // Maps RenderView routing ids to a MainThreadEventQueue. |
| 137 RouteQueueMap route_queues_; | 146 RouteQueueMap route_queues_; |
| 138 | 147 |
| 148 using AssociatedRoutes = std::unordered_map<int, int>; |
| 149 // Maps RenderFrame routing ids to RenderView routing ids so that |
| 150 // events sent down the two routing pipes can be handled synchronously. |
| 151 AssociatedRoutes associated_routes_; |
| 152 |
| 139 blink::scheduler::RendererScheduler* renderer_scheduler_; | 153 blink::scheduler::RendererScheduler* renderer_scheduler_; |
| 140 }; | 154 }; |
| 141 | 155 |
| 142 } // namespace content | 156 } // namespace content |
| 143 | 157 |
| 144 #endif // CONTENT_RENDERER_INPUT_INPUT_EVENT_FILTER_H_ | 158 #endif // CONTENT_RENDERER_INPUT_INPUT_EVENT_FILTER_H_ |
| OLD | NEW |