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

Unified Diff: third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp

Issue 1895873006: compositor-worker: Initialize CW machinery plumbing to compositor and fire CW rAF callbacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add big fat TODOs in scheduler code to implement proper idle task scheduling and ensure GC is runniā€¦ Created 4 years, 7 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
Index: third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp
diff --git a/third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp b/third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp
index 040ce92ea79208362ca3f48cfceb67291d092614..5e8e3914ddcffe06ae1b8ddec3443c7527dd866f 100644
--- a/third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp
+++ b/third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp
@@ -11,6 +11,7 @@
#include "bindings/core/v8/V8PerIsolateData.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/ThreadSafeFunctional.h"
+#include "platform/WaitableEvent.h"
#include "platform/WebThreadSupportingGC.h"
#include "public/platform/Platform.h"
#include "public/platform/WebTraceLocation.h"
@@ -29,10 +30,13 @@ WorkerBackingThread::WorkerBackingThread(WebThread* thread, bool shouldCallGCOnS
, m_isOwningThread(false)
, m_shouldCallGCOnShutdown(shouldCallGCOnShutdown)
{
+ thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&WorkerBackingThread::initialize, AllowCrossThreadAccess(this)));
}
WorkerBackingThread::~WorkerBackingThread()
{
+ if (!m_isOwningThread)
+ signalShutdownAndWait();
#if DCHECK_IS_ON()
MutexLocker locker(m_mutex);
DCHECK_EQ(0u, m_workerScriptCount);
@@ -46,7 +50,8 @@ void WorkerBackingThread::attach()
if (++m_workerScriptCount > 1)
return;
}
- initialize();
+ if (m_isOwningThread)
+ initialize();
}
void WorkerBackingThread::detach()
@@ -56,7 +61,8 @@ void WorkerBackingThread::detach()
if (--m_workerScriptCount > 0)
return;
}
- shutdown();
+ if (m_isOwningThread)
+ shutdown();
}
void WorkerBackingThread::initialize()
@@ -75,7 +81,7 @@ void WorkerBackingThread::initialize()
Platform::current()->didStartWorkerThread();
}
-void WorkerBackingThread::shutdown()
+void WorkerBackingThread::shutdown(WaitableEvent* doneEvent)
{
if (m_isOwningThread)
Platform::current()->willStopWorkerThread();
@@ -90,6 +96,15 @@ void WorkerBackingThread::shutdown()
V8PerIsolateData::destroy(m_isolate);
m_isolate = nullptr;
+ if (doneEvent)
+ doneEvent->signal();
+}
+
+void WorkerBackingThread::signalShutdownAndWait()
haraken 2016/05/06 02:45:51 +yhirano: Would you review the changes to the shut
+{
+ WaitableEvent doneEvent;
+ m_backingThread->platformThread().getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&WorkerBackingThread::shutdown, AllowCrossThreadAccess(this), AllowCrossThreadAccess(&doneEvent)));
+ doneEvent.wait();
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698