| 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 92c7dbe30e5e2029efd02695376b526fe3649d85..ed4b4a6006f160010d0093180cb8d6a2e4efbd40 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> {
|
| + 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.
|
| @@ -113,6 +131,10 @@ public:
|
| // safe.
|
| WorkerGlobalScope* workerGlobalScope();
|
|
|
| + // Called for creating WorkerThreadLifecycleObserver on both the main thread
|
| + // and the worker thread.
|
| + WorkerThreadContext* workerThreadContext() const { return m_workerThreadContext; }
|
| +
|
| // Returns true once one of the terminate* methods is called.
|
| bool terminated();
|
|
|
| @@ -196,6 +218,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
|
|
|