OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "platform/v8_inspector/InspectorWrapper.h" | 5 #include "platform/v8_inspector/InspectorWrapper.h" |
6 | 6 |
7 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 7 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
8 | 8 |
9 #include <v8-debug.h> | 9 #include <v8-debug.h> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 for (auto& config : methods) { | 25 for (auto& config : methods) { |
26 v8::Local<v8::Name> v8name = v8::String::NewFromUtf8(isolate, config.nam
e, v8::NewStringType::kInternalized).ToLocalChecked(); | 26 v8::Local<v8::Name> v8name = v8::String::NewFromUtf8(isolate, config.nam
e, v8::NewStringType::kInternalized).ToLocalChecked(); |
27 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate:
:New(isolate, config.callback); | 27 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate:
:New(isolate, config.callback); |
28 functionTemplate->RemovePrototype(); | 28 functionTemplate->RemovePrototype(); |
29 instanceTemplate->Set(v8name, functionTemplate, static_cast<v8::Property
Attribute>(v8::DontDelete | v8::DontEnum | v8::ReadOnly)); | 29 instanceTemplate->Set(v8name, functionTemplate, static_cast<v8::Property
Attribute>(v8::DontDelete | v8::DontEnum | v8::ReadOnly)); |
30 } | 30 } |
31 | 31 |
32 return functionTemplate; | 32 return functionTemplate; |
33 } | 33 } |
34 | 34 |
35 v8::Local<v8::Object> InspectorWrapperBase::createWrapper(v8::Local<v8::Function
Template> constructorTemplate, v8::Local<v8::Context> context) | 35 v8::Local<v8::Object> InspectorWrapperBase::createWrapper(V8DebuggerClient* clie
nt, v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context>
context) |
36 { | 36 { |
37 v8::Local<v8::Function> function; | 37 v8::Local<v8::Function> function; |
38 if (!constructorTemplate->GetFunction(context).ToLocal(&function)) | 38 if (!constructorTemplate->GetFunction(context).ToLocal(&function)) |
39 return v8::Local<v8::Object>(); | 39 return v8::Local<v8::Object>(); |
40 | 40 |
41 v8::Local<v8::Object> result; | 41 v8::Local<v8::Object> result; |
42 if (!function->NewInstance(context).ToLocal(&result)) | 42 if (!client->instantiateObject(function).ToLocal(&result)) |
43 return v8::Local<v8::Object>(); | 43 return v8::Local<v8::Object>(); |
44 return result; | 44 return result; |
45 } | 45 } |
46 | 46 |
47 void* InspectorWrapperBase::unwrap(v8::Local<v8::Context> context, v8::Local<v8:
:Object> object, const char* name) | 47 void* InspectorWrapperBase::unwrap(v8::Local<v8::Context> context, v8::Local<v8:
:Object> object, const char* name) |
48 { | 48 { |
49 v8::Isolate* isolate = context->GetIsolate(); | 49 v8::Isolate* isolate = context->GetIsolate(); |
50 ASSERT(context != v8::Debug::GetDebugContext(isolate)); | 50 ASSERT(context != v8::Debug::GetDebugContext(isolate)); |
51 | 51 |
52 v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, v8::String:
:NewFromUtf8(isolate, name, v8::NewStringType::kInternalized).ToLocalChecked()); | 52 v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, v8::String:
:NewFromUtf8(isolate, name, v8::NewStringType::kInternalized).ToLocalChecked()); |
53 | 53 |
54 v8::Local<v8::Value> value; | 54 v8::Local<v8::Value> value; |
55 if (!object->GetPrivate(context, privateKey).ToLocal(&value)) | 55 if (!object->GetPrivate(context, privateKey).ToLocal(&value)) |
56 return nullptr; | 56 return nullptr; |
57 if (!value->IsExternal()) | 57 if (!value->IsExternal()) |
58 return nullptr; | 58 return nullptr; |
59 return value.As<v8::External>()->Value(); | 59 return value.As<v8::External>()->Value(); |
60 } | 60 } |
61 | 61 |
62 v8::Local<v8::String> InspectorWrapperBase::v8InternalizedString(v8::Isolate* is
olate, const char* name) | 62 v8::Local<v8::String> InspectorWrapperBase::v8InternalizedString(v8::Isolate* is
olate, const char* name) |
63 { | 63 { |
64 return v8::String::NewFromUtf8(isolate, name, v8::NewStringType::kInternaliz
ed).ToLocalChecked(); | 64 return v8::String::NewFromUtf8(isolate, name, v8::NewStringType::kInternaliz
ed).ToLocalChecked(); |
65 } | 65 } |
66 | 66 |
67 } // namespace blink | 67 } // namespace blink |
OLD | NEW |