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

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

Issue 2025783002: Worker: Introduce an observation mechanism for WorkerThread termination (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delayed_task
Patch Set: Stop tracing CrossThread(Weak)Persistents Created 4 years, 6 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/WorkerThread.cpp
diff --git a/third_party/WebKit/Source/core/workers/WorkerThread.cpp b/third_party/WebKit/Source/core/workers/WorkerThread.cpp
index d470e8e2ae8eb902d49d06c57b54888fed418dac..37c77d3b6f633184bff0e95685da6bb0d76c0519 100644
--- a/third_party/WebKit/Source/core/workers/WorkerThread.cpp
+++ b/third_party/WebKit/Source/core/workers/WorkerThread.cpp
@@ -154,6 +154,24 @@ static HashSet<WorkerThread*>& workerThreads()
return threads;
}
+WorkerThreadContext::WorkerThreadContext()
+{
+ DCHECK(isMainThread());
+}
+
+WorkerThreadContext::~WorkerThreadContext()
+{
+ DCHECK(isMainThread());
+}
+
+void WorkerThreadContext::notifyContextDestroyed()
+{
+ DCHECK(isMainThread());
+ DCHECK(!m_wasContextDestroyed);
+ m_wasContextDestroyed = true;
+ LifecycleNotifier::notifyContextDestroyed();
+}
+
WorkerThread::~WorkerThread()
{
DCHECK(isMainThread());
@@ -307,7 +325,9 @@ WorkerThread::WorkerThread(PassRefPtr<WorkerLoaderProxy> workerLoaderProxy, Work
, m_shutdownEvent(adoptPtr(new WaitableEvent(
WaitableEvent::ResetPolicy::Manual,
WaitableEvent::InitialState::NonSignaled)))
+ , m_workerThreadContext(new WorkerThreadContext)
{
+ DCHECK(isMainThread());
MutexLocker lock(threadSetMutex());
workerThreads().add(this);
}
@@ -354,6 +374,8 @@ void WorkerThread::terminateInternal(TerminationMode mode)
if (m_terminationEvent)
m_terminationEvent->signal();
+ m_workerThreadContext->notifyContextDestroyed();
+
// If the worker thread was never initialized, don't start another
// shutdown, but still wait for the thread to signal when shutdown has
// completed on initializeOnWorkerThread().

Powered by Google App Engine
This is Rietveld 408576698