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

Unified Diff: chrome/renderer/websharedworker_proxy.cc

Issue 372047: Fixed worker startup issue (Closed)
Patch Set: Removed tests to a separate patch. Created 11 years, 1 month 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
Index: chrome/renderer/websharedworker_proxy.cc
diff --git a/chrome/renderer/websharedworker_proxy.cc b/chrome/renderer/websharedworker_proxy.cc
index c0ecba4c46b1bdd844db3ae616f553a3ed18d709..dbb47a46a90c57787daebb989e54f8cce32315c6 100644
--- a/chrome/renderer/websharedworker_proxy.cc
+++ b/chrome/renderer/websharedworker_proxy.cc
@@ -12,7 +12,8 @@
WebSharedWorkerProxy::WebSharedWorkerProxy(ChildThread* child_thread,
int route_id,
int render_view_route_id)
- : WebWorkerBase(child_thread, route_id, render_view_route_id) {
+ : WebWorkerBase(child_thread, route_id, render_view_route_id),
+ m_connectListener(NULL) {
}
bool WebSharedWorkerProxy::isStarted() {
@@ -37,7 +38,8 @@ void WebSharedWorkerProxy::clientDestroyed() {
NOTREACHED();
}
-void WebSharedWorkerProxy::connect(WebKit::WebMessagePortChannel* channel) {
+void WebSharedWorkerProxy::connect(WebKit::WebMessagePortChannel* channel,
+ ConnectListener* listener) {
WebMessagePortChannelImpl* webchannel =
static_cast<WebMessagePortChannelImpl*>(channel);
@@ -46,6 +48,13 @@ void WebSharedWorkerProxy::connect(WebKit::WebMessagePortChannel* channel) {
webchannel->QueueMessages();
Send(new WorkerMsg_Connect(route_id_, message_port_id, MSG_ROUTING_NONE));
+ if (HasQueuedMessages()) {
+ m_connectListener = listener;
+ } else {
+ // The listener may free this object, so do not access the object after
+ // this point.
+ listener->connected();
+ }
}
void WebSharedWorkerProxy::OnMessageReceived(const IPC::Message& message) {
@@ -58,5 +67,11 @@ void WebSharedWorkerProxy::OnWorkerCreated() {
// The worker is created - now send off the CreateWorkerContext message and
// any other queued messages
SendQueuedMessages();
+
+ // Inform any listener that the pending connect event has been sent
+ // (this can result in this object being freed).
+ if (m_connectListener) {
+ m_connectListener->connected();
jam 2009/11/09 02:53:03 nit: chrome style is not to use brace brackets for
+ }
}

Powered by Google App Engine
This is Rietveld 408576698