Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10603)

Unified Diff: chrome/renderer/webworker_proxy.cc

Issue 151125: Fix the GC of workers. When Worker object is GC'ed in the renderer, we need t... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/webworker_proxy.h ('k') | webkit/glue/webworker_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/webworker_proxy.cc
===================================================================
--- chrome/renderer/webworker_proxy.cc (revision 19506)
+++ chrome/renderer/webworker_proxy.cc (working copy)
@@ -25,15 +25,26 @@
}
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::terminateWorkerContext() {
if (route_id_ != MSG_ROUTING_NONE) {
Send(new WorkerMsg_TerminateWorkerContext(route_id_));
- child_thread_->RemoveRoute(route_id_);
- route_id_ = MSG_ROUTING_NONE;
+ Disconnect();
}
}
« no previous file with comments | « chrome/renderer/webworker_proxy.h ('k') | webkit/glue/webworker_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698