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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ActiveScriptWrappable_h 5 #ifndef ActiveScriptWrappable_h
6 #define ActiveScriptWrappable_h 6 #define ActiveScriptWrappable_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "platform/heap/Handle.h" 9 #include "platform/heap/Handle.h"
10 #include "wtf/Noncopyable.h" 10 #include "wtf/Noncopyable.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 class Isolate; 13 class Isolate;
14 } 14 }
15 15
16 namespace blink { 16 namespace blink {
17 17
18 class ScriptWrappable; 18 class ScriptWrappable;
19 class ScriptWrappableVisitor; 19 class ScriptWrappableVisitor;
20 20
21 /** 21 /**
22 * Classes deriving from ActiveScriptWrappable will be registered in a 22 * Classes deriving from ActiveScriptWrappable will be registered in a
23 * thread-specific list. They keep their wrappers and dependant objects alive 23 * thread-specific list. They keep their wrappers and dependant objects alive
24 * as long as they have pending activity. 24 * as long as they have pending activity.
25 */ 25 */
26 class CORE_EXPORT ActiveScriptWrappable : public GarbageCollectedMixin { 26 class CORE_EXPORT ActiveScriptWrappableBase : public GarbageCollectedMixin {
27 WTF_MAKE_NONCOPYABLE(ActiveScriptWrappable); 27 WTF_MAKE_NONCOPYABLE(ActiveScriptWrappableBase);
28 28
29 public: 29 public:
30 explicit ActiveScriptWrappable(ScriptWrappable*); 30 explicit ActiveScriptWrappableBase(ScriptWrappable*);
31 31
32 static void traceActiveScriptWrappables(v8::Isolate*, 32 static void traceActiveScriptWrappables(v8::Isolate*,
33 ScriptWrappableVisitor*); 33 ScriptWrappableVisitor*);
34 34
35 protected:
36 virtual bool isContextDestroyed(ActiveScriptWrappableBase*) const = 0;
37
35 private: 38 private:
36 ScriptWrappable* toScriptWrappable() const { return m_scriptWrappable; } 39 ScriptWrappable* toScriptWrappable() const { return m_scriptWrappable; }
37 40
38 ScriptWrappable* m_scriptWrappable; 41 ScriptWrappable* m_scriptWrappable;
39 }; 42 };
40 43
44 template <typename T>
45 class ActiveScriptWrappable : public ActiveScriptWrappableBase {
46 WTF_MAKE_NONCOPYABLE(ActiveScriptWrappable);
47
48 public:
49 explicit ActiveScriptWrappable(ScriptWrappable* wrappable)
50 : ActiveScriptWrappableBase(wrappable) {}
51
52 protected:
53 bool isContextDestroyed(ActiveScriptWrappableBase* object) const final {
54 return !(static_cast<T*>(object)->T::getExecutionContext)() ||
55 (static_cast<T*>(object)->T::getExecutionContext)()
56 ->isContextDestroyed();
57 }
58 };
59
41 } // namespace blink 60 } // namespace blink
42 61
43 #endif // ActiveScriptWrappable_h 62 #endif // ActiveScriptWrappable_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698