OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 20 matching lines...) Expand all Loading... |
31 #include "web/WebEmbeddedWorkerImpl.h" | 31 #include "web/WebEmbeddedWorkerImpl.h" |
32 | 32 |
33 #include <memory> | 33 #include <memory> |
34 #include "bindings/core/v8/SourceLocation.h" | 34 #include "bindings/core/v8/SourceLocation.h" |
35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
36 #include "core/dom/SecurityContext.h" | 36 #include "core/dom/SecurityContext.h" |
37 #include "core/frame/csp/ContentSecurityPolicy.h" | 37 #include "core/frame/csp/ContentSecurityPolicy.h" |
38 #include "core/inspector/ConsoleMessage.h" | 38 #include "core/inspector/ConsoleMessage.h" |
39 #include "core/loader/FrameLoadRequest.h" | 39 #include "core/loader/FrameLoadRequest.h" |
40 #include "core/loader/ThreadableLoadingContext.h" | 40 #include "core/loader/ThreadableLoadingContext.h" |
| 41 #include "core/loader/WorkerFetchContext.h" |
41 #include "core/probe/CoreProbes.h" | 42 #include "core/probe/CoreProbes.h" |
42 #include "core/workers/ParentFrameTaskRunners.h" | 43 #include "core/workers/ParentFrameTaskRunners.h" |
43 #include "core/workers/WorkerClients.h" | 44 #include "core/workers/WorkerClients.h" |
44 #include "core/workers/WorkerGlobalScope.h" | 45 #include "core/workers/WorkerGlobalScope.h" |
45 #include "core/workers/WorkerInspectorProxy.h" | 46 #include "core/workers/WorkerInspectorProxy.h" |
46 #include "core/workers/WorkerLoaderProxy.h" | 47 #include "core/workers/WorkerLoaderProxy.h" |
47 #include "core/workers/WorkerScriptLoader.h" | 48 #include "core/workers/WorkerScriptLoader.h" |
48 #include "core/workers/WorkerThreadStartupData.h" | 49 #include "core/workers/WorkerThreadStartupData.h" |
49 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" | 50 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" |
50 #include "modules/serviceworkers/ServiceWorkerThread.h" | 51 #include "modules/serviceworkers/ServiceWorkerThread.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 SharedBuffer::create(content.data(), content.length())); | 327 SharedBuffer::create(content.data(), content.length())); |
327 m_loadingShadowPage = true; | 328 m_loadingShadowPage = true; |
328 m_mainFrame->frame()->loader().load( | 329 m_mainFrame->frame()->loader().load( |
329 FrameLoadRequest(0, ResourceRequest(m_workerStartData.scriptURL), | 330 FrameLoadRequest(0, ResourceRequest(m_workerStartData.scriptURL), |
330 SubstituteData(buffer, "text/html", "UTF-8", KURL()))); | 331 SubstituteData(buffer, "text/html", "UTF-8", KURL()))); |
331 } | 332 } |
332 | 333 |
333 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) { | 334 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) { |
334 DCHECK_EQ(frame, m_mainFrame); | 335 DCHECK_EQ(frame, m_mainFrame); |
335 DCHECK(!m_mainScriptLoader); | 336 DCHECK(!m_mainScriptLoader); |
| 337 DCHECK(!m_webWorkerFetchContextInfo); |
336 DCHECK(m_mainFrame); | 338 DCHECK(m_mainFrame); |
337 DCHECK(m_workerContextClient); | 339 DCHECK(m_workerContextClient); |
338 DCHECK(m_loadingShadowPage); | 340 DCHECK(m_loadingShadowPage); |
339 DCHECK(!m_askedToTerminate); | 341 DCHECK(!m_askedToTerminate); |
340 m_loadingShadowPage = false; | 342 m_loadingShadowPage = false; |
341 frame->dataSource()->setServiceWorkerNetworkProvider(WTF::wrapUnique( | 343 frame->dataSource()->setServiceWorkerNetworkProvider(WTF::wrapUnique( |
342 m_workerContextClient->createServiceWorkerNetworkProvider())); | 344 m_workerContextClient->createServiceWorkerNetworkProvider())); |
| 345 m_webWorkerFetchContextInfo = WTF::wrapUnique( |
| 346 m_workerContextClient->createServiceWorkerFetchContextInfo()); |
343 m_mainScriptLoader = WorkerScriptLoader::create(); | 347 m_mainScriptLoader = WorkerScriptLoader::create(); |
344 m_mainScriptLoader->setRequestContext( | 348 m_mainScriptLoader->setRequestContext( |
345 WebURLRequest::RequestContextServiceWorker); | 349 WebURLRequest::RequestContextServiceWorker); |
346 m_mainScriptLoader->loadAsynchronously( | 350 m_mainScriptLoader->loadAsynchronously( |
347 *m_mainFrame->frame()->document(), m_workerStartData.scriptURL, | 351 *m_mainFrame->frame()->document(), m_workerStartData.scriptURL, |
348 DenyCrossOriginRequests, m_workerStartData.addressSpace, nullptr, | 352 DenyCrossOriginRequests, m_workerStartData.addressSpace, nullptr, |
349 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, | 353 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, |
350 WTF::unretained(this))); | 354 WTF::unretained(this))); |
351 // Do nothing here since onScriptLoaderFinished() might have been already | 355 // Do nothing here since onScriptLoaderFinished() might have been already |
352 // invoked and |this| might have been deleted at this point. | 356 // invoked and |this| might have been deleted at this point. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 std::move(m_contentSettingsClient)); | 427 std::move(m_contentSettingsClient)); |
424 provideIndexedDBClientToWorker(workerClients, | 428 provideIndexedDBClientToWorker(workerClients, |
425 IndexedDBClientImpl::create(*workerClients)); | 429 IndexedDBClientImpl::create(*workerClients)); |
426 provideServiceWorkerGlobalScopeClientToWorker( | 430 provideServiceWorkerGlobalScopeClientToWorker( |
427 workerClients, | 431 workerClients, |
428 ServiceWorkerGlobalScopeClientImpl::create(*m_workerContextClient)); | 432 ServiceWorkerGlobalScopeClientImpl::create(*m_workerContextClient)); |
429 provideServiceWorkerContainerClientToWorker( | 433 provideServiceWorkerContainerClientToWorker( |
430 workerClients, | 434 workerClients, |
431 WTF::wrapUnique(m_workerContextClient->createServiceWorkerProvider())); | 435 WTF::wrapUnique(m_workerContextClient->createServiceWorkerProvider())); |
432 | 436 |
| 437 // |m_webWorkerFetchContextInfo| is null if off-main-thread-fetch is disabled. |
| 438 if (m_webWorkerFetchContextInfo) { |
| 439 provideWorkerFetchContextInfoToWorker( |
| 440 workerClients, std::move(m_webWorkerFetchContextInfo)); |
| 441 WorkerFetchContextInfo* workerFetchContextInfo = |
| 442 WorkerFetchContextInfo::from(*workerClients); |
| 443 workerFetchContextInfo->setDataSaverEnabled( |
| 444 document->frame()->settings()->getDataSaverEnabled()); |
| 445 } |
| 446 |
433 // We need to set the CSP to both the shadow page's document and the | 447 // We need to set the CSP to both the shadow page's document and the |
434 // ServiceWorkerGlobalScope. | 448 // ServiceWorkerGlobalScope. |
435 document->initContentSecurityPolicy( | 449 document->initContentSecurityPolicy( |
436 m_mainScriptLoader->releaseContentSecurityPolicy()); | 450 m_mainScriptLoader->releaseContentSecurityPolicy()); |
437 if (!m_mainScriptLoader->getReferrerPolicy().isNull()) { | 451 if (!m_mainScriptLoader->getReferrerPolicy().isNull()) { |
438 document->parseAndSetReferrerPolicy( | 452 document->parseAndSetReferrerPolicy( |
439 m_mainScriptLoader->getReferrerPolicy()); | 453 m_mainScriptLoader->getReferrerPolicy()); |
440 } | 454 } |
441 | 455 |
442 KURL scriptURL = m_mainScriptLoader->url(); | 456 KURL scriptURL = m_mainScriptLoader->url(); |
(...skipping 28 matching lines...) Expand all Loading... |
471 *this, *document, *m_workerContextClient); | 485 *this, *document, *m_workerContextClient); |
472 m_loaderProxy = WorkerLoaderProxy::create(this); | 486 m_loaderProxy = WorkerLoaderProxy::create(this); |
473 m_workerThread = | 487 m_workerThread = |
474 ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalScopeProxy); | 488 ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalScopeProxy); |
475 m_workerThread->start(std::move(startupData), m_mainThreadTaskRunners.get()); | 489 m_workerThread->start(std::move(startupData), m_mainThreadTaskRunners.get()); |
476 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), | 490 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), |
477 scriptURL); | 491 scriptURL); |
478 } | 492 } |
479 | 493 |
480 } // namespace blink | 494 } // namespace blink |
OLD | NEW |