summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_thread.h
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/renderer/render_thread.h')
-rw-r--r--chrome/renderer/render_thread.h70
1 files changed, 40 insertions, 30 deletions
diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h
index a3bd534..44dd548 100644
--- a/chrome/renderer/render_thread.h
+++ b/chrome/renderer/render_thread.h
@@ -10,8 +10,10 @@
#include "base/gfx/native_widget_types.h"
#include "base/shared_memory.h"
#include "base/task.h"
+#include "base/thread.h"
#include "build/build_config.h"
-#include "chrome/common/child_thread.h"
+#include "chrome/common/ipc_sync_channel.h"
+#include "chrome/common/message_router.h"
class FilePath;
class NotificationService;
@@ -25,12 +27,10 @@ struct WebPreferences;
// The RenderThreadBase is the minimal interface that a RenderView/Widget
// expects from a render thread. The interface basically abstracts a way to send
// and receive messages.
-class RenderThreadBase {
+class RenderThreadBase : public IPC::Message::Sender {
public:
virtual ~RenderThreadBase() {}
- virtual bool Send(IPC::Message* msg) = 0;
-
// True if currently sending a message.
virtual bool InSend() const = 0;
@@ -52,35 +52,21 @@ class RenderThreadBase {
// Most of the communication occurs in the form of IPC messages. They are
// routed to the RenderThread according to the routing IDs of the messages.
// The routing IDs correspond to RenderView instances.
-class RenderThread : public RenderThreadBase,
- public ChildThread {
+class RenderThread : public IPC::Channel::Listener,
+ public RenderThreadBase,
+ public base::Thread {
public:
- // Grabs the IPC channel name from the command line.
- RenderThread();
- // Constructor that's used when running in single process mode.
- RenderThread(const std::wstring& channel_name);
+ explicit RenderThread(const std::wstring& channel_name);
virtual ~RenderThread();
- // Returns the one render thread for this process. Note that this should only
- // be accessed when running on the render thread itself
- static RenderThread* current();
-
- // Overridded from RenderThreadBase.
- virtual bool Send(IPC::Message* msg) {
- return ChildThread::Send(msg);
- }
-
- virtual bool InSend() const {
- return ChildThread::InSend();
- }
+ // IPC::Channel::Listener implementation:
+ virtual void OnMessageReceived(const IPC::Message& msg);
+ virtual void OnChannelError();
- virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener) {
- return ChildThread::AddRoute(routing_id, listener);
- }
- virtual void RemoveRoute(int32 routing_id) {
- return ChildThread::RemoveRoute(routing_id);
- }
+ // IPC::Message::Sender implementation:
+ virtual bool Send(IPC::Message* msg);
+ // Overridded from RenderThreadBase.
virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter);
virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter);
@@ -93,17 +79,25 @@ class RenderThread : public RenderThreadBase,
// Do DNS prefetch resolution of a hostname.
void Resolve(const char* name, size_t length);
+ // See documentation on MessageRouter for AddRoute and RemoveRoute
+ virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener);
+ virtual void RemoveRoute(int32 routing_id);
+
// Invokes InformHostOfCacheStats after a short delay. Used to move this
// bookkeeping operation off the critical latency path.
void InformHostOfCacheStatsLater();
- private:
- virtual void OnControlMessageReceived(const IPC::Message& msg);
+ MessageLoop* owner_loop() { return owner_loop_; }
+ // Indicates if RenderThread::Send() is on the call stack.
+ virtual bool InSend() const { return in_send_ != 0; }
+
+ protected:
// Called by the thread base class
virtual void Init();
virtual void CleanUp();
+ private:
void OnUpdateVisitedLinks(base::SharedMemoryHandle table);
void OnUpdateUserScripts(base::SharedMemoryHandle table);
@@ -125,6 +119,16 @@ class RenderThread : public RenderThreadBase,
// decisions about how to allocation resources using current information.
void InformHostOfCacheStats();
+ // The message loop used to run tasks on the thread that started this thread.
+ MessageLoop* owner_loop_;
+
+ // Used only on the background render thread to implement message routing
+ // functionality to the consumers of the RenderThread.
+ MessageRouter router_;
+
+ std::wstring channel_name_;
+ scoped_ptr<IPC::SyncChannel> channel_;
+
// These objects live solely on the render thread.
VisitedLinkSlave* visited_link_slave_;
UserScriptSlave* user_script_slave_;
@@ -135,7 +139,13 @@ class RenderThread : public RenderThreadBase,
scoped_ptr<NotificationService> notification_service_;
+ int in_send_;
+
DISALLOW_COPY_AND_ASSIGN(RenderThread);
};
+// The global RenderThread object for this process. Note that this should only
+// be accessed when running on the render thread itself.
+extern RenderThread* g_render_thread;
+
#endif // CHROME_RENDERER_RENDER_THREAD_H_