| 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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 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->referrerPolicy().isNull()) | 437 if (!m_mainScriptLoader->getReferrerPolicy().isNull()) { |
| 438 document->parseAndSetReferrerPolicy(m_mainScriptLoader->referrerPolicy()); | 438 document->parseAndSetReferrerPolicy( |
| 439 m_mainScriptLoader->getReferrerPolicy()); |
| 440 } |
| 439 | 441 |
| 440 KURL scriptURL = m_mainScriptLoader->url(); | 442 KURL scriptURL = m_mainScriptLoader->url(); |
| 441 WorkerThreadStartMode startMode = | 443 WorkerThreadStartMode startMode = |
| 442 m_workerInspectorProxy->workerStartMode(document); | 444 m_workerInspectorProxy->workerStartMode(document); |
| 443 std::unique_ptr<WorkerSettings> workerSettings = | 445 std::unique_ptr<WorkerSettings> workerSettings = |
| 444 wrapUnique(new WorkerSettings(document->settings())); | 446 wrapUnique(new WorkerSettings(document->settings())); |
| 445 | 447 |
| 446 std::unique_ptr<WorkerThreadStartupData> startupData = | 448 std::unique_ptr<WorkerThreadStartupData> startupData = |
| 447 WorkerThreadStartupData::create( | 449 WorkerThreadStartupData::create( |
| 448 scriptURL, m_workerStartData.userAgent, m_mainScriptLoader->script(), | 450 scriptURL, m_workerStartData.userAgent, m_mainScriptLoader->script(), |
| 449 m_mainScriptLoader->releaseCachedMetadata(), startMode, | 451 m_mainScriptLoader->releaseCachedMetadata(), startMode, |
| 450 document->contentSecurityPolicy()->headers().get(), | 452 document->contentSecurityPolicy()->headers().get(), |
| 451 m_mainScriptLoader->referrerPolicy(), starterOrigin, workerClients, | 453 m_mainScriptLoader->getReferrerPolicy(), starterOrigin, workerClients, |
| 452 m_mainScriptLoader->responseAddressSpace(), | 454 m_mainScriptLoader->responseAddressSpace(), |
| 453 m_mainScriptLoader->originTrialTokens(), std::move(workerSettings), | 455 m_mainScriptLoader->originTrialTokens(), std::move(workerSettings), |
| 454 static_cast<V8CacheOptions>(m_workerStartData.v8CacheOptions)); | 456 static_cast<V8CacheOptions>(m_workerStartData.v8CacheOptions)); |
| 455 | 457 |
| 456 m_mainScriptLoader.clear(); | 458 m_mainScriptLoader.clear(); |
| 457 | 459 |
| 458 // We have a dummy document here for loading but it doesn't really represent | 460 // We have a dummy document here for loading but it doesn't really represent |
| 459 // the document/frame of associated document(s) for this worker. Here we | 461 // the document/frame of associated document(s) for this worker. Here we |
| 460 // populate the task runners with null document not to confuse the frame | 462 // populate the task runners with null document not to confuse the frame |
| 461 // scheduler (which will end up using the thread's default task runner). | 463 // scheduler (which will end up using the thread's default task runner). |
| 462 m_mainThreadTaskRunners = ParentFrameTaskRunners::create(nullptr); | 464 m_mainThreadTaskRunners = ParentFrameTaskRunners::create(nullptr); |
| 463 | 465 |
| 464 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create( | 466 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create( |
| 465 *this, *document, *m_workerContextClient); | 467 *this, *document, *m_workerContextClient); |
| 466 m_loaderProxy = WorkerLoaderProxy::create(this); | 468 m_loaderProxy = WorkerLoaderProxy::create(this); |
| 467 m_workerThread = | 469 m_workerThread = |
| 468 ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalScopeProxy); | 470 ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalScopeProxy); |
| 469 m_workerThread->start(std::move(startupData)); | 471 m_workerThread->start(std::move(startupData)); |
| 470 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), | 472 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), |
| 471 scriptURL); | 473 scriptURL); |
| 472 } | 474 } |
| 473 | 475 |
| 474 } // namespace blink | 476 } // namespace blink |
| OLD | NEW |