| Index: Source/core/workers/WorkerMessagingProxy.cpp
|
| diff --git a/Source/core/workers/WorkerMessagingProxy.cpp b/Source/core/workers/WorkerMessagingProxy.cpp
|
| index 2048ba78c9c9d01cab4edbe42731ceb6aa460d87..c8cef028fb4aa8158f29d69a64a8487ff812bcdd 100644
|
| --- a/Source/core/workers/WorkerMessagingProxy.cpp
|
| +++ b/Source/core/workers/WorkerMessagingProxy.cpp
|
| @@ -47,7 +47,7 @@
|
| #include "core/workers/WorkerClients.h"
|
| #include "core/workers/WorkerInspectorProxy.h"
|
| #include "core/workers/WorkerObjectProxy.h"
|
| -#include "core/workers/WorkerThreadStartupData.h"
|
| +#include "core/workers/WorkerScriptStartupData.h"
|
| #include "platform/heap/Handle.h"
|
| #include "wtf/Functional.h"
|
| #include "wtf/MainThread.h"
|
| @@ -72,14 +72,14 @@ WorkerMessagingProxy::WorkerMessagingProxy(InProcessWorkerBase* workerObject, Pa
|
| , m_workerObject(workerObject)
|
| , m_mayBeDestroyed(false)
|
| , m_unconfirmedMessageCount(0)
|
| - , m_workerThreadHadPendingActivity(false)
|
| + , m_workerScriptHadPendingActivity(false)
|
| , m_askedToTerminate(false)
|
| , m_workerInspectorProxy(WorkerInspectorProxy::create())
|
| , m_workerClients(workerClients)
|
| {
|
| ASSERT(m_workerObject);
|
| ASSERT((m_executionContext->isDocument() && isMainThread())
|
| - || (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_executionContext.get())->thread()->isCurrentThread()));
|
| + || (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_executionContext.get())->script()->isCurrentThread()));
|
| m_workerInspectorProxy->setWorkerGlobalScopeProxy(this);
|
| }
|
|
|
| @@ -87,7 +87,7 @@ WorkerMessagingProxy::~WorkerMessagingProxy()
|
| {
|
| ASSERT(!m_workerObject);
|
| ASSERT((m_executionContext->isDocument() && isMainThread())
|
| - || (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_executionContext.get())->thread()->isCurrentThread()));
|
| + || (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_executionContext.get())->script()->isCurrentThread()));
|
| if (m_loaderProxy)
|
| m_loaderProxy->detachProvider(this);
|
| }
|
| @@ -106,14 +106,14 @@ void WorkerMessagingProxy::startWorkerGlobalScope(const KURL& scriptURL, const S
|
| RefPtr<ContentSecurityPolicy> csp = m_workerObject->contentSecurityPolicy() ? m_workerObject->contentSecurityPolicy() : document->contentSecurityPolicy();
|
| ASSERT(csp);
|
|
|
| - OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::create(scriptURL, userAgent, sourceCode, nullptr, startMode, csp->deprecatedHeader(), csp->deprecatedHeaderType(), starterOrigin, m_workerClients.release());
|
| + OwnPtr<WorkerScriptStartupData> startupData = WorkerScriptStartupData::create(scriptURL, userAgent, sourceCode, nullptr, startMode, csp->deprecatedHeader(), csp->deprecatedHeaderType(), starterOrigin, m_workerClients.release());
|
| double originTime = document->loader() ? document->loader()->timing().referenceMonotonicTime() : monotonicallyIncreasingTime();
|
|
|
| m_loaderProxy = WorkerLoaderProxy::create(this);
|
| - RefPtr<WorkerThread> thread = createWorkerThread(originTime, startupData.release());
|
| - thread->start();
|
| - workerThreadCreated(thread);
|
| - m_workerInspectorProxy->workerThreadCreated(m_executionContext.get(), m_workerThread.get(), scriptURL);
|
| + RefPtr<WorkerScript> script = createWorkerScript(originTime, startupData.release());
|
| + script->start();
|
| + workerScriptCreated(script);
|
| + m_workerInspectorProxy->workerScriptCreated(m_executionContext.get(), m_workerScript.get(), scriptURL);
|
| }
|
|
|
| void WorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels)
|
| @@ -131,9 +131,9 @@ void WorkerMessagingProxy::postMessageToWorkerGlobalScope(PassRefPtr<SerializedS
|
| return;
|
|
|
| OwnPtr<ExecutionContextTask> task = createCrossThreadTask(&processMessageOnWorkerGlobalScope, message, channels, AllowCrossThreadAccess(&workerObjectProxy()));
|
| - if (m_workerThread) {
|
| + if (m_workerScript) {
|
| ++m_unconfirmedMessageCount;
|
| - m_workerThread->postTask(FROM_HERE, task.release());
|
| + m_workerScript->postTask(FROM_HERE, task.release());
|
| } else {
|
| m_queuedEarlyTasks.append(task.release());
|
| }
|
| @@ -144,8 +144,8 @@ bool WorkerMessagingProxy::postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionConte
|
| if (m_askedToTerminate)
|
| return false;
|
|
|
| - ASSERT(m_workerThread);
|
| - m_workerThread->postTask(FROM_HERE, task);
|
| + ASSERT(m_workerScript);
|
| + m_workerScript->postTask(FROM_HERE, task);
|
| return true;
|
| }
|
|
|
| @@ -167,7 +167,7 @@ void WorkerMessagingProxy::reportException(const String& errorMessage, int lineN
|
| RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, lineNumber, columnNumber, nullptr);
|
| bool errorHandled = !m_workerObject->dispatchEvent(event);
|
|
|
| - postTaskToWorkerGlobalScope(createCrossThreadTask(&WorkerGlobalScope::exceptionHandled, m_workerThread->workerGlobalScope(), exceptionId, errorHandled));
|
| + postTaskToWorkerGlobalScope(createCrossThreadTask(&WorkerGlobalScope::exceptionHandled, m_workerScript->workerGlobalScope(), exceptionId, errorHandled));
|
| }
|
|
|
| void WorkerMessagingProxy::reportConsoleMessage(MessageSource source, MessageLevel level, const String& message, int lineNumber, const String& sourceURL)
|
| @@ -186,17 +186,17 @@ void WorkerMessagingProxy::reportConsoleMessage(MessageSource source, MessageLev
|
| frame->console().addMessage(consoleMessage.release());
|
| }
|
|
|
| -void WorkerMessagingProxy::workerThreadCreated(PassRefPtr<WorkerThread> workerThread)
|
| +void WorkerMessagingProxy::workerScriptCreated(PassRefPtr<WorkerScript> workerScript)
|
| {
|
| ASSERT(!m_askedToTerminate);
|
| - m_workerThread = workerThread;
|
| + m_workerScript = workerScript;
|
|
|
| ASSERT(!m_unconfirmedMessageCount);
|
| m_unconfirmedMessageCount = m_queuedEarlyTasks.size();
|
| - m_workerThreadHadPendingActivity = true; // Worker initialization means a pending activity.
|
| + m_workerScriptHadPendingActivity = true; // Worker initialization means a pending activity.
|
|
|
| for (auto& earlyTasks : m_queuedEarlyTasks)
|
| - m_workerThread->postTask(FROM_HERE, earlyTasks.release());
|
| + m_workerScript->postTask(FROM_HERE, earlyTasks.release());
|
| m_queuedEarlyTasks.clear();
|
| }
|
|
|
| @@ -209,18 +209,18 @@ void WorkerMessagingProxy::workerObjectDestroyed()
|
| void WorkerMessagingProxy::workerObjectDestroyedInternal()
|
| {
|
| m_mayBeDestroyed = true;
|
| - if (m_workerThread)
|
| + if (m_workerScript)
|
| terminateWorkerGlobalScope();
|
| else
|
| - workerThreadTerminated();
|
| + workerScriptTerminated();
|
| }
|
|
|
| -void WorkerMessagingProxy::workerThreadTerminated()
|
| +void WorkerMessagingProxy::workerScriptTerminated()
|
| {
|
| // This method is always the last to be performed, so the proxy is not needed for communication
|
| // in either side any more. However, the Worker object may still exist, and it assumes that the proxy exists, too.
|
| m_askedToTerminate = true;
|
| - m_workerThread = nullptr;
|
| + m_workerScript = nullptr;
|
| terminateInternally();
|
| if (m_mayBeDestroyed)
|
| delete this;
|
| @@ -232,8 +232,8 @@ void WorkerMessagingProxy::terminateWorkerGlobalScope()
|
| return;
|
| m_askedToTerminate = true;
|
|
|
| - if (m_workerThread)
|
| - m_workerThread->stop();
|
| + if (m_workerScript)
|
| + m_workerScript->stop();
|
|
|
| terminateInternally();
|
| }
|
| @@ -272,17 +272,17 @@ void WorkerMessagingProxy::confirmMessageFromWorkerObject(bool hasPendingActivit
|
|
|
| void WorkerMessagingProxy::reportPendingActivity(bool hasPendingActivity)
|
| {
|
| - m_workerThreadHadPendingActivity = hasPendingActivity;
|
| + m_workerScriptHadPendingActivity = hasPendingActivity;
|
| }
|
|
|
| bool WorkerMessagingProxy::hasPendingActivity() const
|
| {
|
| - return (m_unconfirmedMessageCount || m_workerThreadHadPendingActivity) && !m_askedToTerminate;
|
| + return (m_unconfirmedMessageCount || m_workerScriptHadPendingActivity) && !m_askedToTerminate;
|
| }
|
|
|
| void WorkerMessagingProxy::terminateInternally()
|
| {
|
| - m_workerInspectorProxy->workerThreadTerminated();
|
| + m_workerInspectorProxy->workerScriptTerminated();
|
|
|
| // FIXME: This need to be revisited when we support nested worker one day
|
| ASSERT(m_executionContext->isDocument());
|
|
|