| 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 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 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 <memory> |
| 33 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
| 34 #include "core/events/MessageEvent.h" | 35 #include "core/events/MessageEvent.h" |
| 35 #include "core/inspector/ConsoleMessage.h" | 36 #include "core/inspector/ConsoleMessage.h" |
| 36 #include "core/inspector/InspectorInstrumentation.h" | 37 #include "core/inspector/InspectorInstrumentation.h" |
| 37 #include "core/loader/FrameLoadRequest.h" | 38 #include "core/loader/FrameLoadRequest.h" |
| 38 #include "core/loader/FrameLoader.h" | 39 #include "core/loader/FrameLoader.h" |
| 40 #include "core/loader/ThreadableLoadingContext.h" |
| 39 #include "core/workers/ParentFrameTaskRunners.h" | 41 #include "core/workers/ParentFrameTaskRunners.h" |
| 40 #include "core/workers/SharedWorkerGlobalScope.h" | 42 #include "core/workers/SharedWorkerGlobalScope.h" |
| 41 #include "core/workers/SharedWorkerThread.h" | 43 #include "core/workers/SharedWorkerThread.h" |
| 42 #include "core/workers/WorkerClients.h" | 44 #include "core/workers/WorkerClients.h" |
| 43 #include "core/workers/WorkerGlobalScope.h" | 45 #include "core/workers/WorkerGlobalScope.h" |
| 44 #include "core/workers/WorkerInspectorProxy.h" | 46 #include "core/workers/WorkerInspectorProxy.h" |
| 45 #include "core/workers/WorkerLoaderProxy.h" | 47 #include "core/workers/WorkerLoaderProxy.h" |
| 46 #include "core/workers/WorkerScriptLoader.h" | 48 #include "core/workers/WorkerScriptLoader.h" |
| 47 #include "core/workers/WorkerThreadStartupData.h" | 49 #include "core/workers/WorkerThreadStartupData.h" |
| 48 #include "platform/CrossThreadFunctional.h" | 50 #include "platform/CrossThreadFunctional.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 63 #include "public/web/WebView.h" | 65 #include "public/web/WebView.h" |
| 64 #include "public/web/WebWorkerContentSettingsClientProxy.h" | 66 #include "public/web/WebWorkerContentSettingsClientProxy.h" |
| 65 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h" | 67 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h" |
| 66 #include "web/IndexedDBClientImpl.h" | 68 #include "web/IndexedDBClientImpl.h" |
| 67 #include "web/LocalFileSystemClient.h" | 69 #include "web/LocalFileSystemClient.h" |
| 68 #include "web/WebDataSourceImpl.h" | 70 #include "web/WebDataSourceImpl.h" |
| 69 #include "web/WebLocalFrameImpl.h" | 71 #include "web/WebLocalFrameImpl.h" |
| 70 #include "web/WorkerContentSettingsClient.h" | 72 #include "web/WorkerContentSettingsClient.h" |
| 71 #include "wtf/Functional.h" | 73 #include "wtf/Functional.h" |
| 72 #include "wtf/PtrUtil.h" | 74 #include "wtf/PtrUtil.h" |
| 73 #include <memory> | |
| 74 | 75 |
| 75 namespace blink { | 76 namespace blink { |
| 76 | 77 |
| 77 // TODO(toyoshim): Share implementation with WebEmbeddedWorkerImpl as much as | 78 // TODO(toyoshim): Share implementation with WebEmbeddedWorkerImpl as much as |
| 78 // possible. | 79 // possible. |
| 79 | 80 |
| 80 WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client) | 81 WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client) |
| 81 : m_webView(nullptr), | 82 : m_webView(nullptr), |
| 82 m_mainFrame(nullptr), | 83 m_mainFrame(nullptr), |
| 83 m_askedToTerminate(false), | 84 m_askedToTerminate(false), |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 ->postTask(FROM_HERE, std::move(task)); | 270 ->postTask(FROM_HERE, std::move(task)); |
| 270 } | 271 } |
| 271 | 272 |
| 272 void WebSharedWorkerImpl::postTaskToWorkerGlobalScope( | 273 void WebSharedWorkerImpl::postTaskToWorkerGlobalScope( |
| 273 const WebTraceLocation& location, | 274 const WebTraceLocation& location, |
| 274 std::unique_ptr<WTF::CrossThreadClosure> task) { | 275 std::unique_ptr<WTF::CrossThreadClosure> task) { |
| 275 DCHECK(isMainThread()); | 276 DCHECK(isMainThread()); |
| 276 m_workerThread->postTask(location, std::move(task)); | 277 m_workerThread->postTask(location, std::move(task)); |
| 277 } | 278 } |
| 278 | 279 |
| 279 ExecutionContext* WebSharedWorkerImpl::getLoaderExecutionContext() { | 280 ThreadableLoadingContext* WebSharedWorkerImpl::getThreadableLoadingContext() { |
| 280 DCHECK(isMainThread()); | 281 if (!m_loadingContext) { |
| 281 return m_loadingDocument.get(); | 282 m_loadingContext = |
| 283 ThreadableLoadingContext::create(*toDocument(m_loadingDocument.get())); |
| 284 } |
| 285 return m_loadingContext; |
| 282 } | 286 } |
| 283 | 287 |
| 284 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) { | 288 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) { |
| 285 DCHECK(isMainThread()); | 289 DCHECK(isMainThread()); |
| 286 workerThread()->postTask( | 290 workerThread()->postTask( |
| 287 BLINK_FROM_HERE, | 291 BLINK_FROM_HERE, |
| 288 crossThreadBind(&WebSharedWorkerImpl::connectTaskOnWorkerThread, | 292 crossThreadBind(&WebSharedWorkerImpl::connectTaskOnWorkerThread, |
| 289 WTF::crossThreadUnretained(this), | 293 WTF::crossThreadUnretained(this), |
| 290 WTF::passed(WebMessagePortChannelUniquePtr(webChannel)))); | 294 WTF::passed(WebMessagePortChannelUniquePtr(webChannel)))); |
| 291 } | 295 } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 if (devtoolsAgent) | 440 if (devtoolsAgent) |
| 437 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, | 441 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, |
| 438 message); | 442 message); |
| 439 } | 443 } |
| 440 | 444 |
| 441 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) { | 445 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) { |
| 442 return new WebSharedWorkerImpl(client); | 446 return new WebSharedWorkerImpl(client); |
| 443 } | 447 } |
| 444 | 448 |
| 445 } // namespace blink | 449 } // namespace blink |
| OLD | NEW |