Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Unified Diff: chrome/worker/worker_thread.cc

Issue 126086: Switch child threads so that current() only works on the correct thread and t... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/worker/worker_thread.h ('k') | webkit/glue/webworker_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/worker/worker_thread.cc
===================================================================
--- chrome/worker/worker_thread.cc (revision 18344)
+++ chrome/worker/worker_thread.cc (working copy)
@@ -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::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 @@
}
ChildThread::CleanUp();
+ lazy_tls.Pointer()->Set(NULL);
}
void WorkerThread::OnControlMessageReceived(const IPC::Message& msg) {
« no previous file with comments | « chrome/worker/worker_thread.h ('k') | webkit/glue/webworker_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698