| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 wrapCrossThreadWeakPersistent(m_loadingDocument.get()))); | 315 wrapCrossThreadWeakPersistent(m_loadingDocument.get()))); |
| 316 } | 316 } |
| 317 | 317 |
| 318 void WebSharedWorkerImpl::postTaskToWorkerGlobalScope( | 318 void WebSharedWorkerImpl::postTaskToWorkerGlobalScope( |
| 319 const WebTraceLocation& location, | 319 const WebTraceLocation& location, |
| 320 std::unique_ptr<WTF::CrossThreadClosure> task) { | 320 std::unique_ptr<WTF::CrossThreadClosure> task) { |
| 321 m_workerThread->postTask(location, std::move(task)); | 321 m_workerThread->postTask(location, std::move(task)); |
| 322 } | 322 } |
| 323 | 323 |
| 324 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) { | 324 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) { |
| 325 DCHECK(isMainThread()); |
| 325 workerThread()->postTask( | 326 workerThread()->postTask( |
| 326 BLINK_FROM_HERE, | 327 BLINK_FROM_HERE, |
| 327 createCrossThreadTask( | 328 crossThreadBind(&WebSharedWorkerImpl::connectTask, |
| 328 &connectTask, | 329 WTF::crossThreadUnretained(this), |
| 329 WTF::passed(WebMessagePortChannelUniquePtr(webChannel)))); | 330 WTF::passed(WebMessagePortChannelUniquePtr(webChannel)))); |
| 330 } | 331 } |
| 331 | 332 |
| 332 void WebSharedWorkerImpl::connectTask(WebMessagePortChannelUniquePtr channel, | 333 void WebSharedWorkerImpl::connectTask(WebMessagePortChannelUniquePtr channel) { |
| 333 ExecutionContext* context) { | |
| 334 // Wrap the passed-in channel in a MessagePort, and send it off via a connect | 334 // Wrap the passed-in channel in a MessagePort, and send it off via a connect |
| 335 // event. | 335 // event. |
| 336 MessagePort* port = MessagePort::create(*context); | 336 DCHECK(m_workerThread->isCurrentThread()); |
| 337 WorkerGlobalScope* workerGlobalScope = |
| 338 toWorkerGlobalScope(m_workerThread->globalScope()); |
| 339 MessagePort* port = MessagePort::create(*workerGlobalScope); |
| 337 port->entangle(std::move(channel)); | 340 port->entangle(std::move(channel)); |
| 338 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); | |
| 339 SECURITY_DCHECK(workerGlobalScope->isSharedWorkerGlobalScope()); | 341 SECURITY_DCHECK(workerGlobalScope->isSharedWorkerGlobalScope()); |
| 340 workerGlobalScope->dispatchEvent(createConnectEvent(port)); | 342 workerGlobalScope->dispatchEvent(createConnectEvent(port)); |
| 341 } | 343 } |
| 342 | 344 |
| 343 void WebSharedWorkerImpl::startWorkerContext( | 345 void WebSharedWorkerImpl::startWorkerContext( |
| 344 const WebURL& url, | 346 const WebURL& url, |
| 345 const WebString& name, | 347 const WebString& name, |
| 346 const WebString& contentSecurityPolicy, | 348 const WebString& contentSecurityPolicy, |
| 347 WebContentSecurityPolicyType policyType, | 349 WebContentSecurityPolicyType policyType, |
| 348 WebAddressSpace creationAddressSpace) { | 350 WebAddressSpace creationAddressSpace) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 if (devtoolsAgent) | 468 if (devtoolsAgent) |
| 467 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, | 469 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, |
| 468 message); | 470 message); |
| 469 } | 471 } |
| 470 | 472 |
| 471 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) { | 473 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) { |
| 472 return new WebSharedWorkerImpl(client); | 474 return new WebSharedWorkerImpl(client); |
| 473 } | 475 } |
| 474 | 476 |
| 475 } // namespace blink | 477 } // namespace blink |
| OLD | NEW |