| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "web/WebSharedWorkerImpl.h" | 31 #include "web/WebSharedWorkerImpl.h" |
| 32 | 32 |
| 33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
| 34 #include "core/dom/ExecutionContextTask.h" | |
| 35 #include "core/events/MessageEvent.h" | 34 #include "core/events/MessageEvent.h" |
| 36 #include "core/html/HTMLFormElement.h" | 35 #include "core/html/HTMLFormElement.h" |
| 37 #include "core/inspector/ConsoleMessage.h" | 36 #include "core/inspector/ConsoleMessage.h" |
| 38 #include "core/inspector/InspectorInstrumentation.h" | 37 #include "core/inspector/InspectorInstrumentation.h" |
| 39 #include "core/loader/FrameLoadRequest.h" | 38 #include "core/loader/FrameLoadRequest.h" |
| 40 #include "core/loader/FrameLoader.h" | 39 #include "core/loader/FrameLoader.h" |
| 41 #include "core/page/Page.h" | 40 #include "core/page/Page.h" |
| 42 #include "core/workers/ParentFrameTaskRunners.h" | 41 #include "core/workers/ParentFrameTaskRunners.h" |
| 43 #include "core/workers/SharedWorkerGlobalScope.h" | 42 #include "core/workers/SharedWorkerGlobalScope.h" |
| 44 #include "core/workers/SharedWorkerThread.h" | 43 #include "core/workers/SharedWorkerThread.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 void WebSharedWorkerImpl::didTerminateWorkerThreadOnMainThread() { | 295 void WebSharedWorkerImpl::didTerminateWorkerThreadOnMainThread() { |
| 297 m_client->workerContextDestroyed(); | 296 m_client->workerContextDestroyed(); |
| 298 // The lifetime of this proxy is controlled by the worker context. | 297 // The lifetime of this proxy is controlled by the worker context. |
| 299 delete this; | 298 delete this; |
| 300 } | 299 } |
| 301 | 300 |
| 302 // WorkerLoaderProxyProvider ------------------------------------------------- | 301 // WorkerLoaderProxyProvider ------------------------------------------------- |
| 303 | 302 |
| 304 void WebSharedWorkerImpl::postTaskToLoader( | 303 void WebSharedWorkerImpl::postTaskToLoader( |
| 305 const WebTraceLocation& location, | 304 const WebTraceLocation& location, |
| 306 std::unique_ptr<ExecutionContextTask> task) { | 305 std::unique_ptr<WTF::CrossThreadClosure> task) { |
| 307 m_parentFrameTaskRunners->get(TaskType::Networking) | 306 m_parentFrameTaskRunners->get(TaskType::Networking) |
| 308 ->postTask(FROM_HERE, | 307 ->postTask(FROM_HERE, std::move(task)); |
| 309 crossThreadBind( | |
| 310 &ExecutionContextTask::performTaskIfContextIsValid, | |
| 311 WTF::passed(std::move(task)), | |
| 312 wrapCrossThreadWeakPersistent(m_loadingDocument.get()))); | |
| 313 } | 308 } |
| 314 | 309 |
| 315 void WebSharedWorkerImpl::postTaskToWorkerGlobalScope( | 310 void WebSharedWorkerImpl::postTaskToWorkerGlobalScope( |
| 316 const WebTraceLocation& location, | 311 const WebTraceLocation& location, |
| 317 std::unique_ptr<WTF::CrossThreadClosure> task) { | 312 std::unique_ptr<WTF::CrossThreadClosure> task) { |
| 318 m_workerThread->postTask(location, std::move(task)); | 313 m_workerThread->postTask(location, std::move(task)); |
| 319 } | 314 } |
| 320 | 315 |
| 316 ExecutionContext* WebSharedWorkerImpl::getLoaderExecutionContext() { |
| 317 return m_loadingDocument.get(); |
| 318 } |
| 319 |
| 321 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) { | 320 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) { |
| 322 DCHECK(isMainThread()); | 321 DCHECK(isMainThread()); |
| 323 workerThread()->postTask( | 322 workerThread()->postTask( |
| 324 BLINK_FROM_HERE, | 323 BLINK_FROM_HERE, |
| 325 crossThreadBind(&WebSharedWorkerImpl::connectTask, | 324 crossThreadBind(&WebSharedWorkerImpl::connectTask, |
| 326 WTF::crossThreadUnretained(this), | 325 WTF::crossThreadUnretained(this), |
| 327 WTF::passed(WebMessagePortChannelUniquePtr(webChannel)))); | 326 WTF::passed(WebMessagePortChannelUniquePtr(webChannel)))); |
| 328 } | 327 } |
| 329 | 328 |
| 330 void WebSharedWorkerImpl::connectTask(WebMessagePortChannelUniquePtr channel) { | 329 void WebSharedWorkerImpl::connectTask(WebMessagePortChannelUniquePtr channel) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 if (devtoolsAgent) | 465 if (devtoolsAgent) |
| 467 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, | 466 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, |
| 468 message); | 467 message); |
| 469 } | 468 } |
| 470 | 469 |
| 471 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) { | 470 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) { |
| 472 return new WebSharedWorkerImpl(client); | 471 return new WebSharedWorkerImpl(client); |
| 473 } | 472 } |
| 474 | 473 |
| 475 } // namespace blink | 474 } // namespace blink |
| OLD | NEW |