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

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

Issue 2813683002: Allow MainThreadEventQueue to call the RenderWidget directly. (Closed)
Patch Set: Fix style nits 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_HANDLER_MANAGER_H_ 5 #ifndef CONTENT_RENDERER_INPUT_INPUT_HANDLER_MANAGER_H_
6 #define CONTENT_RENDERER_INPUT_INPUT_HANDLER_MANAGER_H_ 6 #define CONTENT_RENDERER_INPUT_INPUT_HANDLER_MANAGER_H_
7 7
8 #include <unordered_map> 8 #include <unordered_map>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "content/common/input/input_event_ack_state.h" 13 #include "content/common/input/input_event_ack_state.h"
14 #include "content/renderer/render_view_impl.h" 14 #include "content/renderer/render_view_impl.h"
15 #include "ui/events/blink/input_handler_proxy.h" 15 #include "ui/events/blink/input_handler_proxy.h"
16 16
17 namespace base { 17 namespace base {
18 class SingleThreadTaskRunner; 18 class SingleThreadTaskRunner;
19 } 19 }
20 20
21 namespace cc { 21 namespace cc {
22 class InputHandler; 22 class InputHandler;
23 struct InputHandlerScrollResult; 23 struct InputHandlerScrollResult;
24 } 24 }
25 25
26 namespace blink { 26 namespace blink {
27 class WebInputEvent;
28 class WebMouseWheelEvent; 27 class WebMouseWheelEvent;
29 } 28 }
30 29
31 namespace blink { 30 namespace blink {
32 namespace scheduler { 31 namespace scheduler {
33 class RendererScheduler; 32 class RendererScheduler;
34 } 33 }
35 } 34 }
36 35
37 namespace ui { 36 namespace ui {
38 struct DidOverscrollParams; 37 struct DidOverscrollParams;
39 } 38 }
40 39
41 namespace content { 40 namespace content {
42 41
43 class InputHandlerWrapper; 42 class InputHandlerWrapper;
43 class InputHandlerManagerClient;
44 class MainThreadEventQueue;
44 class SynchronousInputHandlerProxyClient; 45 class SynchronousInputHandlerProxyClient;
45 class InputHandlerManagerClient;
46 46
47 // InputHandlerManager class manages InputHandlerProxy instances for 47 // InputHandlerManager class manages InputHandlerProxy instances for
48 // the WebViews in this renderer. 48 // the WebViews in this renderer.
49 class CONTENT_EXPORT InputHandlerManager { 49 class CONTENT_EXPORT InputHandlerManager {
50 public: 50 public:
51 // |task_runner| is the SingleThreadTaskRunner of the compositor thread. The 51 // |task_runner| is the SingleThreadTaskRunner of the compositor thread. The
52 // underlying MessageLoop and supplied |client| and the |renderer_scheduler| 52 // underlying MessageLoop and supplied |client| and the |renderer_scheduler|
53 // must outlive this object. The RendererScheduler needs to know when input 53 // must outlive this object. The RendererScheduler needs to know when input
54 // events and fling animations occur, which is why it's passed in here. 54 // events and fling animations occur, which is why it's passed in here.
55 InputHandlerManager( 55 InputHandlerManager(
56 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 56 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
57 InputHandlerManagerClient* client, 57 InputHandlerManagerClient* client,
58 SynchronousInputHandlerProxyClient* sync_handler_client, 58 SynchronousInputHandlerProxyClient* sync_handler_client,
59 blink::scheduler::RendererScheduler* renderer_scheduler); 59 blink::scheduler::RendererScheduler* renderer_scheduler);
60 virtual ~InputHandlerManager(); 60 virtual ~InputHandlerManager();
61 61
62 // Callable from the main thread only. 62 // Callable from the main thread only.
63 void AddInputHandler(int routing_id, 63 void AddInputHandler(
64 const base::WeakPtr<cc::InputHandler>& input_handler, 64 int routing_id,
65 const base::WeakPtr<RenderWidget>& render_widget, 65 const base::WeakPtr<cc::InputHandler>& input_handler,
66 bool enable_smooth_scrolling); 66 const scoped_refptr<MainThreadEventQueue>& input_event_queue,
67 const base::WeakPtr<RenderWidget>& render_widget,
68 bool enable_smooth_scrolling);
67 69
68 void RegisterRoutingID(int routing_id);
69 void UnregisterRoutingID(int routing_id); 70 void UnregisterRoutingID(int routing_id);
70 71
71 void RegisterAssociatedRenderFrameRoutingID(int render_frame_routing_id, 72 void RegisterAssociatedRenderFrameRoutingID(int render_frame_routing_id,
72 int render_view_routing_id); 73 int render_view_routing_id);
73 void RegisterAssociatedRenderFrameRoutingIDOnCompositorThread( 74 void RegisterAssociatedRenderFrameRoutingIDOnCompositorThread(
74 int render_frame_routing_id, 75 int render_frame_routing_id,
75 int render_view_routing_id); 76 int render_view_routing_id);
76 77
77 void ObserveGestureEventAndResultOnMainThread( 78 void ObserveGestureEventAndResultOnMainThread(
78 int routing_id, 79 int routing_id,
79 const blink::WebGestureEvent& gesture_event, 80 const blink::WebGestureEvent& gesture_event,
80 const cc::InputHandlerScrollResult& scroll_result); 81 const cc::InputHandlerScrollResult& scroll_result);
81 82
82 void NotifyInputEventHandledOnMainThread(int routing_id,
83 blink::WebInputEvent::Type,
84 blink::WebInputEventResult,
85 InputEventAckState);
86 void ProcessRafAlignedInputOnMainThread(int routing_id,
87 base::TimeTicks frame_time);
88
89 // Callback only from the compositor's thread. 83 // Callback only from the compositor's thread.
90 void RemoveInputHandler(int routing_id); 84 void RemoveInputHandler(int routing_id);
91 85
92 using InputEventAckStateCallback = 86 using InputEventAckStateCallback =
93 base::Callback<void(InputEventAckState, 87 base::Callback<void(InputEventAckState,
94 ui::WebScopedInputEvent, 88 ui::WebScopedInputEvent,
95 const ui::LatencyInfo&, 89 const ui::LatencyInfo&,
96 std::unique_ptr<ui::DidOverscrollParams>)>; 90 std::unique_ptr<ui::DidOverscrollParams>)>;
97 // Called from the compositor's thread. 91 // Called from the compositor's thread.
98 virtual void HandleInputEvent(int routing_id, 92 virtual void HandleInputEvent(int routing_id,
99 ui::WebScopedInputEvent input_event, 93 ui::WebScopedInputEvent input_event,
100 const ui::LatencyInfo& latency_info, 94 const ui::LatencyInfo& latency_info,
101 const InputEventAckStateCallback& callback); 95 const InputEventAckStateCallback& callback);
102 96
103 virtual void QueueClosureForMainThreadEventQueue( 97 virtual void QueueClosureForMainThreadEventQueue(
104 int routing_id, 98 int routing_id,
105 const base::Closure& closure); 99 const base::Closure& closure);
106 // Called from the compositor's thread. 100 // Called from the compositor's thread.
107 void DidOverscroll(int routing_id, const ui::DidOverscrollParams& params); 101 void DidOverscroll(int routing_id, const ui::DidOverscrollParams& params);
108 102
109 // Called from the compositor's thread. 103 // Called from the compositor's thread.
110 void DidStopFlinging(int routing_id); 104 void DidStopFlinging(int routing_id);
111 105
112 // Called from the compositor's thread. 106 // Called from the compositor's thread.
113 void DidAnimateForInput(); 107 void DidAnimateForInput();
114 108
115 // Called from the compositor's thread. 109 // Called from the compositor's thread.
116 virtual void NeedsMainFrame(int routing_id);
117
118 // Called from the compositor's thread.
119 void DispatchNonBlockingEventToMainThread( 110 void DispatchNonBlockingEventToMainThread(
120 int routing_id, 111 int routing_id,
121 ui::WebScopedInputEvent event, 112 ui::WebScopedInputEvent event,
122 const ui::LatencyInfo& latency_info); 113 const ui::LatencyInfo& latency_info);
123 114
124 private: 115 private:
125 // Called from the compositor's thread. 116 // Called from the compositor's thread.
126 void AddInputHandlerOnCompositorThread( 117 void AddInputHandlerOnCompositorThread(
127 int routing_id, 118 int routing_id,
128 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, 119 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
129 const base::WeakPtr<cc::InputHandler>& input_handler, 120 const base::WeakPtr<cc::InputHandler>& input_handler,
121 const scoped_refptr<MainThreadEventQueue>& input_event_queue,
130 const base::WeakPtr<RenderWidget>& render_widget, 122 const base::WeakPtr<RenderWidget>& render_widget,
131 bool enable_smooth_scrolling); 123 bool enable_smooth_scrolling);
132 124
133 void RegisterRoutingIDOnCompositorThread(int routing_id);
134 void UnregisterRoutingIDOnCompositorThread(int routing_id); 125 void UnregisterRoutingIDOnCompositorThread(int routing_id);
135 126
136 void ObserveWheelEventAndResultOnCompositorThread( 127 void ObserveWheelEventAndResultOnCompositorThread(
137 int routing_id, 128 int routing_id,
138 const blink::WebMouseWheelEvent& wheel_event, 129 const blink::WebMouseWheelEvent& wheel_event,
139 const cc::InputHandlerScrollResult& scroll_result); 130 const cc::InputHandlerScrollResult& scroll_result);
140 131
141 void ObserveGestureEventAndResultOnCompositorThread( 132 void ObserveGestureEventAndResultOnCompositorThread(
142 int routing_id, 133 int routing_id,
143 const blink::WebGestureEvent& gesture_event, 134 const blink::WebGestureEvent& gesture_event,
(...skipping 16 matching lines...) Expand all
160 // May be null. 151 // May be null.
161 SynchronousInputHandlerProxyClient* const synchronous_handler_proxy_client_; 152 SynchronousInputHandlerProxyClient* const synchronous_handler_proxy_client_;
162 blink::scheduler::RendererScheduler* const renderer_scheduler_; // Not owned. 153 blink::scheduler::RendererScheduler* const renderer_scheduler_; // Not owned.
163 154
164 base::WeakPtrFactory<InputHandlerManager> weak_ptr_factory_; 155 base::WeakPtrFactory<InputHandlerManager> weak_ptr_factory_;
165 }; 156 };
166 157
167 } // namespace content 158 } // namespace content
168 159
169 #endif // CONTENT_RENDERER_INPUT_INPUT_HANDLER_MANAGER_H_ 160 #endif // CONTENT_RENDERER_INPUT_INPUT_HANDLER_MANAGER_H_
OLDNEW
« no previous file with comments | « content/renderer/input/input_event_filter_unittest.cc ('k') | content/renderer/input/input_handler_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698