OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_GPU_INPUT_HANDLER_MANAGER_H_ | 5 #ifndef CONTENT_RENDERER_GPU_INPUT_HANDLER_MANAGER_H_ |
6 #define CONTENT_RENDERER_GPU_INPUT_HANDLER_MANAGER_H_ | 6 #define CONTENT_RENDERER_GPU_INPUT_HANDLER_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "content/renderer/render_view_impl.h" | 11 #include "content/renderer/render_view_impl.h" |
12 #include "ipc/ipc_channel_proxy.h" | 12 #include "ipc/ipc_channel_proxy.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class MessageLoopProxy; | 15 class MessageLoopProxy; |
16 } | 16 } |
17 | 17 |
| 18 namespace cc { |
| 19 class InputHandler; |
| 20 } |
| 21 |
18 namespace WebKit { | 22 namespace WebKit { |
19 class WebInputEvent; | 23 class WebInputEvent; |
20 } | 24 } |
21 | 25 |
22 namespace content { | 26 namespace content { |
23 | 27 |
24 class InputEventFilter; | 28 class InputEventFilter; |
| 29 class InputHandlerWrapper; |
25 | 30 |
26 // InputHandlerManager class manages WebCompositorInputHandler instances for | 31 // InputHandlerManager class manages InputHandlerProxy instances for |
27 // the WebViews in this renderer. | 32 // the WebViews in this renderer. |
28 class InputHandlerManager { | 33 class InputHandlerManager { |
29 public: | 34 public: |
30 // |main_listener| refers to the central IPC message listener that lives on | 35 // |main_listener| refers to the central IPC message listener that lives on |
31 // the main thread, where all incoming IPC messages are first handled. | 36 // the main thread, where all incoming IPC messages are first handled. |
32 // |message_loop_proxy| is the MessageLoopProxy of the compositor thread. | 37 // |message_loop_proxy| is the MessageLoopProxy of the compositor thread. |
33 // The underlying MessageLoop must outlive this object. | 38 // The underlying MessageLoop must outlive this object. |
34 InputHandlerManager( | 39 InputHandlerManager( |
35 IPC::Listener* main_listener, | 40 IPC::Listener* main_listener, |
36 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy); | 41 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy); |
37 ~InputHandlerManager(); | 42 ~InputHandlerManager(); |
38 | 43 |
39 // This MessageFilter should be added to allow input events to be redirected | 44 // This MessageFilter should be added to allow input events to be redirected |
40 // to the compositor's thread. | 45 // to the compositor's thread. |
41 IPC::ChannelProxy::MessageFilter* GetMessageFilter() const; | 46 IPC::ChannelProxy::MessageFilter* GetMessageFilter() const; |
42 | 47 |
43 // Callable from the main thread only. | 48 // Callable from the main thread only. |
44 void AddInputHandler(int routing_id, | 49 void AddInputHandler( |
45 int input_handler_id, | 50 int routing_id, |
46 const base::WeakPtr<RenderViewImpl>& render_view_impl); | 51 const base::WeakPtr<cc::InputHandler>& input_handler, |
| 52 const base::WeakPtr<RenderViewImpl>& render_view_impl); |
47 | 53 |
48 | |
49 private: | |
50 // Callback only from the compositor's thread. | 54 // Callback only from the compositor's thread. |
51 void RemoveInputHandler(int routing_id); | 55 void RemoveInputHandler(int routing_id); |
52 | 56 |
53 // Called from the compositor's thread. | 57 // Called from the compositor's thread. |
54 void HandleInputEvent(int routing_id, | 58 void HandleInputEvent(int routing_id, |
55 const WebKit::WebInputEvent* input_event); | 59 const WebKit::WebInputEvent* input_event); |
56 | 60 |
57 // Called from the compositor's thread. | 61 // Called from the compositor's thread. |
| 62 InputEventFilter* filter() { return filter_.get(); } |
| 63 |
| 64 private: |
| 65 // Called from the compositor's thread. |
58 void AddInputHandlerOnCompositorThread( | 66 void AddInputHandlerOnCompositorThread( |
59 int routing_id, | 67 int routing_id, |
60 int input_handler_id, | |
61 const scoped_refptr<base::MessageLoopProxy>& main_loop, | 68 const scoped_refptr<base::MessageLoopProxy>& main_loop, |
| 69 const base::WeakPtr<cc::InputHandler>& input_handler, |
62 const base::WeakPtr<RenderViewImpl>& render_view_impl); | 70 const base::WeakPtr<RenderViewImpl>& render_view_impl); |
63 | 71 |
64 class InputHandlerWrapper; | |
65 friend class InputHandlerWrapper; | |
66 | |
67 typedef std::map<int, // routing_id | 72 typedef std::map<int, // routing_id |
68 scoped_refptr<InputHandlerWrapper> > InputHandlerMap; | 73 scoped_refptr<InputHandlerWrapper> > InputHandlerMap; |
69 InputHandlerMap input_handlers_; | 74 InputHandlerMap input_handlers_; |
70 | 75 |
71 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 76 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
72 scoped_refptr<InputEventFilter> filter_; | 77 scoped_refptr<InputEventFilter> filter_; |
73 }; | 78 }; |
74 | 79 |
75 } // namespace content | 80 } // namespace content |
76 | 81 |
77 #endif // CONTENT_RENDERER_GPU_INPUT_HANDLER_MANAGER_H_ | 82 #endif // CONTENT_RENDERER_GPU_INPUT_HANDLER_MANAGER_H_ |
OLD | NEW |