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

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

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.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

Powered by Google App Engine
This is Rietveld 408576698