| 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_COMPOSITOR_THREAD_H_ | 5 #ifndef CONTENT_RENDERER_GPU_COMPOSITOR_THREAD_H_ |
| 6 #define CONTENT_RENDERER_GPU_COMPOSITOR_THREAD_H_ | 6 #define CONTENT_RENDERER_GPU_COMPOSITOR_THREAD_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "content/renderer/render_view_impl.h" |
| 11 #include "ipc/ipc_channel_proxy.h" | 13 #include "ipc/ipc_channel_proxy.h" |
| 12 #include "webkit/glue/webthread_impl.h" | 14 #include "webkit/glue/webthread_impl.h" |
| 13 | 15 |
| 14 namespace WebKit { | 16 namespace WebKit { |
| 15 class WebInputEvent; | 17 class WebInputEvent; |
| 16 } | 18 } |
| 17 | 19 |
| 18 class InputEventFilter; | 20 class InputEventFilter; |
| 19 | 21 |
| 20 // The CompositorThread class manages the background thread for the compositor. | 22 // The CompositorThread class manages the background thread for the compositor. |
| 21 // The CompositorThread instance can be assumed to outlive the background | 23 // The CompositorThread instance can be assumed to outlive the background |
| 22 // thread it manages. | 24 // thread it manages. |
| 23 class CompositorThread { | 25 class CompositorThread { |
| 24 public: | 26 public: |
| 25 // |main_listener| refers to the central IPC message listener that lives on | 27 // |main_listener| refers to the central IPC message listener that lives on |
| 26 // the main thread, where all incoming IPC messages are first handled. | 28 // the main thread, where all incoming IPC messages are first handled. |
| 27 explicit CompositorThread(IPC::Channel::Listener* main_listener); | 29 explicit CompositorThread(IPC::Channel::Listener* main_listener); |
| 28 ~CompositorThread(); | 30 ~CompositorThread(); |
| 29 | 31 |
| 30 // This MessageFilter should be added to allow input events to be redirected | 32 // This MessageFilter should be added to allow input events to be redirected |
| 31 // to the compositor's thread. | 33 // to the compositor's thread. |
| 32 IPC::ChannelProxy::MessageFilter* GetMessageFilter() const; | 34 IPC::ChannelProxy::MessageFilter* GetMessageFilter() const; |
| 33 | 35 |
| 34 // Callable from the main thread or the compositor's thread. | 36 // Callable from the main thread only. |
| 35 void AddInputHandler(int routing_id, int input_handler_id); | 37 void AddInputHandler(int routing_id, |
| 38 int input_handler_id, |
| 39 const base::WeakPtr<RenderViewImpl>& render_view_impl); |
| 36 | 40 |
| 37 webkit_glue::WebThreadImpl* GetWebThread() { return &thread_; } | 41 webkit_glue::WebThreadImpl* GetWebThread() { return &thread_; } |
| 38 | 42 |
| 39 private: | 43 private: |
| 40 // Callback only from the compositor's thread. | 44 // Callback only from the compositor's thread. |
| 41 void RemoveInputHandler(int routing_id); | 45 void RemoveInputHandler(int routing_id); |
| 42 | 46 |
| 43 // Called from the compositor's thread. | 47 // Called from the compositor's thread. |
| 44 void HandleInputEvent(int routing_id, | 48 void HandleInputEvent(int routing_id, |
| 45 const WebKit::WebInputEvent* input_event); | 49 const WebKit::WebInputEvent* input_event); |
| 46 | 50 |
| 51 // Called from the compositor's thread. |
| 52 void AddInputHandlerOnCompositorThread( |
| 53 int routing_id, |
| 54 int input_handler_id, |
| 55 scoped_refptr<base::MessageLoopProxy> main_loop, |
| 56 const base::WeakPtr<RenderViewImpl>& render_view_impl); |
| 57 |
| 47 class InputHandlerWrapper; | 58 class InputHandlerWrapper; |
| 48 friend class InputHandlerWrapper; | 59 friend class InputHandlerWrapper; |
| 49 | 60 |
| 50 typedef std::map<int, // routing_id | 61 typedef std::map<int, // routing_id |
| 51 linked_ptr<InputHandlerWrapper> > InputHandlerMap; | 62 scoped_refptr<InputHandlerWrapper> > InputHandlerMap; |
| 52 InputHandlerMap input_handlers_; | 63 InputHandlerMap input_handlers_; |
| 53 | 64 |
| 54 webkit_glue::WebThreadImpl thread_; | 65 webkit_glue::WebThreadImpl thread_; |
| 55 scoped_refptr<InputEventFilter> filter_; | 66 scoped_refptr<InputEventFilter> filter_; |
| 56 }; | 67 }; |
| 57 | 68 |
| 58 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_THREAD_H_ | 69 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_THREAD_H_ |
| OLD | NEW |