OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "bindings/core/v8/V8PrivateProperty.h" | |
6 | |
7 #include "bindings/core/v8/ScriptState.h" | |
8 #include "bindings/core/v8/ScriptWrappable.h" | |
9 #include "bindings/core/v8/V8Binding.h" | |
10 | |
11 namespace blink { | |
12 | |
13 v8::Local<v8::Value> V8PrivateProperty::Symbol::getFromMainWorld(ScriptState* sc riptState, ScriptWrappable* scriptWrappable) | |
14 { | |
15 v8::Local<v8::Object> wrapper = scriptWrappable->newLocalWrapper(scriptState ->isolate()); | |
16 return wrapper.IsEmpty() ? v8::Local<v8::Value>() : get(scriptState->context (), wrapper); | |
17 } | |
18 | |
19 v8::Local<v8::Private> V8PrivateProperty::createV8Private(v8::Isolate* isolate, const char* symbol, size_t length) | |
20 { | |
21 v8::Local<v8::String> str; | |
22 if (!LIKELY(v8::String::NewFromOneByte(isolate, reinterpret_cast<const uint8 _t*>(symbol), v8::NewStringType::kNormal, static_cast<int>(length)).ToLocal(&str ))) { | |
haraken
2016/05/24 17:33:53
Can we use v8CallOrCrash?
Yuki
2016/05/26 10:52:11
Done.
| |
23 // Immediately crashes when NewFromOneByte() fails because it only fails | |
24 // the given string is too long. | |
25 RELEASE_NOTREACHED(); | |
26 return v8::Local<v8::Private>(); | |
27 } | |
28 return v8::Private::ForApi(isolate, str); | |
29 } | |
30 | |
31 } // namespace blink | |
OLD | NEW |