OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 CHROME_RENDERER_RENDER_THREAD_H_ | 5 #ifndef CHROME_RENDERER_RENDER_THREAD_H_ |
6 #define CHROME_RENDERER_RENDER_THREAD_H_ | 6 #define CHROME_RENDERER_RENDER_THREAD_H_ |
7 | 7 |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "base/shared_memory.h" | 9 #include "base/shared_memory.h" |
10 #include "base/task.h" | 10 #include "base/task.h" |
11 #include "base/thread.h" | 11 #include "base/thread.h" |
12 #include "chrome/common/ipc_sync_channel.h" | 12 #include "chrome/common/ipc_sync_channel.h" |
13 #include "chrome/common/message_router.h" | 13 #include "chrome/common/message_router.h" |
14 | 14 |
15 class SkBitmap; | 15 class SkBitmap; |
16 class Task; | 16 class Task; |
17 class VisitedLinkSlave; | 17 class VisitedLinkSlave; |
18 struct WebPreferences; | 18 struct WebPreferences; |
19 class RenderDnsMaster; | 19 class RenderDnsMaster; |
20 class NotificationService; | 20 class NotificationService; |
21 class GreasemonkeySlave; | 21 class GreasemonkeySlave; |
22 | 22 |
23 // The RenderThreadBase is the minimal interface that a RenderWidget expects | 23 // The RenderThreadBase is the minimal interface that a RenderView/Widget |
24 // from a render thread. The interface basically abstracts a way to send and | 24 // expects from a render thread. The interface basically abstracts a way to send |
25 // receive messages. It is currently only used for testing. | 25 // and receive messages. |
26 class RenderThreadBase : public IPC::Message::Sender { | 26 class RenderThreadBase : public IPC::Message::Sender { |
27 public: | 27 public: |
28 virtual ~RenderThreadBase() {} | 28 virtual ~RenderThreadBase() {} |
29 | 29 |
30 // True if currently sending a message. | 30 // True if currently sending a message. |
31 virtual bool InSend() const = 0; | 31 virtual bool InSend() const = 0; |
32 | 32 |
33 // Called to add or remove a listener for a particular message routing ID. | 33 // Called to add or remove a listener for a particular message routing ID. |
34 // These methods normally get delegated to a MessageRouter. | 34 // These methods normally get delegated to a MessageRouter. |
35 virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener) = 0; | 35 virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener) = 0; |
36 virtual void RemoveRoute(int32 routing_id) = 0; | 36 virtual void RemoveRoute(int32 routing_id) = 0; |
| 37 |
| 38 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; |
| 39 virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; |
37 }; | 40 }; |
38 | 41 |
39 // The RenderThread class represents a background thread where RenderView | 42 // The RenderThread class represents a background thread where RenderView |
40 // instances live. The RenderThread supports an API that is used by its | 43 // instances live. The RenderThread supports an API that is used by its |
41 // consumer to talk indirectly to the RenderViews and supporting objects. | 44 // consumer to talk indirectly to the RenderViews and supporting objects. |
42 // Likewise, it provides an API for the RenderViews to talk back to the main | 45 // Likewise, it provides an API for the RenderViews to talk back to the main |
43 // process (i.e., their corresponding WebContents). | 46 // process (i.e., their corresponding WebContents). |
44 // | 47 // |
45 // Most of the communication occurs in the form of IPC messages. They are | 48 // Most of the communication occurs in the form of IPC messages. They are |
46 // routed to the RenderThread according to the routing IDs of the messages. | 49 // routed to the RenderThread according to the routing IDs of the messages. |
47 // The routing IDs correspond to RenderView instances. | 50 // The routing IDs correspond to RenderView instances. |
48 class RenderThread : public IPC::Channel::Listener, | 51 class RenderThread : public IPC::Channel::Listener, |
49 public RenderThreadBase, | 52 public RenderThreadBase, |
50 public base::Thread { | 53 public base::Thread { |
51 public: | 54 public: |
52 RenderThread(const std::wstring& channel_name); | 55 RenderThread(const std::wstring& channel_name); |
53 virtual ~RenderThread(); | 56 virtual ~RenderThread(); |
54 | 57 |
55 // IPC::Channel::Listener implementation: | 58 // IPC::Channel::Listener implementation: |
56 virtual void OnMessageReceived(const IPC::Message& msg); | 59 virtual void OnMessageReceived(const IPC::Message& msg); |
57 virtual void OnChannelError(); | 60 virtual void OnChannelError(); |
58 | 61 |
59 // IPC::Message::Sender implementation: | 62 // IPC::Message::Sender implementation: |
60 virtual bool Send(IPC::Message* msg); | 63 virtual bool Send(IPC::Message* msg); |
61 | 64 |
62 void AddFilter(IPC::ChannelProxy::MessageFilter* filter); | 65 // Overridded from RenderThreadBase. |
63 void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter); | 66 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter); |
| 67 virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter); |
64 | 68 |
65 // Gets the VisitedLinkSlave instance for this thread | 69 // Gets the VisitedLinkSlave instance for this thread |
66 VisitedLinkSlave* visited_link_slave() const { return visited_link_slave_; } | 70 VisitedLinkSlave* visited_link_slave() const { return visited_link_slave_; } |
67 | 71 |
68 // Gets the GreasemonkeySlave instance for this thread | 72 // Gets the GreasemonkeySlave instance for this thread |
69 GreasemonkeySlave* greasemonkey_slave() const { return greasemonkey_slave_; } | 73 GreasemonkeySlave* greasemonkey_slave() const { return greasemonkey_slave_; } |
70 | 74 |
71 // Do DNS prefetch resolution of a hostname. | 75 // Do DNS prefetch resolution of a hostname. |
72 void Resolve(const char* name, size_t length); | 76 void Resolve(const char* name, size_t length); |
73 | 77 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 int in_send_; | 138 int in_send_; |
135 | 139 |
136 DISALLOW_EVIL_CONSTRUCTORS(RenderThread); | 140 DISALLOW_EVIL_CONSTRUCTORS(RenderThread); |
137 }; | 141 }; |
138 | 142 |
139 // The global RenderThread object for this process. Note that this should only | 143 // The global RenderThread object for this process. Note that this should only |
140 // be accessed when running on the render thread itself. | 144 // be accessed when running on the render thread itself. |
141 extern RenderThread* g_render_thread; | 145 extern RenderThread* g_render_thread; |
142 | 146 |
143 #endif // CHROME_RENDERER_RENDER_THREAD_H_ | 147 #endif // CHROME_RENDERER_RENDER_THREAD_H_ |
OLD | NEW |