void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, const String& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, JSC::RuntimeFlags runtimeFlags) { // FIXME: This need to be revisited when we support nested worker one day ASSERT(m_scriptExecutionContext); Document& document = downcast<Document>(*m_scriptExecutionContext); WorkerThreadStartMode startMode = m_inspectorProxy->workerStartMode(*m_scriptExecutionContext.get()); String identifier = m_inspectorProxy->identifier(); #if ENABLE(INDEXED_DATABASE) IDBClient::IDBConnectionProxy* proxy = document.idbConnectionProxy(); #else IDBClient::IDBConnectionProxy* proxy = nullptr; #endif #if ENABLE(WEB_SOCKETS) SocketProvider* socketProvider = document.socketProvider(); #else SocketProvider* socketProvider = nullptr; #endif auto thread = DedicatedWorkerThread::create(scriptURL, identifier, userAgent, sourceCode, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), proxy, socketProvider, runtimeFlags); workerThreadCreated(thread.get()); thread->start(); m_inspectorProxy->workerStarted(m_scriptExecutionContext.get(), thread.ptr(), scriptURL); }
void WorkerMessagingProxy::startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode) { RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, sourceCode, *this, *this, startMode, m_scriptExecutionContext->contentSecurityPolicy()->policy(), m_scriptExecutionContext->contentSecurityPolicy()->headerType()); workerThreadCreated(thread); thread->start(); InspectorInstrumentation::didStartWorkerContext(m_scriptExecutionContext.get(), this, scriptURL); }
void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode) { // FIXME: This need to be revisited when we support nested worker one day ASSERT_WITH_SECURITY_IMPLICATION(m_scriptExecutionContext->isDocument()); Document* document = static_cast<Document*>(m_scriptExecutionContext.get()); GroupSettings* settings = 0; if (document->page()) settings = &document->page()->group().groupSettings(); RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, settings, sourceCode, *this, *this, startMode, document->contentSecurityPolicy()->deprecatedHeader(), document->contentSecurityPolicy()->deprecatedHeaderType(), document->topOrigin()); workerThreadCreated(thread); thread->start(); InspectorInstrumentation::didStartWorkerGlobalScope(m_scriptExecutionContext.get(), this, scriptURL); }
void ThreadedMessagingProxyBase::initializeWorkerThread( std::unique_ptr<WorkerThreadStartupData> startupData) { DCHECK(isParentContextThread()); Document* document = toDocument(getExecutionContext()); double originTime = document->loader() ? document->loader()->timing().referenceMonotonicTime() : monotonicallyIncreasingTime(); m_loaderProxy = WorkerLoaderProxy::create(this); m_workerThread = createWorkerThread(originTime); m_workerThread->start(std::move(startupData)); workerThreadCreated(); }
void WorkerMessagingProxy::startWorkerGlobalScope(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode) { // FIXME: This need to be revisited when we support nested worker one day ASSERT(m_executionContext->isDocument()); Document* document = toDocument(m_executionContext.get()); OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::create(scriptURL, userAgent, sourceCode, startMode, document->contentSecurityPolicy()->deprecatedHeader(), document->contentSecurityPolicy()->deprecatedHeaderType(), m_workerClients.release()); double originTime = document->loader() ? document->loader()->timing()->referenceMonotonicTime() : monotonicallyIncreasingTime(); RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(*this, *m_workerObjectProxy.get(), originTime, startupData.release()); thread->start(); workerThreadCreated(thread); InspectorInstrumentation::didStartWorkerGlobalScope(m_executionContext.get(), this, scriptURL); }
InProcessWorkerMessagingProxyForTest(ExecutionContext* executionContext, BlinkGC::ThreadHeapMode threadHeapMode) : InProcessWorkerMessagingProxy(executionContext, nullptr /* workerObject */, nullptr /* workerClients */) { workerObjectProxy().m_defaultIntervalInSec = kDefaultIntervalInSec; workerObjectProxy().m_nextIntervalInSec = kNextIntervalInSec; workerObjectProxy().m_maxIntervalInSec = kMaxIntervalInSec; m_mockWorkerLoaderProxyProvider = wrapUnique(new MockWorkerLoaderProxyProvider()); m_workerThread = wrapUnique( new DedicatedWorkerThreadForTest(m_mockWorkerLoaderProxyProvider.get(), workerObjectProxy(), threadHeapMode)); workerThreadCreated(); m_mockWorkerThreadLifecycleObserver = new MockWorkerThreadLifecycleObserver( m_workerThread->getWorkerThreadLifecycleContext()); EXPECT_CALL(*m_mockWorkerThreadLifecycleObserver, contextDestroyed()) .Times(1); }
void WorkerMessagingProxy::startWorkerGlobalScope(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode) { // FIXME: This need to be revisited when we support nested worker one day ASSERT(m_executionContext->isDocument()); if (m_askedToTerminate) { // Worker.terminate() could be called from JS before the thread was created. return; } Document* document = toDocument(m_executionContext.get()); SecurityOrigin* starterOrigin = document->securityOrigin(); ContentSecurityPolicy* csp = m_workerObject->contentSecurityPolicy() ? m_workerObject->contentSecurityPolicy() : document->contentSecurityPolicy(); ASSERT(csp); OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::create(scriptURL, userAgent, sourceCode, nullptr, startMode, csp->headers(), starterOrigin, m_workerClients.release()); double originTime = document->loader() ? document->loader()->timing().referenceMonotonicTime() : monotonicallyIncreasingTime(); m_loaderProxy = WorkerLoaderProxy::create(this); RefPtr<WorkerThread> thread = createWorkerThread(originTime); thread->start(startupData.release()); workerThreadCreated(thread); m_workerInspectorProxy->workerThreadCreated(m_executionContext.get(), m_workerThread.get(), scriptURL); }
void WorkerMessagingProxy::startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode) { RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, sourceCode, *this, *this); workerThreadCreated(thread); thread->start(); }