| Index: Source/core/workers/Worker.cpp
|
| diff --git a/Source/core/workers/Worker.cpp b/Source/core/workers/Worker.cpp
|
| index 8a0b761bb77f65f74414055da6a0e0f258d39014..caf255e8eca1920c5408419c73edd18dad9b4db1 100644
|
| --- a/Source/core/workers/Worker.cpp
|
| +++ b/Source/core/workers/Worker.cpp
|
| @@ -44,7 +44,7 @@
|
|
|
| namespace blink {
|
|
|
| -inline Worker::Worker(ExecutionContext* context)
|
| +Worker::Worker(ExecutionContext* context)
|
| : AbstractWorker(context)
|
| , m_contextProxy(nullptr)
|
| {
|
| @@ -59,21 +59,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()
|
| @@ -99,6 +88,30 @@ void Worker::postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> me
|
| m_contextProxy->postMessageToWorkerGlobalScope(message, channels.release());
|
| }
|
|
|
| +bool Worker::initialize(ExecutionContext* context, const String& url, ExceptionState& exceptionState)
|
| +{
|
| + suspendIfNeeded();
|
| +
|
| + KURL scriptURL = resolveURL(url, exceptionState);
|
| + if (scriptURL.isEmpty())
|
| + return false;
|
| +
|
| + m_scriptLoader = WorkerScriptLoader::create();
|
| + m_scriptLoader->loadAsynchronously(*context, scriptURL, DenyCrossOriginRequests, this);
|
| +
|
| + m_contextProxy = createWorkerGlobalScopeProxy(context);
|
| +
|
| + return true;
|
| +}
|
| +
|
| +WorkerGlobalScopeProxy* Worker::createWorkerGlobalScopeProxy(ExecutionContext* context)
|
| +{
|
| + Document* document = toDocument(context);
|
| + WorkerGlobalScopeProxyProvider* proxyProvider = WorkerGlobalScopeProxyProvider::from(*document->page());
|
| + ASSERT(proxyProvider);
|
| + return proxyProvider->createWorkerGlobalScopeProxy(this);
|
| +}
|
| +
|
| void Worker::terminate()
|
| {
|
| if (m_contextProxy)
|
|
|