diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 00:25:06 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 00:25:06 +0000 |
commit | f784592cd075d7866c74e410833768c8b6f9b622 (patch) | |
tree | 8512d6dc402faef8df803c7ff07ba5b77eecda3f /chrome/worker | |
parent | a63f220009f90657fc1070d4a9bde26726deb6b4 (diff) | |
download | chromium_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/worker')
-rw-r--r-- | chrome/worker/worker_main.cc | 7 | ||||
-rw-r--r-- | chrome/worker/worker_thread.cc | 29 | ||||
-rw-r--r-- | chrome/worker/worker_thread.h | 5 |
3 files changed, 11 insertions, 30 deletions
diff --git a/chrome/worker/worker_main.cc b/chrome/worker/worker_main.cc index 03831b8b..d6304ab 100644 --- a/chrome/worker/worker_main.cc +++ b/chrome/worker/worker_main.cc @@ -20,15 +20,16 @@ // Mainline routine for running as the worker process. int WorkerMain(const MainFunctionParams& parameters) { - // The main thread of the render process. - MessageLoopForIO main_message_loop; + // The main message loop of the worker process. + MessageLoop main_message_loop; std::wstring app_name = chrome::kBrowserAppName; PlatformThread::SetName(WideToASCII(app_name + L"_WorkerMain").c_str()); // Initialize the SystemMonitor base::SystemMonitor::Start(); - ChildProcess worker_process(new WorkerThread()); + ChildProcess worker_process; + worker_process.set_main_thread(new WorkerThread()); #if defined(OS_WIN) sandbox::TargetServices* target_services = parameters.sandbox_info_.TargetServices(); diff --git a/chrome/worker/worker_thread.cc b/chrome/worker/worker_thread.cc index 7663b7a..e4be0b9 100644 --- a/chrome/worker/worker_thread.cc +++ b/chrome/worker/worker_thread.cc @@ -15,37 +15,22 @@ static base::LazyInstance<base::ThreadLocalPointer<WorkerThread> > lazy_tls( base::LINKER_INITIALIZED); -WorkerThread::WorkerThread() - : ChildThread(base::Thread::Options(MessageLoop::TYPE_DEFAULT, - kV8StackSize)) { -} - -WorkerThread::~WorkerThread() { -} - -WorkerThread* WorkerThread::current() { - return lazy_tls.Pointer()->Get(); -} - -void WorkerThread::Init() { +WorkerThread::WorkerThread() { lazy_tls.Pointer()->Set(this); - ChildThread::Init(); webkit_client_.reset(new WorkerWebKitClientImpl); WebKit::initialize(webkit_client_.get()); } -void WorkerThread::CleanUp() { +WorkerThread::~WorkerThread() { // Shutdown in reverse of the initialization order. - - if (webkit_client_.get()) { - WebKit::shutdown(); - webkit_client_.reset(); - } - - ChildThread::CleanUp(); + WebKit::shutdown(); lazy_tls.Pointer()->Set(NULL); } +WorkerThread* WorkerThread::current() { + return lazy_tls.Pointer()->Get(); +} + void WorkerThread::OnControlMessageReceived(const IPC::Message& msg) { IPC_BEGIN_MESSAGE_MAP(WorkerThread, msg) IPC_MESSAGE_HANDLER(WorkerProcessMsg_CreateWorker, OnCreateWorker) diff --git a/chrome/worker/worker_thread.h b/chrome/worker/worker_thread.h index 6bea33c..27d0abf 100644 --- a/chrome/worker/worker_thread.h +++ b/chrome/worker/worker_thread.h @@ -5,7 +5,6 @@ #ifndef CHROME_WORKER_WORKER_THREAD_H_ #define CHROME_WORKER_WORKER_THREAD_H_ -#include "base/thread.h" #include "chrome/common/child_thread.h" class GURL; @@ -22,10 +21,6 @@ class WorkerThread : public ChildThread { private: virtual void OnControlMessageReceived(const IPC::Message& msg); - // Called by the thread base class - virtual void Init(); - virtual void CleanUp(); - void OnCreateWorker(const GURL& url, int route_id); scoped_ptr<WorkerWebKitClientImpl> webkit_client_; |