summaryrefslogtreecommitdiffstats
path: root/chrome/common/child_thread.h
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 00:25:06 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 00:25:06 +0000
commitf784592cd075d7866c74e410833768c8b6f9b622 (patch)
tree8512d6dc402faef8df803c7ff07ba5b77eecda3f /chrome/common/child_thread.h
parenta63f220009f90657fc1070d4a9bde26726deb6b4 (diff)
downloadchromium_src-f784592cd075d7866c74e410833768c8b6f9b622.zip
chromium_src-f784592cd075d7866c74e410833768c8b6f9b622.tar.gz
chromium_src-f784592cd075d7866c74e410833768c8b6f9b622.tar.bz2
Switch the first thread in a child process to be the main thread, and make theIO thread be the second thread. The change is needed for plugins on mac.
Review URL: http://codereview.chromium.org/155944 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21355 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/child_thread.h')
-rw-r--r--chrome/common/child_thread.h45
1 files changed, 16 insertions, 29 deletions
diff --git a/chrome/common/child_thread.h b/chrome/common/child_thread.h
index 1affe25..91ea9b7 100644
--- a/chrome/common/child_thread.h
+++ b/chrome/common/child_thread.h
@@ -7,18 +7,20 @@
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
-#include "base/thread.h"
#include "chrome/common/message_router.h"
#include "chrome/common/resource_dispatcher.h"
#include "ipc/ipc_sync_channel.h"
-// Child processes's background thread should derive from this class.
+class NotificationService;
+
+// The main thread of a child process derives from this class.
class ChildThread : public IPC::Channel::Listener,
- public IPC::Message::Sender,
- public base::Thread {
+ public IPC::Message::Sender {
public:
// Creates the thread.
- ChildThread(Thread::Options options);
+ ChildThread();
+ // Used for single-process mode.
+ ChildThread(const std::string channel_name);
virtual ~ChildThread();
// IPC::Message::Sender implementation:
@@ -28,58 +30,39 @@ class ChildThread : public IPC::Channel::Listener,
void AddRoute(int32 routing_id, IPC::Channel::Listener* listener);
void RemoveRoute(int32 routing_id);
- MessageLoop* owner_loop() { return owner_loop_; }
-
ResourceDispatcher* resource_dispatcher() {
return resource_dispatcher_.get();
}
+ MessageLoop* message_loop() { return message_loop_; }
+
// Returns the one child thread.
static ChildThread* current();
protected:
friend class ChildProcess;
- // Starts the thread.
- bool Run();
-
- // Overrides the channel name. Used for --single-process mode.
- void SetChannelName(const std::string& name) { channel_name_ = name; }
-
// Called when the process refcount is 0.
void OnProcessFinalRelease();
- protected:
- // The required stack size if V8 runs on a thread.
- static const size_t kV8StackSize;
-
virtual void OnControlMessageReceived(const IPC::Message& msg) { }
IPC::SyncChannel* channel() { return channel_.get(); }
- // Thread implementation.
- virtual void Init();
- virtual void CleanUp();
-
private:
+ void Init();
+
// IPC::Channel::Listener implementation:
virtual void OnMessageReceived(const IPC::Message& msg);
virtual void OnChannelError();
- // The message loop used to run tasks on the thread that started this thread.
- MessageLoop* owner_loop_;
-
std::string channel_name_;
scoped_ptr<IPC::SyncChannel> channel_;
- // Used only on the background render thread to implement message routing
- // functionality to the consumers of the ChildThread.
+ // Implements message routing functionality to the consumers of ChildThread.
MessageRouter router_;
- Thread::Options options_;
-
// Handles resource loads for this process.
- // NOTE: this object lives on the owner thread.
scoped_ptr<ResourceDispatcher> resource_dispatcher_;
// If true, checks with the browser process before shutdown. This avoids race
@@ -87,6 +70,10 @@ class ChildThread : public IPC::Channel::Listener,
// that would addref it.
bool check_with_browser_before_shutdown_;
+ MessageLoop* message_loop_;
+
+ scoped_ptr<NotificationService> notification_service_;
+
DISALLOW_COPY_AND_ASSIGN(ChildThread);
};