summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordimich@google.com <dimich@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 17:08:33 +0000
committerdimich@google.com <dimich@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 17:08:33 +0000
commitce190ab7ea2b0838f756cf50fcd6ec6fb5b98b51 (patch)
treecacacb7f6c32eb9b23c70e09cfa0f0f94a72aed3 /webkit
parentd1259e8b2e5d83dbf3f4c12ff64f609f1b67cfeb (diff)
downloadchromium_src-ce190ab7ea2b0838f756cf50fcd6ec6fb5b98b51.zip
chromium_src-ce190ab7ea2b0838f756cf50fcd6ec6fb5b98b51.tar.gz
chromium_src-ce190ab7ea2b0838f756cf50fcd6ec6fb5b98b51.tar.bz2
Fix the GC of workers. When Worker object is GC'ed in the renderer, we need to terminate the worker process.
BUG=15647, 15759 TEST=new ui_test is part of this CL Review URL: http://codereview.chromium.org/151125 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20034 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/webworker_impl.cc12
-rw-r--r--webkit/glue/webworker_impl.h1
2 files changed, 12 insertions, 1 deletions
diff --git a/webkit/glue/webworker_impl.cc b/webkit/glue/webworker_impl.cc
index 65131d5..625f0d8 100644
--- a/webkit/glue/webworker_impl.cc
+++ b/webkit/glue/webworker_impl.cc
@@ -119,7 +119,8 @@ void InitializeWebKitStaticValues() {
WebWorkerImpl::WebWorkerImpl(WebWorkerClient* client)
: client_(client),
- web_view_(NULL) {
+ web_view_(NULL),
+ asked_to_terminate_(false) {
InitializeWebKitStaticValues();
}
@@ -193,6 +194,10 @@ void WebWorkerImpl::startWorkerContext(const WebURL& script_url,
}
void WebWorkerImpl::terminateWorkerContext() {
+ if (asked_to_terminate_)
+ return;
+ asked_to_terminate_ = true;
+
if (worker_thread_)
worker_thread_->stop();
}
@@ -207,6 +212,11 @@ void WebWorkerImpl::postMessageToWorkerContext(const WebString& message) {
}
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(
diff --git a/webkit/glue/webworker_impl.h b/webkit/glue/webworker_impl.h
index 6f083b6..f7daf42 100644
--- a/webkit/glue/webworker_impl.h
+++ b/webkit/glue/webworker_impl.h
@@ -125,6 +125,7 @@ class WebWorkerImpl: public WebCore::WorkerObjectProxy,
// 'shadow page' - created to proxy loading requests from the worker.
WTF::RefPtr<WebCore::ScriptExecutionContext> loading_document_;
WebView* web_view_;
+ bool asked_to_terminate_;
WTF::RefPtr<WebCore::WorkerThread> worker_thread_;