Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.h |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.h b/third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.h |
| index 3bbe969450019357733b0853080713e4dab72ab8..579f3a7dd421562fe17f8518168ba69685dc0595 100644 |
| --- a/third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.h |
| +++ b/third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.h |
| @@ -23,21 +23,40 @@ class ScriptWrappableVisitor; |
| * thread-specific list. They keep their wrappers and dependant objects alive |
| * as long as they have pending activity. |
| */ |
| -class CORE_EXPORT ActiveScriptWrappable : public GarbageCollectedMixin { |
| - WTF_MAKE_NONCOPYABLE(ActiveScriptWrappable); |
| +class CORE_EXPORT ActiveScriptWrappableBase : public GarbageCollectedMixin { |
| + WTF_MAKE_NONCOPYABLE(ActiveScriptWrappableBase); |
| public: |
| - explicit ActiveScriptWrappable(ScriptWrappable*); |
| + explicit ActiveScriptWrappableBase(ScriptWrappable*); |
| static void traceActiveScriptWrappables(v8::Isolate*, |
| ScriptWrappableVisitor*); |
| + protected: |
| + virtual bool isContextDestroyed(ActiveScriptWrappableBase*) const = 0; |
| + |
| private: |
| ScriptWrappable* toScriptWrappable() const { return m_scriptWrappable; } |
| ScriptWrappable* m_scriptWrappable; |
| }; |
| +template <typename T> |
| +class CORE_EXPORT ActiveScriptWrappable : public ActiveScriptWrappableBase { |
| + WTF_MAKE_NONCOPYABLE(ActiveScriptWrappable); |
| + |
| + public: |
| + explicit ActiveScriptWrappable(ScriptWrappable* wrappable) |
| + : ActiveScriptWrappableBase(wrappable) {} |
| + |
| + protected: |
| + bool isContextDestroyed(ActiveScriptWrappableBase* object) const final { |
| + return !(static_cast<T*>(object)->T::getExecutionContext)() || |
|
haraken
2016/12/15 15:35:06
You're clever!
I'm surprised that all ActiveScrip
sof
2016/12/15 15:47:39
Or ContextLifecycleObserver.. or both (in which ca
|
| + (static_cast<T*>(object)->T::getExecutionContext)() |
| + ->isContextDestroyed(); |
| + } |
| +}; |
| + |
| } // namespace blink |
| #endif // ActiveScriptWrappable_h |