summaryrefslogtreecommitdiffstats
path: root/chrome/worker
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/worker')
-rw-r--r--chrome/worker/worker_main.cc7
-rw-r--r--chrome/worker/worker_thread.cc29
-rw-r--r--chrome/worker/worker_thread.h5
3 files changed, 30 insertions, 11 deletions
diff --git a/chrome/worker/worker_main.cc b/chrome/worker/worker_main.cc
index d6304ab..03831b8b 100644
--- a/chrome/worker/worker_main.cc
+++ b/chrome/worker/worker_main.cc
@@ -20,16 +20,15 @@
// Mainline routine for running as the worker process.
int WorkerMain(const MainFunctionParams& parameters) {
- // The main message loop of the worker process.
- MessageLoop main_message_loop;
+ // The main thread of the render process.
+ MessageLoopForIO 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;
- worker_process.set_main_thread(new WorkerThread());
+ ChildProcess worker_process(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 e4be0b9..7663b7a 100644
--- a/chrome/worker/worker_thread.cc
+++ b/chrome/worker/worker_thread.cc
@@ -15,22 +15,37 @@ static base::LazyInstance<base::ThreadLocalPointer<WorkerThread> > lazy_tls(
base::LINKER_INITIALIZED);
-WorkerThread::WorkerThread() {
- lazy_tls.Pointer()->Set(this);
- webkit_client_.reset(new WorkerWebKitClientImpl);
- WebKit::initialize(webkit_client_.get());
+WorkerThread::WorkerThread()
+ : ChildThread(base::Thread::Options(MessageLoop::TYPE_DEFAULT,
+ kV8StackSize)) {
}
WorkerThread::~WorkerThread() {
- // Shutdown in reverse of the initialization order.
- WebKit::shutdown();
- lazy_tls.Pointer()->Set(NULL);
}
WorkerThread* WorkerThread::current() {
return lazy_tls.Pointer()->Get();
}
+void WorkerThread::Init() {
+ lazy_tls.Pointer()->Set(this);
+ ChildThread::Init();
+ webkit_client_.reset(new WorkerWebKitClientImpl);
+ WebKit::initialize(webkit_client_.get());
+}
+
+void WorkerThread::CleanUp() {
+ // Shutdown in reverse of the initialization order.
+
+ if (webkit_client_.get()) {
+ WebKit::shutdown();
+ webkit_client_.reset();
+ }
+
+ ChildThread::CleanUp();
+ lazy_tls.Pointer()->Set(NULL);
+}
+
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 27d0abf..6bea33c 100644
--- a/chrome/worker/worker_thread.h
+++ b/chrome/worker/worker_thread.h
@@ -5,6 +5,7 @@
#ifndef CHROME_WORKER_WORKER_THREAD_H_
#define CHROME_WORKER_WORKER_THREAD_H_
+#include "base/thread.h"
#include "chrome/common/child_thread.h"
class GURL;
@@ -21,6 +22,10 @@ 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_;