Index: webkit/glue/webworker_impl.cc |
=================================================================== |
--- webkit/glue/webworker_impl.cc (revision 19506) |
+++ webkit/glue/webworker_impl.cc (working copy) |
@@ -117,7 +117,8 @@ |
WebWorkerImpl::WebWorkerImpl(WebWorkerClient* client) |
: client_(client), |
- web_view_(NULL) { |
+ web_view_(NULL), |
+ asked_to_terminate_(false) { |
InitializeWebKitStaticValues(); |
} |
@@ -184,6 +185,10 @@ |
} |
void WebWorkerImpl::terminateWorkerContext() { |
+ if (asked_to_terminate_) |
+ return; |
+ asked_to_terminate_ = true; |
+ |
if (worker_thread_) |
worker_thread_->stop(); |
} |
@@ -196,6 +201,11 @@ |
} |
void WebWorkerImpl::workerObjectDestroyed() { |
+ // Worker object in the renderer was destroyed, perhaps a result of GC. |
+ // For us, it's a signal to start terminating the WorkerContext too. |
+ // TODO(dimich): when 'kill a worker' html5 spec algorithm is implemented, it |
+ // should be used here instead of 'terminate a worker'. |
+ terminateWorkerContext(); |
} |
void WebWorkerImpl::DispatchTaskToMainThread( |