diff options
author | dimich@google.com <dimich@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-07 17:08:33 +0000 |
---|---|---|
committer | dimich@google.com <dimich@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-07 17:08:33 +0000 |
commit | ce190ab7ea2b0838f756cf50fcd6ec6fb5b98b51 (patch) | |
tree | cacacb7f6c32eb9b23c70e09cfa0f0f94a72aed3 /chrome/renderer/webworker_proxy.cc | |
parent | d1259e8b2e5d83dbf3f4c12ff64f609f1b67cfeb (diff) | |
download | chromium_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 'chrome/renderer/webworker_proxy.cc')
-rw-r--r-- | chrome/renderer/webworker_proxy.cc | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/chrome/renderer/webworker_proxy.cc b/chrome/renderer/webworker_proxy.cc index 6cec8cc..b013aa9 100644 --- a/chrome/renderer/webworker_proxy.cc +++ b/chrome/renderer/webworker_proxy.cc @@ -25,15 +25,26 @@ WebWorkerProxy::WebWorkerProxy( } WebWorkerProxy::~WebWorkerProxy() { - if (queued_messages_.empty()) - return; + Disconnect(); for (size_t i = 0; i < queued_messages_.size(); ++i) delete queued_messages_[i]; +} + +void WebWorkerProxy::Disconnect() { + if (route_id_ == MSG_ROUTING_NONE) + return; + + // So the messages from WorkerContext (like WorkerContextDestroyed) do not + // come after nobody is listening. Since Worker and WorkerContext can + // terminate independently, already sent messages may still be in the pipe. + child_thread_->RemoveRoute(route_id_); // Tell the browser to not start our queued worker. - if (route_id_ != MSG_ROUTING_NONE) + if (!queued_messages_.empty()) child_thread_->Send(new ViewHostMsg_CancelCreateDedicatedWorker(route_id_)); + + route_id_ = MSG_ROUTING_NONE; } void WebWorkerProxy::startWorkerContext( @@ -57,8 +68,7 @@ void WebWorkerProxy::startWorkerContext( void WebWorkerProxy::terminateWorkerContext() { if (route_id_ != MSG_ROUTING_NONE) { Send(new WorkerMsg_TerminateWorkerContext(route_id_)); - child_thread_->RemoveRoute(route_id_); - route_id_ = MSG_ROUTING_NONE; + Disconnect(); } } |