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