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