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

Side by Side Diff: content/renderer/shared_worker/embedded_shared_worker_stub.cc

Issue 189413014: Send WorkerHostMsg_WorkerConnected in EmbeddedSharedWorkerStub::OnConnect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporated kinuko's comment Created 6 years, 9 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 unified diff | Download patch
« no previous file with comments | « content/renderer/shared_worker/embedded_shared_worker_stub.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" 5 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h"
6 6
7 #include "base/message_loop/message_loop_proxy.h" 7 #include "base/message_loop/message_loop_proxy.h"
8 #include "content/child/scoped_child_process_reference.h" 8 #include "content/child/scoped_child_process_reference.h"
9 #include "content/child/shared_worker_devtools_agent.h" 9 #include "content/child/shared_worker_devtools_agent.h"
10 #include "content/child/webmessageportchannel_impl.h" 10 #include "content/child/webmessageportchannel_impl.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 OnTerminateWorkerContext(); 56 OnTerminateWorkerContext();
57 } 57 }
58 58
59 void EmbeddedSharedWorkerStub::workerScriptLoaded() { 59 void EmbeddedSharedWorkerStub::workerScriptLoaded() {
60 Send(new WorkerHostMsg_WorkerScriptLoaded(route_id_)); 60 Send(new WorkerHostMsg_WorkerScriptLoaded(route_id_));
61 runing_ = true; 61 runing_ = true;
62 // Process any pending connections. 62 // Process any pending connections.
63 for (PendingChannelList::const_iterator iter = pending_channels_.begin(); 63 for (PendingChannelList::const_iterator iter = pending_channels_.begin();
64 iter != pending_channels_.end(); 64 iter != pending_channels_.end();
65 ++iter) { 65 ++iter) {
66 impl_->connect(*iter); 66 ConnectToChannel(*iter);
67 Send(new WorkerHostMsg_WorkerConnected((*iter)->message_port_id(),
68 route_id_));
69 } 67 }
70 pending_channels_.clear(); 68 pending_channels_.clear();
71 } 69 }
72 70
73 void EmbeddedSharedWorkerStub::workerScriptLoadFailed() { 71 void EmbeddedSharedWorkerStub::workerScriptLoadFailed() {
74 Send(new WorkerHostMsg_WorkerScriptLoadFailed(route_id_)); 72 Send(new WorkerHostMsg_WorkerScriptLoadFailed(route_id_));
75 for (PendingChannelList::const_iterator iter = pending_channels_.begin(); 73 for (PendingChannelList::const_iterator iter = pending_channels_.begin();
76 iter != pending_channels_.end(); 74 iter != pending_channels_.end();
77 ++iter) { 75 ++iter) {
78 blink::WebMessagePortChannel* channel = *iter; 76 blink::WebMessagePortChannel* channel = *iter;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 125 }
128 126
129 void EmbeddedSharedWorkerStub::Shutdown() { 127 void EmbeddedSharedWorkerStub::Shutdown() {
130 delete this; 128 delete this;
131 } 129 }
132 130
133 bool EmbeddedSharedWorkerStub::Send(IPC::Message* message) { 131 bool EmbeddedSharedWorkerStub::Send(IPC::Message* message) {
134 return RenderThreadImpl::current()->Send(message); 132 return RenderThreadImpl::current()->Send(message);
135 } 133 }
136 134
135 void EmbeddedSharedWorkerStub::ConnectToChannel(
136 WebMessagePortChannelImpl* channel) {
137 impl_->connect(channel);
138 Send(
139 new WorkerHostMsg_WorkerConnected(channel->message_port_id(), route_id_));
140 }
141
137 void EmbeddedSharedWorkerStub::OnConnect(int sent_message_port_id, 142 void EmbeddedSharedWorkerStub::OnConnect(int sent_message_port_id,
138 int routing_id) { 143 int routing_id) {
139 WebMessagePortChannelImpl* channel = 144 WebMessagePortChannelImpl* channel =
140 new WebMessagePortChannelImpl(routing_id, 145 new WebMessagePortChannelImpl(routing_id,
141 sent_message_port_id, 146 sent_message_port_id,
142 base::MessageLoopProxy::current().get()); 147 base::MessageLoopProxy::current().get());
143 if (runing_) { 148 if (runing_) {
144 impl_->connect(channel); 149 ConnectToChannel(channel);
145 } else { 150 } else {
146 // If two documents try to load a SharedWorker at the same time, the 151 // If two documents try to load a SharedWorker at the same time, the
147 // WorkerMsg_Connect for one of the documents can come in before the 152 // WorkerMsg_Connect for one of the documents can come in before the
148 // worker is started. Just queue up the connect and deliver it once the 153 // worker is started. Just queue up the connect and deliver it once the
149 // worker starts. 154 // worker starts.
150 pending_channels_.push_back(channel); 155 pending_channels_.push_back(channel);
151 } 156 }
152 } 157 }
153 158
154 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { 159 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() {
155 runing_ = false; 160 runing_ = false;
156 impl_->terminateWorkerContext(); 161 impl_->terminateWorkerContext();
157 } 162 }
158 163
159 } // namespace content 164 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/shared_worker/embedded_shared_worker_stub.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698