| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 #include "web/WorkerContentSettingsClient.h" | 73 #include "web/WorkerContentSettingsClient.h" |
| 74 #include "wtf/Functional.h" | 74 #include "wtf/Functional.h" |
| 75 #include "wtf/PtrUtil.h" | 75 #include "wtf/PtrUtil.h" |
| 76 #include <memory> | 76 #include <memory> |
| 77 | 77 |
| 78 namespace blink { | 78 namespace blink { |
| 79 | 79 |
| 80 WebEmbeddedWorker* WebEmbeddedWorker::create( | 80 WebEmbeddedWorker* WebEmbeddedWorker::create( |
| 81 WebServiceWorkerContextClient* client, | 81 WebServiceWorkerContextClient* client, |
| 82 WebWorkerContentSettingsClientProxy* contentSettingsClient) { | 82 WebWorkerContentSettingsClientProxy* contentSettingsClient) { |
| 83 return new WebEmbeddedWorkerImpl(wrapUnique(client), | 83 return new WebEmbeddedWorkerImpl(WTF::wrapUnique(client), |
| 84 wrapUnique(contentSettingsClient)); | 84 WTF::wrapUnique(contentSettingsClient)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 static HashSet<WebEmbeddedWorkerImpl*>& runningWorkerInstances() { | 87 static HashSet<WebEmbeddedWorkerImpl*>& runningWorkerInstances() { |
| 88 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ()); | 88 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ()); |
| 89 return set; | 89 return set; |
| 90 } | 90 } |
| 91 | 91 |
| 92 WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl( | 92 WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl( |
| 93 std::unique_ptr<WebServiceWorkerContextClient> client, | 93 std::unique_ptr<WebServiceWorkerContextClient> client, |
| 94 std::unique_ptr<WebWorkerContentSettingsClientProxy> contentSettingsClient) | 94 std::unique_ptr<WebWorkerContentSettingsClientProxy> contentSettingsClient) |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 | 332 |
| 333 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) { | 333 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) { |
| 334 DCHECK(!m_mainScriptLoader); | 334 DCHECK(!m_mainScriptLoader); |
| 335 DCHECK(!m_networkProvider); | 335 DCHECK(!m_networkProvider); |
| 336 DCHECK(m_mainFrame); | 336 DCHECK(m_mainFrame); |
| 337 DCHECK(m_workerContextClient); | 337 DCHECK(m_workerContextClient); |
| 338 DCHECK(m_loadingShadowPage); | 338 DCHECK(m_loadingShadowPage); |
| 339 DCHECK(!m_askedToTerminate); | 339 DCHECK(!m_askedToTerminate); |
| 340 m_loadingShadowPage = false; | 340 m_loadingShadowPage = false; |
| 341 m_networkProvider = | 341 m_networkProvider = |
| 342 wrapUnique(m_workerContextClient->createServiceWorkerNetworkProvider( | 342 WTF::wrapUnique(m_workerContextClient->createServiceWorkerNetworkProvider( |
| 343 frame->dataSource())); | 343 frame->dataSource())); |
| 344 m_mainScriptLoader = WorkerScriptLoader::create(); | 344 m_mainScriptLoader = WorkerScriptLoader::create(); |
| 345 m_mainScriptLoader->setRequestContext( | 345 m_mainScriptLoader->setRequestContext( |
| 346 WebURLRequest::RequestContextServiceWorker); | 346 WebURLRequest::RequestContextServiceWorker); |
| 347 m_mainScriptLoader->loadAsynchronously( | 347 m_mainScriptLoader->loadAsynchronously( |
| 348 *m_mainFrame->frame()->document(), m_workerStartData.scriptURL, | 348 *m_mainFrame->frame()->document(), m_workerStartData.scriptURL, |
| 349 DenyCrossOriginRequests, m_workerStartData.addressSpace, nullptr, | 349 DenyCrossOriginRequests, m_workerStartData.addressSpace, nullptr, |
| 350 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, | 350 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, |
| 351 WTF::unretained(this))); | 351 WTF::unretained(this))); |
| 352 // Do nothing here since onScriptLoaderFinished() might have been already | 352 // Do nothing here since onScriptLoaderFinished() might have been already |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 421 |
| 422 WorkerClients* workerClients = WorkerClients::create(); | 422 WorkerClients* workerClients = WorkerClients::create(); |
| 423 provideContentSettingsClientToWorker(workerClients, | 423 provideContentSettingsClientToWorker(workerClients, |
| 424 std::move(m_contentSettingsClient)); | 424 std::move(m_contentSettingsClient)); |
| 425 provideIndexedDBClientToWorker(workerClients, IndexedDBClientImpl::create()); | 425 provideIndexedDBClientToWorker(workerClients, IndexedDBClientImpl::create()); |
| 426 provideServiceWorkerGlobalScopeClientToWorker( | 426 provideServiceWorkerGlobalScopeClientToWorker( |
| 427 workerClients, | 427 workerClients, |
| 428 ServiceWorkerGlobalScopeClientImpl::create(*m_workerContextClient)); | 428 ServiceWorkerGlobalScopeClientImpl::create(*m_workerContextClient)); |
| 429 provideServiceWorkerContainerClientToWorker( | 429 provideServiceWorkerContainerClientToWorker( |
| 430 workerClients, | 430 workerClients, |
| 431 wrapUnique(m_workerContextClient->createServiceWorkerProvider())); | 431 WTF::wrapUnique(m_workerContextClient->createServiceWorkerProvider())); |
| 432 | 432 |
| 433 // We need to set the CSP to both the shadow page's document and the | 433 // We need to set the CSP to both the shadow page's document and the |
| 434 // ServiceWorkerGlobalScope. | 434 // ServiceWorkerGlobalScope. |
| 435 document->initContentSecurityPolicy( | 435 document->initContentSecurityPolicy( |
| 436 m_mainScriptLoader->releaseContentSecurityPolicy()); | 436 m_mainScriptLoader->releaseContentSecurityPolicy()); |
| 437 if (!m_mainScriptLoader->getReferrerPolicy().isNull()) { | 437 if (!m_mainScriptLoader->getReferrerPolicy().isNull()) { |
| 438 document->parseAndSetReferrerPolicy( | 438 document->parseAndSetReferrerPolicy( |
| 439 m_mainScriptLoader->getReferrerPolicy()); | 439 m_mainScriptLoader->getReferrerPolicy()); |
| 440 } | 440 } |
| 441 | 441 |
| 442 KURL scriptURL = m_mainScriptLoader->url(); | 442 KURL scriptURL = m_mainScriptLoader->url(); |
| 443 WorkerThreadStartMode startMode = | 443 WorkerThreadStartMode startMode = |
| 444 m_workerInspectorProxy->workerStartMode(document); | 444 m_workerInspectorProxy->workerStartMode(document); |
| 445 std::unique_ptr<WorkerSettings> workerSettings = | 445 std::unique_ptr<WorkerSettings> workerSettings = |
| 446 wrapUnique(new WorkerSettings(document->settings())); | 446 WTF::wrapUnique(new WorkerSettings(document->settings())); |
| 447 | 447 |
| 448 std::unique_ptr<WorkerThreadStartupData> startupData = | 448 std::unique_ptr<WorkerThreadStartupData> startupData = |
| 449 WorkerThreadStartupData::create( | 449 WorkerThreadStartupData::create( |
| 450 scriptURL, m_workerStartData.userAgent, m_mainScriptLoader->script(), | 450 scriptURL, m_workerStartData.userAgent, m_mainScriptLoader->script(), |
| 451 m_mainScriptLoader->releaseCachedMetadata(), startMode, | 451 m_mainScriptLoader->releaseCachedMetadata(), startMode, |
| 452 document->contentSecurityPolicy()->headers().get(), | 452 document->contentSecurityPolicy()->headers().get(), |
| 453 m_mainScriptLoader->getReferrerPolicy(), starterOrigin, workerClients, | 453 m_mainScriptLoader->getReferrerPolicy(), starterOrigin, workerClients, |
| 454 m_mainScriptLoader->responseAddressSpace(), | 454 m_mainScriptLoader->responseAddressSpace(), |
| 455 m_mainScriptLoader->originTrialTokens(), std::move(workerSettings), | 455 m_mainScriptLoader->originTrialTokens(), std::move(workerSettings), |
| 456 static_cast<V8CacheOptions>(m_workerStartData.v8CacheOptions)); | 456 static_cast<V8CacheOptions>(m_workerStartData.v8CacheOptions)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 467 *this, *document, *m_workerContextClient); | 467 *this, *document, *m_workerContextClient); |
| 468 m_loaderProxy = WorkerLoaderProxy::create(this); | 468 m_loaderProxy = WorkerLoaderProxy::create(this); |
| 469 m_workerThread = | 469 m_workerThread = |
| 470 ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalScopeProxy); | 470 ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalScopeProxy); |
| 471 m_workerThread->start(std::move(startupData)); | 471 m_workerThread->start(std::move(startupData)); |
| 472 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), | 472 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), |
| 473 scriptURL); | 473 scriptURL); |
| 474 } | 474 } |
| 475 | 475 |
| 476 } // namespace blink | 476 } // namespace blink |
| OLD | NEW |