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

Unified Diff: third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.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: remake and add tests 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/WorkerThreadLifecycleObserver.h
diff --git a/third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h b/third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h
new file mode 100644
index 0000000000000000000000000000000000000000..d4cee80e825b661cc9575e823dc9c5387937c155
--- /dev/null
+++ b/third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h
@@ -0,0 +1,44 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WorkerThreadLifecycleObserver_h
+#define WorkerThreadLifecycleObserver_h
+
+#include "core/CoreExport.h"
+#include "platform/LifecycleObserver.h"
+
+namespace blink {
+
+class WorkerThreadContext;
+
+// An interface for observing worker thread termination from the main thread.
+// This may be useful, for example, when an object living on the main thread
+// needs to release references to objects on the worker thread before it gets
+// terminated.
+//
+// A class that inherits this interface should override
+// LifecycleObserver::contextDestroyed() that is called on the main thread when
+// the worker thread is about to terminate. While contextDestroyed() is called,
+// it is guaranteed that the worker thread is still alive.
+//
+// A newly created observer should firstly check whether the worker thread is
+// alive by wasContextDestroyedBeforeObserverCreation(). If this return true,
+// the worker thread has already been terminated before the observer is created,
+// and contextDestroyed() is never notified.
+class CORE_EXPORT WorkerThreadLifecycleObserver : public LifecycleObserver<WorkerThreadContext, WorkerThreadLifecycleObserver> {
+protected:
+ WorkerThreadLifecycleObserver(WorkerThreadContext*);
+
+ bool wasContextDestroyedBeforeObserverCreation() const
+ {
+ return m_wasContextDestroyedBeforeObserverCreation;
+ };
yhirano 2016/06/09 04:55:13 no semicolon
nhiroki 2016/06/09 07:37:06 Done.
+
+private:
+ const bool m_wasContextDestroyedBeforeObserverCreation;
+};
+
+} // namespace blink
+
+#endif // WorkerThreadLifecycleObserver_h

Powered by Google App Engine
This is Rietveld 408576698