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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.h

Issue 2577053002: ActiveScriptWrappable: GC wrappers in detached ExecutionContexts. (Closed)
Patch Set: component build fix(msvc) Created 4 years 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/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..68d41787ddc5e1a9d633a37a114906aac2c41991 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 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)() ||
+ (static_cast<T*>(object)->T::getExecutionContext)()
+ ->isContextDestroyed();
+ }
+};
+
} // namespace blink
#endif // ActiveScriptWrappable_h

Powered by Google App Engine
This is Rietveld 408576698