summaryrefslogtreecommitdiffstats
path: root/chrome/worker/worker_thread.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/worker/worker_thread.cc')
-rw-r--r--chrome/worker/worker_thread.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/chrome/worker/worker_thread.cc b/chrome/worker/worker_thread.cc
index 8f3aebf..a6db89d 100644
--- a/chrome/worker/worker_thread.cc
+++ b/chrome/worker/worker_thread.cc
@@ -4,11 +4,17 @@
#include "chrome/worker/worker_thread.h"
+#include "base/lazy_instance.h"
+#include "base/thread_local.h"
#include "chrome/common/worker_messages.h"
#include "chrome/worker/webworkerclient_proxy.h"
#include "chrome/worker/worker_webkitclient_impl.h"
#include "webkit/api/public/WebKit.h"
+static base::LazyInstance<base::ThreadLocalPointer<WorkerThread> > lazy_tls(
+ base::LINKER_INITIALIZED);
+
+
WorkerThread::WorkerThread()
: ChildThread(base::Thread::Options(MessageLoop::TYPE_DEFAULT,
kV8StackSize)) {
@@ -17,7 +23,12 @@ WorkerThread::WorkerThread()
WorkerThread::~WorkerThread() {
}
+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());
@@ -35,6 +46,7 @@ void WorkerThread::CleanUp() {
}
ChildThread::CleanUp();
+ lazy_tls.Pointer()->Set(NULL);
}
void WorkerThread::OnControlMessageReceived(const IPC::Message& msg) {