Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(856)

Unified Diff: Source/core/workers/Worker.cpp

Issue 1018863002: compositor-worker: Introduce CompositorWorker. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/workers/Worker.h ('k') | Source/core/workers/WorkerMessagingProxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « Source/core/workers/Worker.h ('k') | Source/core/workers/WorkerMessagingProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698