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

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

Issue 2781443002: [Bindings] Specialize WindowDocument symbol in V8PrivateProperty (Closed)
Patch Set: Specialize createV8Private to use ForApi Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/V8PrivateProperty.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8PrivateProperty.h b/third_party/WebKit/Source/bindings/core/v8/V8PrivateProperty.h
index adf5bc9f1e5a5d802384fc075a9ea6cbb0bdaf2a..9cd0393b9df8de9b32d899b3d0ec3e58efddd8cd 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8PrivateProperty.h
+++ b/third_party/WebKit/Source/bindings/core/v8/V8PrivateProperty.h
@@ -39,8 +39,7 @@ class ScriptWrappable;
X(SameObject, NotificationData) \
X(SameObject, NotificationVibrate) \
X(SameObject, PerformanceLongTaskTimingAttribution) \
- X(V8NodeFilterCondition, Filter) \
- X(Window, DocumentCachedAccessor)
+ X(V8NodeFilterCondition, Filter)
// The getter's name for a private property.
#define V8_PRIVATE_PROPERTY_GETTER_NAME(InterfaceName, PrivateKeyName) \
@@ -154,6 +153,18 @@ class CORE_EXPORT V8PrivateProperty {
V8_PRIVATE_PROPERTY_FOR_EACH(V8_PRIVATE_PROPERTY_DEFINE_GETTER)
#undef V8_PRIVATE_PROPERTY_DEFINE_GETTER
+ static Symbol getWindowDocumentCachedAccessor(v8::Isolate* isolate) {
+ static constexpr char kSymbol[] = "Window#DocumentCachedAccessor";
+ V8PrivateProperty* privateProp =
+ V8PerIsolateData::from(isolate)->privateProperty();
+ if (UNLIKELY(privateProp->m_symbolWindowDocumentCachedAccessor.isEmpty())) {
+ privateProp->m_symbolWindowDocumentCachedAccessor.set(
+ isolate, createCachedV8Private(isolate, kSymbol, sizeof(kSymbol)));
+ }
+ return Symbol(
+ privateProp->m_symbolWindowDocumentCachedAccessor.newLocal(isolate));
+ }
+
static Symbol createSymbol(v8::Isolate* isolate,
const char* symbol,
size_t length) {
@@ -166,12 +177,21 @@ class CORE_EXPORT V8PrivateProperty {
static v8::Local<v8::Private> createV8Private(v8::Isolate*,
const char* symbol,
size_t length);
+ static v8::Local<v8::Private> createCachedV8Private(v8::Isolate*,
+ const char* symbol,
+ size_t length);
#define V8_PRIVATE_PROPERTY_DECLARE_MEMBER(InterfaceName, KeyName) \
v8::Eternal<v8::Private> V8_PRIVATE_PROPERTY_MEMBER_NAME( \
InterfaceName, KeyName); // NOLINT(readability/naming/underscores)
V8_PRIVATE_PROPERTY_FOR_EACH(V8_PRIVATE_PROPERTY_DECLARE_MEMBER)
#undef V8_PRIVATE_PROPERTY_DECLARE_MEMBER
+
+ // TODO(peria): Do not use this specialized hack for
+ // Window#DocumentCachedAccessor. This is required to put v8::Private key in
+ // a snapshot, and it cannot be a v8::Eternal<> due to V8 serializer's
+ // requirement.
+ ScopedPersistent<v8::Private> m_symbolWindowDocumentCachedAccessor;
jbroman 2017/03/30 15:55:55 Out of curiosity, now that we're using v8::Private
peria 2017/03/31 04:26:50 Yes, I'm thinking so.
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698