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

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

Issue 2794453002: [Bindings] Replace V8HiddenValue in generated code with 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
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(CustomElement, TagName) \ 32 X(CustomElement, TagName) \
33 X(CustomElement, Type) \ 33 X(CustomElement, Type) \
34 X(DOMException, Error) \ 34 X(DOMException, Error) \
35 X(ErrorEvent, Error) \ 35 X(ErrorEvent, Error) \
36 X(IDBObserver, Callback) \ 36 X(IDBObserver, Callback) \
37 X(IntersectionObserver, Callback) \ 37 X(IntersectionObserver, Callback) \
38 X(MessageEvent, CachedData) \ 38 X(MessageEvent, CachedData) \
39 X(MutationObserver, Callback) \ 39 X(MutationObserver, Callback) \
40 X(NamedConstructor, Initialized) \ 40 X(NamedConstructor, Initialized) \
41 X(PerformanceObserver, Callback) \ 41 X(PerformanceObserver, Callback) \
42 X(PopStateEvent, State) \
42 X(SameObject, NotificationActions) \ 43 X(SameObject, NotificationActions) \
43 X(SameObject, NotificationData) \ 44 X(SameObject, NotificationData) \
44 X(SameObject, NotificationVibrate) \ 45 X(SameObject, NotificationVibrate) \
45 X(SameObject, PerformanceLongTaskTimingAttribution) \ 46 X(SameObject, PerformanceLongTaskTimingAttribution) \
46 X(V8NodeFilterCondition, Filter) 47 X(V8NodeFilterCondition, Filter)
47 48
48 // The getter's name for a private property. 49 // The getter's name for a private property.
49 #define V8_PRIVATE_PROPERTY_GETTER_NAME(InterfaceName, PrivateKeyName) \ 50 #define V8_PRIVATE_PROPERTY_GETTER_NAME(InterfaceName, PrivateKeyName) \
50 get##InterfaceName##PrivateKeyName 51 get##InterfaceName##PrivateKeyName
51 52
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 v8::Local<v8::Value> getOrEmpty(v8::Local<v8::Object> object) const { 99 v8::Local<v8::Value> getOrEmpty(v8::Local<v8::Object> object) const {
99 if (hasValue(object)) 100 if (hasValue(object))
100 return getOrUndefined(object); 101 return getOrUndefined(object);
101 return v8::Local<v8::Value>(); 102 return v8::Local<v8::Value>();
102 } 103 }
103 104
104 bool set(v8::Local<v8::Object> object, v8::Local<v8::Value> value) const { 105 bool set(v8::Local<v8::Object> object, v8::Local<v8::Value> value) const {
105 return object->SetPrivate(context(), m_privateSymbol, value).ToChecked(); 106 return object->SetPrivate(context(), m_privateSymbol, value).ToChecked();
106 } 107 }
107 108
109 bool deleteProperty(v8::Local<v8::Object> object) const {
110 return object->DeletePrivate(context(), m_privateSymbol).ToChecked();
111 }
112
108 v8::Local<v8::Private> getPrivate() const { return m_privateSymbol; } 113 v8::Local<v8::Private> getPrivate() const { return m_privateSymbol; }
109 114
110 private: 115 private:
111 friend class V8PrivateProperty; 116 friend class V8PrivateProperty;
112 // The following classes are exceptionally allowed to call to 117 // The following classes are exceptionally allowed to call to
113 // getFromMainWorld. 118 // getFromMainWorld.
114 friend class V8CustomEvent; 119 friend class V8CustomEvent;
115 friend class V8ServiceWorkerMessageEventInternal; 120 friend class V8ServiceWorkerMessageEventInternal;
116 121
117 Symbol(v8::Isolate* isolate, v8::Local<v8::Private> privateSymbol) 122 Symbol(v8::Isolate* isolate, v8::Local<v8::Private> privateSymbol)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 privateProp->m_symbolWindowDocumentCachedAccessor.set( 166 privateProp->m_symbolWindowDocumentCachedAccessor.set(
162 isolate, createCachedV8Private( 167 isolate, createCachedV8Private(
163 isolate, V8_PRIVATE_PROPERTY_SYMBOL_STRING( 168 isolate, V8_PRIVATE_PROPERTY_SYMBOL_STRING(
164 "Window", "DocumentCachedAccessor"))); 169 "Window", "DocumentCachedAccessor")));
165 } 170 }
166 return Symbol( 171 return Symbol(
167 isolate, 172 isolate,
168 privateProp->m_symbolWindowDocumentCachedAccessor.newLocal(isolate)); 173 privateProp->m_symbolWindowDocumentCachedAccessor.newLocal(isolate));
169 } 174 }
170 175
171 static Symbol createSymbol(v8::Isolate* isolate, const char* symbol) { 176 static Symbol getSymbol(v8::Isolate* isolate, const char* symbol) {
172 return Symbol(isolate, createCachedV8Private(isolate, symbol)); 177 return Symbol(isolate, createCachedV8Private(isolate, symbol));
173 } 178 }
174 179
175 private: 180 private:
176 V8PrivateProperty() {} 181 V8PrivateProperty() {}
177 182
178 static v8::Local<v8::Private> createV8Private(v8::Isolate*, 183 static v8::Local<v8::Private> createV8Private(v8::Isolate*,
179 const char* symbol); 184 const char* symbol);
185 // TODO(peria): Remove this method. We should not use v8::Private::ForApi().
180 static v8::Local<v8::Private> createCachedV8Private(v8::Isolate*, 186 static v8::Local<v8::Private> createCachedV8Private(v8::Isolate*,
181 const char* symbol); 187 const char* symbol);
182 188
183 #define V8_PRIVATE_PROPERTY_DECLARE_MEMBER(InterfaceName, KeyName) \ 189 #define V8_PRIVATE_PROPERTY_DECLARE_MEMBER(InterfaceName, KeyName) \
184 v8::Eternal<v8::Private> V8_PRIVATE_PROPERTY_MEMBER_NAME( \ 190 v8::Eternal<v8::Private> V8_PRIVATE_PROPERTY_MEMBER_NAME( \
185 InterfaceName, KeyName); // NOLINT(readability/naming/underscores) 191 InterfaceName, KeyName); // NOLINT(readability/naming/underscores)
186 V8_PRIVATE_PROPERTY_FOR_EACH(V8_PRIVATE_PROPERTY_DECLARE_MEMBER) 192 V8_PRIVATE_PROPERTY_FOR_EACH(V8_PRIVATE_PROPERTY_DECLARE_MEMBER)
187 #undef V8_PRIVATE_PROPERTY_DECLARE_MEMBER 193 #undef V8_PRIVATE_PROPERTY_DECLARE_MEMBER
188 194
189 // TODO(peria): Do not use this specialized hack for 195 // TODO(peria): Do not use this specialized hack for
190 // Window#DocumentCachedAccessor. This is required to put v8::Private key in 196 // Window#DocumentCachedAccessor. This is required to put v8::Private key in
191 // a snapshot, and it cannot be a v8::Eternal<> due to V8 serializer's 197 // a snapshot, and it cannot be a v8::Eternal<> due to V8 serializer's
192 // requirement. 198 // requirement.
193 ScopedPersistent<v8::Private> m_symbolWindowDocumentCachedAccessor; 199 ScopedPersistent<v8::Private> m_symbolWindowDocumentCachedAccessor;
194 }; 200 };
195 201
196 } // namespace blink 202 } // namespace blink
197 203
198 #endif // V8PrivateProperty_h 204 #endif // V8PrivateProperty_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698