| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 return RenderThreadImpl::current()->Send(message); | 274 return RenderThreadImpl::current()->Send(message); |
| 275 } | 275 } |
| 276 | 276 |
| 277 void EmbeddedSharedWorkerStub::ConnectToChannel( | 277 void EmbeddedSharedWorkerStub::ConnectToChannel( |
| 278 WebMessagePortChannelImpl* channel) { | 278 WebMessagePortChannelImpl* channel) { |
| 279 impl_->connect(channel); | 279 impl_->connect(channel); |
| 280 Send( | 280 Send( |
| 281 new WorkerHostMsg_WorkerConnected(channel->message_port_id(), route_id_)); | 281 new WorkerHostMsg_WorkerConnected(channel->message_port_id(), route_id_)); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void EmbeddedSharedWorkerStub::OnConnect(int sent_message_port_id, | 284 void EmbeddedSharedWorkerStub::OnConnect(int port, |
| 285 int routing_id) { | 285 int routing_id) { |
| 286 TransferredMessagePort port; | |
| 287 port.id = sent_message_port_id; | |
| 288 WebMessagePortChannelImpl* channel = new WebMessagePortChannelImpl( | 286 WebMessagePortChannelImpl* channel = new WebMessagePortChannelImpl( |
| 289 routing_id, port, base::ThreadTaskRunnerHandle::Get().get()); | 287 routing_id, port, base::ThreadTaskRunnerHandle::Get().get()); |
| 290 if (running_) { | 288 if (running_) { |
| 291 ConnectToChannel(channel); | 289 ConnectToChannel(channel); |
| 292 } else { | 290 } else { |
| 293 // If two documents try to load a SharedWorker at the same time, the | 291 // If two documents try to load a SharedWorker at the same time, the |
| 294 // WorkerMsg_Connect for one of the documents can come in before the | 292 // WorkerMsg_Connect for one of the documents can come in before the |
| 295 // worker is started. Just queue up the connect and deliver it once the | 293 // worker is started. Just queue up the connect and deliver it once the |
| 296 // worker starts. | 294 // worker starts. |
| 297 pending_channels_.push_back(channel); | 295 pending_channels_.push_back(channel); |
| 298 } | 296 } |
| 299 } | 297 } |
| 300 | 298 |
| 301 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { | 299 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { |
| 302 // After this we wouldn't get any IPC for this stub. | 300 // After this we wouldn't get any IPC for this stub. |
| 303 running_ = false; | 301 running_ = false; |
| 304 impl_->terminateWorkerContext(); | 302 impl_->terminateWorkerContext(); |
| 305 } | 303 } |
| 306 | 304 |
| 307 } // namespace content | 305 } // namespace content |
| OLD | NEW |