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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8PrivateProperty.h

Issue 2781443002: [Bindings] Specialize WindowDocument symbol in V8PrivateProperty (Closed)
Patch Set: . Created 3 years, 8 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 | « no previous file | 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 V8PrivateProperty_h 5 #ifndef V8PrivateProperty_h
6 #define V8PrivateProperty_h 6 #define V8PrivateProperty_h
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "bindings/core/v8/ScriptPromiseProperties.h" 10 #include "bindings/core/v8/ScriptPromiseProperties.h"
(...skipping 21 matching lines...) Expand all
32 X(IDBObserver, Callback) \ 32 X(IDBObserver, Callback) \
33 X(IntersectionObserver, Callback) \ 33 X(IntersectionObserver, Callback) \
34 X(MessageEvent, CachedData) \ 34 X(MessageEvent, CachedData) \
35 X(MutationObserver, Callback) \ 35 X(MutationObserver, Callback) \
36 X(NamedConstructor, Initialized) \ 36 X(NamedConstructor, Initialized) \
37 X(PerformanceObserver, Callback) \ 37 X(PerformanceObserver, Callback) \
38 X(SameObject, NotificationActions) \ 38 X(SameObject, NotificationActions) \
39 X(SameObject, NotificationData) \ 39 X(SameObject, NotificationData) \
40 X(SameObject, NotificationVibrate) \ 40 X(SameObject, NotificationVibrate) \
41 X(SameObject, PerformanceLongTaskTimingAttribution) \ 41 X(SameObject, PerformanceLongTaskTimingAttribution) \
42 X(V8NodeFilterCondition, Filter) \ 42 X(V8NodeFilterCondition, Filter)
43 X(Window, DocumentCachedAccessor)
44 43
45 // The getter's name for a private property. 44 // The getter's name for a private property.
46 #define V8_PRIVATE_PROPERTY_GETTER_NAME(InterfaceName, PrivateKeyName) \ 45 #define V8_PRIVATE_PROPERTY_GETTER_NAME(InterfaceName, PrivateKeyName) \
47 get##InterfaceName##PrivateKeyName 46 get##InterfaceName##PrivateKeyName
48 47
49 // The member variable's name for a private property. 48 // The member variable's name for a private property.
50 #define V8_PRIVATE_PROPERTY_MEMBER_NAME(InterfaceName, PrivateKeyName) \ 49 #define V8_PRIVATE_PROPERTY_MEMBER_NAME(InterfaceName, PrivateKeyName) \
51 m_symbol##InterfaceName##PrivateKeyName 50 m_symbol##InterfaceName##PrivateKeyName
52 51
53 // The string used to create a private symbol. Must be unique per V8 instance. 52 // The string used to create a private symbol. Must be unique per V8 instance.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 157 }
159 V8_PRIVATE_PROPERTY_FOR_EACH(V8_PRIVATE_PROPERTY_DEFINE_GETTER) 158 V8_PRIVATE_PROPERTY_FOR_EACH(V8_PRIVATE_PROPERTY_DEFINE_GETTER)
160 #undef V8_PRIVATE_PROPERTY_DEFINE_GETTER 159 #undef V8_PRIVATE_PROPERTY_DEFINE_GETTER
161 160
162 static Symbol createSymbol(v8::Isolate* isolate, 161 static Symbol createSymbol(v8::Isolate* isolate,
163 const char* symbol, 162 const char* symbol,
164 size_t length) { 163 size_t length) {
165 return Symbol(createV8Private(isolate, symbol, length)); 164 return Symbol(createV8Private(isolate, symbol, length));
166 } 165 }
167 166
167 static Symbol getWindowDocumentCachedAccessor(v8::Isolate* isolate) {
168 static constexpr char kSymbol[] = "Window#Document";
Yuki 2017/03/27 09:06:18 nit: Window#document?
peria 2017/03/28 08:10:03 Done. This string was created with V8_PRIVATE_P
169 V8PrivateProperty* privateProp =
170 V8PerIsolateData::from(isolate)->privateProperty();
171 if (UNLIKELY(privateProp->m_symbolWindowDocument.isEmpty())) {
172 privateProp->m_symbolWindowDocument.set(
173 isolate, createV8Private(isolate, kSymbol, sizeof(kSymbol)));
174 }
175 return Symbol(privateProp->m_symbolWindowDocument.newLocal(isolate));
176 }
177
168 private: 178 private:
169 V8PrivateProperty() {} 179 V8PrivateProperty() {}
170 180
171 static v8::Local<v8::Private> createV8Private(v8::Isolate*, 181 static v8::Local<v8::Private> createV8Private(v8::Isolate*,
172 const char* symbol, 182 const char* symbol,
173 size_t length); 183 size_t length);
174 184
175 #define V8_PRIVATE_PROPERTY_DECLARE_MEMBER(InterfaceName, KeyName) \ 185 #define V8_PRIVATE_PROPERTY_DECLARE_MEMBER(InterfaceName, KeyName) \
176 v8::Eternal<v8::Private> V8_PRIVATE_PROPERTY_MEMBER_NAME( \ 186 v8::Eternal<v8::Private> V8_PRIVATE_PROPERTY_MEMBER_NAME( \
177 InterfaceName, KeyName); // NOLINT(readability/naming/underscores) 187 InterfaceName, KeyName); // NOLINT(readability/naming/underscores)
178 V8_PRIVATE_PROPERTY_FOR_EACH(V8_PRIVATE_PROPERTY_DECLARE_MEMBER) 188 V8_PRIVATE_PROPERTY_FOR_EACH(V8_PRIVATE_PROPERTY_DECLARE_MEMBER)
179 #undef V8_PRIVATE_PROPERTY_DECLARE_MEMBER 189 #undef V8_PRIVATE_PROPERTY_DECLARE_MEMBER
190
191 // TODO(peria): Do not use specialized hack for Window#Document.
Yuki 2017/03/27 09:06:18 nit: Window#document or [Ww]indow.document?
haraken 2017/03/27 09:49:56 a special hack
peria 2017/03/28 08:10:03 Done.
peria 2017/03/28 08:10:03 Done.
192 // This is required to put v8::Private key in snapshot, and it cannot
haraken 2017/03/27 09:49:56 in a snapshot
peria 2017/03/28 08:10:03 Done.
193 // be a v8::Eternal<> due to V8 serializer's requirement.
194 ScopedPersistent<v8::Private> m_symbolWindowDocument;
jbroman 2017/03/27 18:06:56 Can you explain to me why this is correct? If I un
peria 2017/03/28 08:10:03 Right. The difference between v8::Eternal<> and Sc
Yuki 2017/03/28 08:17:59 I'm okay to use ForApi as a short-term solution, b
180 }; 195 };
181 196
182 } // namespace blink 197 } // namespace blink
183 198
184 #endif // V8PrivateProperty_h 199 #endif // V8PrivateProperty_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698