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

Side by Side Diff: third_party/WebKit/Source/platform/heap/WrapperVisitor.h

Issue 2086553002: Refactor ScriptWrappableVisitor.markWrapper(PersistentBase) to be instance method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Whitespace fix 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/events/EventTarget.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 WrapperVisitor_h 5 #ifndef WrapperVisitor_h
6 #define WrapperVisitor_h 6 #define WrapperVisitor_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "wtf/Allocator.h" 9 #include "wtf/Allocator.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 class Value; 12 class Value;
13 class Object; 13 class Object;
14 template <class T> class PersistentBase;
14 } 15 }
15 16
16 namespace blink { 17 namespace blink {
17 18
18 template<typename T> class TraceTrait; 19 template<typename T> class TraceTrait;
19 template<typename T> class Member; 20 template<typename T> class Member;
20 class ScriptWrappable; 21 class ScriptWrappable;
21 template<typename T> class ScopedPersistent; 22 template<typename T> class ScopedPersistent;
22 23
23 // TODO(hlopko): Find a way to remove special-casing using templates 24 // TODO(hlopko): Find a way to remove special-casing using templates
24 #define WRAPPER_VISITOR_SPECIAL_CLASSES(V) \ 25 #define WRAPPER_VISITOR_SPECIAL_CLASSES(V) \
25 V(DocumentStyleSheetCollection); \ 26 V(DocumentStyleSheetCollection); \
26 V(ElementRareData); \ 27 V(ElementRareData); \
27 V(ElementShadow); \ 28 V(ElementShadow); \
28 V(HTMLImportsController) \ 29 V(HTMLImportsController) \
29 V(MutationObserverRegistration); \ 30 V(MutationObserverRegistration); \
30 V(NodeIntersectionObserverData) \ 31 V(NodeIntersectionObserverData) \
31 V(NodeListsNodeData); \ 32 V(NodeListsNodeData); \
32 V(NodeMutationObserverData); \ 33 V(NodeMutationObserverData); \
33 V(NodeRareData); \ 34 V(NodeRareData); \
34 V(StyleEngine); \ 35 V(StyleEngine); \
36 V(V8AbstractEventListener); \
35 37
36 #define FORWARD_DECLARE_SPECIAL_CLASSES(className) \ 38 #define FORWARD_DECLARE_SPECIAL_CLASSES(className) \
37 class className; 39 class className;
38 40
39 WRAPPER_VISITOR_SPECIAL_CLASSES(FORWARD_DECLARE_SPECIAL_CLASSES); 41 WRAPPER_VISITOR_SPECIAL_CLASSES(FORWARD_DECLARE_SPECIAL_CLASSES);
40 42
41 #undef FORWARD_DECLARE_SPECIAL_CLASSES 43 #undef FORWARD_DECLARE_SPECIAL_CLASSES
42 44
43 /** 45 /**
44 * Declares non-virtual traceWrappers method. Should be used on 46 * Declares non-virtual traceWrappers method. Should be used on
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 USING_FAST_MALLOC(WrapperVisitor); 92 USING_FAST_MALLOC(WrapperVisitor);
91 public: 93 public:
92 template<typename T> 94 template<typename T>
93 void traceWrappers(const T* traceable) const 95 void traceWrappers(const T* traceable) const
94 { 96 {
95 static_assert(sizeof(T), "T must be fully defined"); 97 static_assert(sizeof(T), "T must be fully defined");
96 98
97 if (!traceable) 99 if (!traceable)
98 return; 100 return;
99 101
100 if (TraceTrait<T>::heapObjectHeader(traceable)->isWrapperHeaderMarked()) 102 if (TraceTrait<T>::heapObjectHeader(traceable)->isWrapperHeaderMarked()) {
101 return; 103 return;
104 }
102 105
103 pushToMarkingDeque( 106 pushToMarkingDeque(
104 TraceTrait<T>::markWrapper, 107 TraceTrait<T>::markWrapper,
105 TraceTrait<T>::heapObjectHeader, 108 TraceTrait<T>::heapObjectHeader,
106 traceable); 109 traceable);
107 } 110 }
108 111
109 template<typename T> 112 template<typename T>
110 void traceWrappers(const Member<T>& t) const 113 void traceWrappers(const Member<T>& t) const
111 { 114 {
112 traceWrappers(t.get()); 115 traceWrappers(t.get());
113 } 116 }
114 117
115 virtual void traceWrappers(const ScopedPersistent<v8::Value>*) const = 0; 118 virtual void traceWrappers(const ScopedPersistent<v8::Value>* persistent) co nst = 0;
119 virtual void traceWrappers(const ScopedPersistent<v8::Object>* persistent) c onst = 0;
120 virtual void markWrapper(const v8::PersistentBase<v8::Object>* persistent) c onst = 0;
116 121
117 virtual void dispatchTraceWrappers(const ScriptWrappable*) const = 0; 122 virtual void dispatchTraceWrappers(const ScriptWrappable*) const = 0;
118 #define DECLARE_DISPATCH_TRACE_WRAPPERS(className) \ 123 #define DECLARE_DISPATCH_TRACE_WRAPPERS(className) \
119 virtual void dispatchTraceWrappers(const className*) const = 0; 124 virtual void dispatchTraceWrappers(const className*) const = 0;
120 125
121 WRAPPER_VISITOR_SPECIAL_CLASSES(DECLARE_DISPATCH_TRACE_WRAPPERS); 126 WRAPPER_VISITOR_SPECIAL_CLASSES(DECLARE_DISPATCH_TRACE_WRAPPERS);
122 127
123 #undef DECLARE_DISPATCH_TRACE_WRAPPERS 128 #undef DECLARE_DISPATCH_TRACE_WRAPPERS
124 virtual void dispatchTraceWrappers(const void*) const = 0; 129 virtual void dispatchTraceWrappers(const void*) const = 0;
125 130
126 virtual bool markWrapperHeader(HeapObjectHeader*) const = 0; 131 virtual bool markWrapperHeader(HeapObjectHeader*) const = 0;
127 virtual void markWrappersInAllWorlds(const ScriptWrappable*) const = 0; 132 virtual void markWrappersInAllWorlds(const ScriptWrappable*) const = 0;
128 virtual void markWrappersInAllWorlds(const void*) const = 0; 133 virtual void markWrappersInAllWorlds(const void*) const = 0;
129 virtual void pushToMarkingDeque( 134 virtual void pushToMarkingDeque(
130 void (*traceWrappersCallback)(const WrapperVisitor*, const void*), 135 void (*traceWrappersCallback)(const WrapperVisitor*, const void*),
131 HeapObjectHeader* (*heapObjectHeaderCallback)(const void*), 136 HeapObjectHeader* (*heapObjectHeaderCallback)(const void*),
132 const void*) const = 0; 137 const void*) const = 0;
133 }; 138 };
134 139
135 } // namespace blink 140 } // namespace blink
136 141
137 #endif // WrapperVisitor_h 142 #endif // WrapperVisitor_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/EventTarget.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698