Index: third_party/WebKit/Source/core/workers/WorkerThread.h |
diff --git a/third_party/WebKit/Source/core/workers/WorkerThread.h b/third_party/WebKit/Source/core/workers/WorkerThread.h |
index ed3c954900e0b8c8348dd74dce96bdaf4a5f2a0e..25fdffef22e32e1e80ce80ff9b1c8c7899eed95f 100644 |
--- a/third_party/WebKit/Source/core/workers/WorkerThread.h |
+++ b/third_party/WebKit/Source/core/workers/WorkerThread.h |
@@ -32,6 +32,8 @@ |
#include "core/frame/csp/ContentSecurityPolicy.h" |
#include "core/workers/WorkerGlobalScope.h" |
#include "core/workers/WorkerLoaderProxy.h" |
+#include "core/workers/WorkerThreadLifecycleObserver.h" |
+#include "platform/LifecycleNotifier.h" |
#include "wtf/Forward.h" |
#include "wtf/Functional.h" |
#include "wtf/OwnPtr.h" |
@@ -53,6 +55,22 @@ enum WorkerThreadStartMode { |
PauseWorkerGlobalScopeOnStart |
}; |
+// Used for notifying observers on the main thread of worker thread termination. |
+// The lifetime of this class is equal to that of WorkerThread. Created and |
+// destructed on the main thread. |
+class CORE_EXPORT WorkerThreadContext final : public GarbageCollectedFinalized<WorkerThreadContext>, public LifecycleNotifier<WorkerThreadContext, WorkerThreadLifecycleObserver> { |
kinuko
2016/06/10 02:05:28
nit: This very generic, yet another -context class
|
+ USING_GARBAGE_COLLECTED_MIXIN(WorkerThreadContext); |
+ WTF_MAKE_NONCOPYABLE(WorkerThreadContext); |
+public: |
+ WorkerThreadContext(); |
+ ~WorkerThreadContext() override; |
+ void notifyContextDestroyed() override; |
+ |
+private: |
+ friend class WorkerThreadLifecycleObserver; |
+ bool m_wasContextDestroyed = false; |
+}; |
+ |
// WorkerThread is a kind of WorkerBackingThread client. Each worker mechanism |
// can access the lower thread infrastructure via an implementation of this |
// abstract class. Multiple WorkerThreads can share one WorkerBackingThread. |
@@ -120,6 +138,10 @@ public: |
// safe. |
WorkerGlobalScope* workerGlobalScope(); |
+ // Called for creating WorkerThreadLifecycleObserver on both the main thread |
+ // and the worker thread. |
+ WorkerThreadContext* workerThreadContext() const { return m_workerThreadContext; } |
kinuko
2016/06/10 02:05:28
nit: I know this file is consistently in the old s
|
+ |
// Returns true once one of the terminate* methods is called. |
bool terminated(); |
@@ -203,6 +225,8 @@ private: |
// Scheduled when termination starts with TerminationMode::Force, and |
// cancelled when the worker thread is gracefully shut down. |
OwnPtr<ForceTerminationTask> m_scheduledForceTerminationTask; |
+ |
+ Persistent<WorkerThreadContext> m_workerThreadContext; |
}; |
} // namespace blink |