| Index: Source/core/workers/WorkerThread.cpp
|
| diff --git a/Source/core/workers/WorkerThread.cpp b/Source/core/workers/WorkerThread.cpp
|
| index a1706974e17eb2d2bbe79dce4cd6b8cfde2ff5d3..5d46e388bd424cf8613a0ed95c6f2bf058bfd35c 100644
|
| --- a/Source/core/workers/WorkerThread.cpp
|
| +++ b/Source/core/workers/WorkerThread.cpp
|
| @@ -40,6 +40,7 @@
|
| #include "platform/PlatformThreadData.h"
|
| #include "platform/Task.h"
|
| #include "platform/ThreadTimers.h"
|
| +#include "platform/TraceEvent.h"
|
| #include "platform/heap/ThreadState.h"
|
| #include "platform/weborigin/KURL.h"
|
| #include "public/platform/Platform.h"
|
| @@ -248,6 +249,8 @@ WorkerThread::WorkerThread(WorkerLoaderProxy& workerLoaderProxy, WorkerReporting
|
| , m_startupData(startupData)
|
| , m_shutdownEvent(adoptPtr(blink::Platform::current()->createWaitableEvent()))
|
| , m_terminationEvent(adoptPtr(blink::Platform::current()->createWaitableEvent()))
|
| + , m_teleporter(0)
|
| + , m_compositorId(0)
|
| {
|
| MutexLocker lock(threadSetMutex());
|
| workerThreads().add(this);
|
| @@ -262,11 +265,11 @@ WorkerThread::~WorkerThread()
|
|
|
| void WorkerThread::start()
|
| {
|
| - if (m_thread)
|
| + if (thread())
|
| return;
|
|
|
| - m_thread = WebThreadSupportingGC::create("WebCore: Worker");
|
| - m_thread->postTask(new Task(WTF::bind(&WorkerThread::initialize, this)));
|
| + initializeWebThread();
|
| + thread()->postTask(new Task(WTF::bind(&WorkerThread::initialize, this)));
|
| }
|
|
|
| void WorkerThread::interruptAndDispatchInspectorCommands()
|
| @@ -285,9 +288,12 @@ PlatformThreadId WorkerThread::platformThreadId() const
|
|
|
| void WorkerThread::initialize()
|
| {
|
| + TRACE_EVENT0("teleport", "WorkerThread::initialize");
|
| + // fprintf(stderr, "right here\n");
|
| KURL scriptURL = m_startupData->m_scriptURL;
|
| String sourceCode = m_startupData->m_sourceCode;
|
| WorkerThreadStartMode startMode = m_startupData->m_startMode;
|
| + m_compositorId = m_startupData->m_compositorId;
|
|
|
| {
|
| MutexLocker lock(m_threadCreationMutex);
|
| @@ -301,8 +307,8 @@ void WorkerThread::initialize()
|
| }
|
|
|
| m_microtaskRunner = adoptPtr(new MicrotaskRunner);
|
| - m_thread->addTaskObserver(m_microtaskRunner.get());
|
| - m_thread->attachGC();
|
| + thread()->addTaskObserver(m_microtaskRunner.get());
|
| + thread()->attachGC();
|
| m_workerGlobalScope = createWorkerGlobalScope(m_startupData.release());
|
|
|
| m_sharedTimer = adoptPtr(new WorkerSharedTimer(this));
|
| @@ -311,7 +317,7 @@ void WorkerThread::initialize()
|
|
|
| // The corresponding call to didStopWorkerRunLoop is in
|
| // ~WorkerScriptController.
|
| - blink::Platform::current()->didStartWorkerRunLoop(blink::WebWorkerRunLoop(this));
|
| + blink::Platform::current()->didStartWorkerRunLoop(getRunLoop());
|
|
|
| // Notify proxy that a new WorkerGlobalScope has been created and started.
|
| m_workerReportingProxy.workerGlobalScopeStarted(m_workerGlobalScope.get());
|
| @@ -328,6 +334,10 @@ void WorkerThread::initialize()
|
| postDelayedTask(createSameThreadTask(&WorkerThread::idleHandler, this), kShortIdleHandlerDelayMs);
|
| }
|
|
|
| +blink::WebWorkerRunLoop WorkerThread::getRunLoop() {
|
| + return blink::WebWorkerRunLoop(this);
|
| +}
|
| +
|
| void WorkerThread::cleanup()
|
| {
|
|
|
| @@ -343,9 +353,9 @@ void WorkerThread::cleanup()
|
| m_workerGlobalScope->dispose();
|
| m_workerGlobalScope = nullptr;
|
|
|
| - m_thread->detachGC();
|
| + thread()->detachGC();
|
|
|
| - m_thread->removeTaskObserver(m_microtaskRunner.get());
|
| + thread()->removeTaskObserver(m_microtaskRunner.get());
|
| m_microtaskRunner = nullptr;
|
|
|
| // Notify the proxy that the WorkerGlobalScope has been disposed of.
|
| @@ -371,7 +381,7 @@ public:
|
| workerGlobalScope->clearInspector();
|
| // It's not safe to call clearScript until all the cleanup tasks posted by functions initiated by WorkerThreadShutdownStartTask have completed.
|
| workerGlobalScope->clearScript();
|
| - workerGlobalScope->thread()->m_thread->postTask(new Task(WTF::bind(&WorkerThread::cleanup, workerGlobalScope->thread())));
|
| + workerGlobalScope->thread()->thread()->postTask(new Task(WTF::bind(&WorkerThread::cleanup, workerGlobalScope->thread())));
|
| }
|
|
|
| virtual bool isCleanupTask() const { return true; }
|
| @@ -459,7 +469,7 @@ void WorkerThread::terminateAndWaitForAllWorkers()
|
|
|
| bool WorkerThread::isCurrentThread() const
|
| {
|
| - return m_thread && m_thread->isCurrentThread();
|
| + return thread() && thread()->isCurrentThread();
|
| }
|
|
|
| void WorkerThread::idleHandler()
|
| @@ -480,12 +490,12 @@ void WorkerThread::idleHandler()
|
|
|
| void WorkerThread::postTask(PassOwnPtr<ExecutionContextTask> task)
|
| {
|
| - m_thread->postTask(WorkerThreadTask::create(*this, task, true).leakPtr());
|
| + thread()->postTask(WorkerThreadTask::create(*this, task, true).leakPtr());
|
| }
|
|
|
| void WorkerThread::postDelayedTask(PassOwnPtr<ExecutionContextTask> task, long long delayMs)
|
| {
|
| - m_thread->postDelayedTask(WorkerThreadTask::create(*this, task, true).leakPtr(), delayMs);
|
| + thread()->postDelayedTask(WorkerThreadTask::create(*this, task, true).leakPtr(), delayMs);
|
| }
|
|
|
| void WorkerThread::postDebuggerTask(PassOwnPtr<ExecutionContextTask> task)
|
| @@ -532,4 +542,20 @@ void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke
|
| m_workerInspectorController = workerInspectorController;
|
| }
|
|
|
| +void WorkerThread::setTeleporter(WebTeleporter* teleporter)
|
| +{
|
| + TRACE_EVENT0("teleport", "WorkerThread::setTeleporter");
|
| + m_teleporter = teleporter;
|
| +}
|
| +
|
| +void WorkerThread::initializeWebThread()
|
| +{
|
| + m_thread = WebThreadSupportingGC::create("WebCore: Worker");
|
| +}
|
| +
|
| +blink::WebThreadSupportingGC* WorkerThread::thread() const
|
| +{
|
| + return m_thread.get();
|
| +}
|
| +
|
| } // namespace blink
|
|
|