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

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

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.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8PrivateProperty.cpp b/third_party/WebKit/Source/bindings/core/v8/V8PrivateProperty.cpp
index 865447da06afd6001c032b795ed6746876c2bc32..b20fdcdbf837e265bc1a93dc718f9e726bdb9da9 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8PrivateProperty.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8PrivateProperty.cpp
@@ -11,6 +11,15 @@
namespace blink {
+static inline v8::Local<v8::String> createV8String(v8::Isolate* isolate,
Yuki 2017/03/28 08:17:59 nit: anonymous namespace is preferred. nit: inline
jbroman 2017/03/30 15:55:55 nit: This function is equivalent to v8String; cons
peria 2017/03/31 04:26:50 Done.
+ const char* symbol,
+ size_t length) {
+ return v8::String::NewFromOneByte(
+ isolate, reinterpret_cast<const uint8_t*>(symbol),
+ v8::NewStringType::kNormal, static_cast<int>(length))
+ .ToLocalChecked();
+}
+
v8::Local<v8::Value> V8PrivateProperty::Symbol::getFromMainWorld(
ScriptState* scriptState,
ScriptWrappable* scriptWrappable) {
@@ -23,12 +32,14 @@ v8::Local<v8::Value> V8PrivateProperty::Symbol::getFromMainWorld(
v8::Local<v8::Private> V8PrivateProperty::createV8Private(v8::Isolate* isolate,
const char* symbol,
size_t length) {
- v8::Local<v8::String> str =
- v8::String::NewFromOneByte(
- isolate, reinterpret_cast<const uint8_t*>(symbol),
- v8::NewStringType::kNormal, static_cast<int>(length))
- .ToLocalChecked();
- return v8::Private::New(isolate, str);
+ return v8::Private::New(isolate, createV8String(isolate, symbol, length));
+}
+
+v8::Local<v8::Private> V8PrivateProperty::createCachedV8Private(
Yuki 2017/03/28 08:17:59 nit: You may want a TODO comment here, too, to rem
peria 2017/03/31 04:26:50 I'm not confident, but this method can be usable f
+ v8::Isolate* isolate,
+ const char* symbol,
+ size_t length) {
+ return v8::Private::ForApi(isolate, createV8String(isolate, symbol, length));
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698