Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WorkerThreadLifecycleObserver_h | |
| 6 #define WorkerThreadLifecycleObserver_h | |
| 7 | |
| 8 #include "core/CoreExport.h" | |
| 9 #include "platform/LifecycleObserver.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 class WorkerThreadContext; | |
| 14 | |
| 15 // An interface for observing worker thread termination from the main thread. | |
| 16 // This may be useful, for example, when an object living on the main thread | |
| 17 // needs to release references to objects on the worker thread before it gets | |
| 18 // terminated. | |
| 19 // | |
| 20 // A class that inherits this interface should override | |
| 21 // LifecycleObserver::contextDestroyed() that is called on the main thread when | |
| 22 // the worker thread is about to terminate. While contextDestroyed() is called, | |
| 23 // it is guaranteed that the worker thread is still alive. | |
| 24 // | |
| 25 // A newly created observer should firstly check whether the worker thread is | |
| 26 // alive by wasContextDestroyedBeforeObserverCreation(). If this return true, | |
| 27 // the worker thread has already been terminated before the observer is created, | |
| 28 // and contextDestroyed() is never notified. | |
| 29 class CORE_EXPORT WorkerThreadLifecycleObserver : public LifecycleObserver<Worke rThreadContext, WorkerThreadLifecycleObserver> { | |
| 30 protected: | |
| 31 WorkerThreadLifecycleObserver(WorkerThreadContext*); | |
| 32 | |
| 33 bool wasContextDestroyedBeforeObserverCreation() const | |
| 34 { | |
| 35 return m_wasContextDestroyedBeforeObserverCreation; | |
| 36 }; | |
|
yhirano
2016/06/09 04:55:13
no semicolon
nhiroki
2016/06/09 07:37:06
Done.
| |
| 37 | |
| 38 private: | |
| 39 const bool m_wasContextDestroyedBeforeObserverCreation; | |
| 40 }; | |
| 41 | |
| 42 } // namespace blink | |
| 43 | |
| 44 #endif // WorkerThreadLifecycleObserver_h | |
| OLD | NEW |