| OLD | NEW |
| 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/appcache/appcache_dispatcher.h" | 8 #include "content/child/appcache/appcache_dispatcher.h" |
| 9 #include "content/child/appcache/web_application_cache_host_impl.h" | 9 #include "content/child/appcache/web_application_cache_host_impl.h" |
| 10 #include "content/child/request_extra_data.h" | 10 #include "content/child/request_extra_data.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 267 |
| 268 void EmbeddedSharedWorkerStub::ConnectToChannel( | 268 void EmbeddedSharedWorkerStub::ConnectToChannel( |
| 269 WebMessagePortChannelImpl* channel) { | 269 WebMessagePortChannelImpl* channel) { |
| 270 impl_->connect(channel); | 270 impl_->connect(channel); |
| 271 Send( | 271 Send( |
| 272 new WorkerHostMsg_WorkerConnected(channel->message_port_id(), route_id_)); | 272 new WorkerHostMsg_WorkerConnected(channel->message_port_id(), route_id_)); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void EmbeddedSharedWorkerStub::OnConnect(int sent_message_port_id, | 275 void EmbeddedSharedWorkerStub::OnConnect(int sent_message_port_id, |
| 276 int routing_id) { | 276 int routing_id) { |
| 277 TransferredMessagePort port; |
| 278 port.id = sent_message_port_id; |
| 277 WebMessagePortChannelImpl* channel = | 279 WebMessagePortChannelImpl* channel = |
| 278 new WebMessagePortChannelImpl(routing_id, | 280 new WebMessagePortChannelImpl(routing_id, |
| 279 sent_message_port_id, | 281 port, |
| 280 base::MessageLoopProxy::current().get()); | 282 base::MessageLoopProxy::current().get()); |
| 281 if (runing_) { | 283 if (runing_) { |
| 282 ConnectToChannel(channel); | 284 ConnectToChannel(channel); |
| 283 } else { | 285 } else { |
| 284 // If two documents try to load a SharedWorker at the same time, the | 286 // If two documents try to load a SharedWorker at the same time, the |
| 285 // WorkerMsg_Connect for one of the documents can come in before the | 287 // WorkerMsg_Connect for one of the documents can come in before the |
| 286 // worker is started. Just queue up the connect and deliver it once the | 288 // worker is started. Just queue up the connect and deliver it once the |
| 287 // worker starts. | 289 // worker starts. |
| 288 pending_channels_.push_back(channel); | 290 pending_channels_.push_back(channel); |
| 289 } | 291 } |
| 290 } | 292 } |
| 291 | 293 |
| 292 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { | 294 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { |
| 293 runing_ = false; | 295 runing_ = false; |
| 294 impl_->terminateWorkerContext(); | 296 impl_->terminateWorkerContext(); |
| 295 } | 297 } |
| 296 | 298 |
| 297 } // namespace content | 299 } // namespace content |
| OLD | NEW |