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

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

Issue 857193004: [NOT READY FOR REVIEW YET]workers: Some refactoring to allow creating new kind of worker threads Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 years, 11 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/WorkerThread.h ('k') | Source/platform/WebThreadSupportingGC.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/workers/WorkerThread.cpp
diff --git a/Source/core/workers/WorkerThread.cpp b/Source/core/workers/WorkerThread.cpp
index a08d7c5ec5afcd791cf69cdad1a0558aedfa4ffb..2a49ad36eca54674d50632780125bddf77d69efe 100644
--- a/Source/core/workers/WorkerThread.cpp
+++ b/Source/core/workers/WorkerThread.cpp
@@ -248,6 +248,7 @@ WorkerThread::WorkerThread(WorkerLoaderProxy& workerLoaderProxy, WorkerReporting
, m_startupData(startupData)
, m_shutdownEvent(adoptPtr(blink::Platform::current()->createWaitableEvent()))
, m_terminationEvent(adoptPtr(blink::Platform::current()->createWaitableEvent()))
+ , m_isolate(nullptr)
{
MutexLocker lock(threadSetMutex());
workerThreads().add(this);
@@ -265,7 +266,7 @@ void WorkerThread::start()
if (m_thread)
return;
- m_thread = WebThreadSupportingGC::create("WebCore: Worker");
+ m_thread = createWebThreadSupportingGC();
m_thread->postTask(new Task(WTF::bind(&WorkerThread::initialize, this)));
}
@@ -283,6 +284,12 @@ PlatformThreadId WorkerThread::platformThreadId() const
return m_thread->platformThread().threadId();
}
+v8::Isolate* WorkerThread::isolate() const
+{
+ ASSERT(isCurrentThread());
+ return m_isolate;
+}
+
void WorkerThread::initialize()
{
KURL scriptURL = m_startupData->m_scriptURL;
@@ -303,6 +310,9 @@ void WorkerThread::initialize()
m_microtaskRunner = adoptPtr(new MicrotaskRunner);
m_thread->addTaskObserver(m_microtaskRunner.get());
m_thread->attachGC();
+
+ m_isolate = initializeIsolate();
+
m_workerGlobalScope = createWorkerGlobalScope(m_startupData.release());
m_sharedTimer = adoptPtr(new WorkerSharedTimer(this));
@@ -329,6 +339,19 @@ void WorkerThread::initialize()
postDelayedTask(createSameThreadTask(&WorkerThread::idleHandler, this), kShortIdleHandlerDelayMs);
}
+v8::Isolate* WorkerThread::initializeIsolate()
+{
+ ASSERT(isCurrentThread());
+ v8::Isolate* isolate = V8PerIsolateData::initialize();
+ V8Initializer::initializeWorker(isolate);
+ return isolate;
+}
+
+PassOwnPtr<WebThreadSupportingGC> WorkerThread::createWebThreadSupportingGC()
+{
+ return WebThreadSupportingGC::create("WebCore: Worker");
+}
+
void WorkerThread::cleanup()
{
« no previous file with comments | « Source/core/workers/WorkerThread.h ('k') | Source/platform/WebThreadSupportingGC.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698