Commit 12a2c498 authored by kinuko@chromium.org's avatar kinuko@chromium.org

Clear EmbeddedWorkerContextClient's thread-local ptr in willDestroyWorkerContext()

Back then EmbeddedWorkerContextClient used to be destroyed on the worker
thread when corresponding WorkerGlobalScope's destructed, but after
http://crrev.com/262813004 we started to destruct it on main thread
(after the worker side termination), so resetting thread-local ptr in
the dtor doesn't work (as it runs on main thread).

This change clears the thread-local ptr in willDestroyWorkerContext(),
where we're sure we're still on the worker thread.

BUG=n/a

Review URL: https://codereview.chromium.org/287193011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272487 0039d316-1c4b-4281-b951-d872f2087c98
parent 3aa775f9
......@@ -97,9 +97,6 @@ EmbeddedWorkerContextClient::EmbeddedWorkerContextClient(
}
EmbeddedWorkerContextClient::~EmbeddedWorkerContextClient() {
// g_worker_client_tls.Pointer()->Get() could be NULL if this gets
// deleted before workerContextStarted() is called.
g_worker_client_tls.Pointer()->Set(NULL);
}
bool EmbeddedWorkerContextClient::OnMessageReceived(
......@@ -143,6 +140,8 @@ void EmbeddedWorkerContextClient::workerContextStarted(
worker_task_runner_ = new WorkerThreadTaskRunner(
WorkerTaskRunner::Instance()->CurrentWorkerId());
DCHECK_NE(0, WorkerTaskRunner::Instance()->CurrentWorkerId());
// g_worker_client_tls.Pointer()->Get() could return NULL if this context
// gets deleted before workerContextStarted() is called.
DCHECK(g_worker_client_tls.Pointer()->Get() == NULL);
DCHECK(!script_context_);
g_worker_client_tls.Pointer()->Set(this);
......@@ -164,9 +163,15 @@ void EmbeddedWorkerContextClient::willDestroyWorkerContext() {
// worker_task_runner_->RunsTasksOnCurrentThread() returns false
// (while we're still on the worker thread).
script_context_.reset();
// This also lets the message filter stop dispatching messages to
// this client.
g_worker_client_tls.Pointer()->Set(NULL);
}
void EmbeddedWorkerContextClient::workerContextDestroyed() {
DCHECK(g_worker_client_tls.Pointer()->Get() == NULL);
// Now we should be able to free the WebEmbeddedWorker container on the
// main thread.
main_thread_proxy_->PostTask(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment