void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString& name, const WebString& userAgent, const WebString& sourceCode, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType policyType, long long) { initializeLoader(url); WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerContextOnStart : DontPauseWorkerContextOnStart; setWorkerThread(SharedWorkerThread::create(name, url, userAgent, sourceCode, *this, *this, startMode, contentSecurityPolicy, static_cast<WebCore::ContentSecurityPolicy::HeaderType>(policyType))); workerThread()->start(); }
void WebWorkerImpl::startWorkerContext(const WebURL& scriptUrl, const WebString& userAgent, const WebString& sourceCode) { initializeLoader(scriptUrl); setWorkerThread(DedicatedWorkerThread::create(scriptUrl, userAgent, sourceCode, *this, *this)); // Worker initialization means a pending activity. reportPendingActivity(true); workerThread()->start(); }
void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString& name, const WebString& userAgent, const WebString& sourceCode, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType policyType, long long) { initializeLoader(url); WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerGlobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart; OwnPtr<WorkerClients> workerClients = WorkerClients::create(); provideLocalFileSystemToWorker(workerClients.get(), WorkerFileSystemClient::create()); OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::create(url, userAgent, sourceCode, startMode, contentSecurityPolicy, static_cast<WebCore::ContentSecurityPolicy::HeaderType>(policyType), workerClients.release()); setWorkerThread(SharedWorkerThread::create(name, *this, *this, startupData.release())); workerThread()->start(); }
void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString& name, const WebString& userAgent, const WebString& sourceCode, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType policyType, long long) { initializeLoader(url); WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerContextOnStart : DontPauseWorkerContextOnStart; ASSERT(m_loadingDocument->isDocument()); Document* document = static_cast<Document*>(m_loadingDocument.get()); GroupSettings* settings = 0; if (document->page()) settings = document->page()->group().groupSettings(); setWorkerThread(SharedWorkerThread::create(name, url, userAgent, settings, sourceCode, *this, *this, startMode, contentSecurityPolicy, static_cast<WebCore::ContentSecurityPolicy::HeaderType>(policyType))); workerThread()->start(); }
void WebSharedWorkerImpl::onScriptLoaderFinished() { ASSERT(m_loadingDocument); ASSERT(m_mainScriptLoader); if (m_askedToTerminate) return; if (m_mainScriptLoader->failed()) { m_mainScriptLoader->cancel(); m_client->workerScriptLoadFailed(); // The SharedWorker was unable to load the initial script, so // shut it down right here. delete this; return; } Document* document = m_mainFrame->frame()->document(); WorkerThreadStartMode startMode = DontPauseWorkerGlobalScopeOnStart; if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(document)) startMode = PauseWorkerGlobalScopeOnStart; // FIXME: this document's origin is pristine and without any extra privileges. (crbug.com/254993) SecurityOrigin* starterOrigin = document->securityOrigin(); OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::create()); WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); provideContentSettingsClientToWorker(workerClients.get(), adoptPtr(m_client->createWorkerContentSettingsClientProxy(webSecurityOrigin))); RefPtrWillBeRawPtr<ContentSecurityPolicy> contentSecurityPolicy = m_mainScriptLoader->releaseContentSecurityPolicy(); OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::create( m_url, m_loadingDocument->userAgent(), m_mainScriptLoader->script(), nullptr, startMode, contentSecurityPolicy ? contentSecurityPolicy->headers() : nullptr, starterOrigin, workerClients.release()); m_loaderProxy = WorkerLoaderProxy::create(this); setWorkerThread(SharedWorkerThread::create(m_name, m_loaderProxy, *this)); InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScriptLoader->identifier(), m_mainScriptLoader->script()); m_mainScriptLoader.clear(); workerThread()->start(startupData.release()); m_workerInspectorProxy->workerThreadCreated(m_loadingDocument.get(), workerThread(), m_url); m_client->workerScriptLoaded(); }