| Index: Source/core/workers/Worker.cpp
|
| diff --git a/Source/core/workers/Worker.cpp b/Source/core/workers/Worker.cpp
|
| index ecd92b8c72e6de8a877ebdadb624cb6a9bb5b87d..d4607c6566cdcdc9cea078400cbec3dddb4fbd34 100644
|
| --- a/Source/core/workers/Worker.cpp
|
| +++ b/Source/core/workers/Worker.cpp
|
| @@ -58,21 +58,10 @@ PassRefPtrWillBeRawPtr<Worker> Worker::create(ExecutionContext* context, const S
|
| exceptionState.throwDOMException(InvalidAccessError, "The context provided is invalid.");
|
| return nullptr;
|
| }
|
| - WorkerGlobalScopeProxyProvider* proxyProvider = WorkerGlobalScopeProxyProvider::from(*document->page());
|
| - ASSERT(proxyProvider);
|
| -
|
| RefPtrWillBeRawPtr<Worker> worker = adoptRefWillBeNoop(new Worker(context));
|
| -
|
| - worker->suspendIfNeeded();
|
| -
|
| - KURL scriptURL = worker->resolveURL(url, exceptionState);
|
| - if (scriptURL.isEmpty())
|
| - return nullptr;
|
| -
|
| - worker->m_scriptLoader = WorkerScriptLoader::create();
|
| - worker->m_scriptLoader->loadAsynchronously(*context, scriptURL, DenyCrossOriginRequests, worker.get());
|
| - worker->m_contextProxy = proxyProvider->createWorkerGlobalScopeProxy(worker.get());
|
| - return worker.release();
|
| + if (worker->initialize(context, url, exceptionState))
|
| + return worker.release();
|
| + return nullptr;
|
| }
|
|
|
| Worker::~Worker()
|
| @@ -98,6 +87,24 @@ void Worker::postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> me
|
| m_contextProxy->postMessageToWorkerGlobalScope(message, channels.release());
|
| }
|
|
|
| +bool Worker::initialize(ExecutionContext* context, const String& url, ExceptionState& exceptionState)
|
| +{
|
| + suspendIfNeeded();
|
| +
|
| + Document* document = toDocument(context);
|
| + WorkerGlobalScopeProxyProvider* proxyProvider = WorkerGlobalScopeProxyProvider::from(*document->page());
|
| + ASSERT(proxyProvider);
|
| +
|
| + KURL scriptURL = resolveURL(url, exceptionState);
|
| + if (scriptURL.isEmpty())
|
| + return false;
|
| +
|
| + m_scriptLoader = WorkerScriptLoader::create();
|
| + m_scriptLoader->loadAsynchronously(*context, scriptURL, DenyCrossOriginRequests, this);
|
| + m_contextProxy = proxyProvider->createWorkerGlobalScopeProxy(this);
|
| + return true;
|
| +}
|
| +
|
| void Worker::terminate()
|
| {
|
| if (m_contextProxy)
|
|
|