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

Side by Side 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, 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 #include "bindings/core/v8/V8PrivateProperty.h" 5 #include "bindings/core/v8/V8PrivateProperty.h"
6 6
7 #include "bindings/core/v8/ScriptState.h" 7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/ScriptWrappable.h" 8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "bindings/core/v8/V8Binding.h" 9 #include "bindings/core/v8/V8Binding.h"
10 #include "bindings/core/v8/V8BindingMacros.h" 10 #include "bindings/core/v8/V8BindingMacros.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 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.
15 const char* symbol,
16 size_t length) {
17 return v8::String::NewFromOneByte(
18 isolate, reinterpret_cast<const uint8_t*>(symbol),
19 v8::NewStringType::kNormal, static_cast<int>(length))
20 .ToLocalChecked();
21 }
22
14 v8::Local<v8::Value> V8PrivateProperty::Symbol::getFromMainWorld( 23 v8::Local<v8::Value> V8PrivateProperty::Symbol::getFromMainWorld(
15 ScriptState* scriptState, 24 ScriptState* scriptState,
16 ScriptWrappable* scriptWrappable) { 25 ScriptWrappable* scriptWrappable) {
17 v8::Local<v8::Object> wrapper = 26 v8::Local<v8::Object> wrapper =
18 scriptWrappable->mainWorldWrapper(scriptState->isolate()); 27 scriptWrappable->mainWorldWrapper(scriptState->isolate());
19 return wrapper.IsEmpty() ? v8::Local<v8::Value>() 28 return wrapper.IsEmpty() ? v8::Local<v8::Value>()
20 : get(scriptState->context(), wrapper); 29 : get(scriptState->context(), wrapper);
21 } 30 }
22 31
23 v8::Local<v8::Private> V8PrivateProperty::createV8Private(v8::Isolate* isolate, 32 v8::Local<v8::Private> V8PrivateProperty::createV8Private(v8::Isolate* isolate,
24 const char* symbol, 33 const char* symbol,
25 size_t length) { 34 size_t length) {
26 v8::Local<v8::String> str = 35 return v8::Private::New(isolate, createV8String(isolate, symbol, length));
27 v8::String::NewFromOneByte( 36 }
28 isolate, reinterpret_cast<const uint8_t*>(symbol), 37
29 v8::NewStringType::kNormal, static_cast<int>(length)) 38 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
30 .ToLocalChecked(); 39 v8::Isolate* isolate,
31 return v8::Private::New(isolate, str); 40 const char* symbol,
41 size_t length) {
42 return v8::Private::ForApi(isolate, createV8String(isolate, symbol, length));
32 } 43 }
33 44
34 } // namespace blink 45 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698