Index: content/worker/websharedworker_stub.cc |
diff --git a/content/worker/websharedworker_stub.cc b/content/worker/websharedworker_stub.cc |
index a2471df4a04783b8213ad403983d47297ce583fa..435c1dc1a58060b749fcf88eb6d666148a2bc449 100644 |
--- a/content/worker/websharedworker_stub.cc |
+++ b/content/worker/websharedworker_stub.cc |
@@ -27,6 +27,7 @@ WebSharedWorkerStub::WebSharedWorkerStub( |
: route_id_(route_id), |
client_(route_id, this), |
running_(false), |
+ terminating_(false), |
url_(url) { |
WorkerThread* worker_thread = WorkerThread::current(); |
@@ -102,15 +103,22 @@ void WebSharedWorkerStub::OnConnect(int sent_message_port_id, int routing_id) { |
} |
void WebSharedWorkerStub::OnTerminateWorkerContext() { |
- impl_->terminateWorkerContext(); |
- |
- // Call the client to make sure context exits. |
- EnsureWorkerContextTerminates(); |
- running_ = false; |
+ if (running_) { |
+ impl_->terminateWorkerContext(); |
kinuko
2014/02/19 04:24:08
It feels like we should always nullify the impl_ a
horo
2014/02/19 05:29:09
The bug is caused by "delete this" in Shutdown() w
|
+ // Call the client to make sure context exits. |
+ EnsureWorkerContextTerminates(); |
+ running_ = false; |
+ } else { |
+ terminating_ = true; |
+ } |
} |
void WebSharedWorkerStub::WorkerScriptLoaded() { |
running_ = true; |
+ if (terminating_) { |
+ OnTerminateWorkerContext(); |
+ return; |
+ } |
// Process any pending connections. |
for (PendingChannelList::const_iterator iter = pending_channels_.begin(); |
iter != pending_channels_.end(); |