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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.cpp

Issue 1924713002: [DevTools] Removed InjectedScriptHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-inspect-to-native
Patch Set: Created 4 years, 7 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 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/V8InjectedScriptHost.h" 5 #include "platform/v8_inspector/V8InjectedScriptHost.h"
6 6
7 #include "platform/inspector_protocol/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/inspector_protocol/Values.h" 8 #include "platform/v8_inspector/InjectedScriptNative.h"
9 #include "platform/v8_inspector/InjectedScript.h"
10 #include "platform/v8_inspector/InjectedScriptHost.h"
11 #include "platform/v8_inspector/InspectorWrapper.h"
12 #include "platform/v8_inspector/JavaScriptCallFrame.h"
13 #include "platform/v8_inspector/V8Compat.h" 9 #include "platform/v8_inspector/V8Compat.h"
14 #include "platform/v8_inspector/V8DebuggerImpl.h" 10 #include "platform/v8_inspector/V8DebuggerImpl.h"
15 #include "platform/v8_inspector/V8StringUtil.h" 11 #include "platform/v8_inspector/V8StringUtil.h"
16 #include "platform/v8_inspector/public/V8DebuggerClient.h" 12 #include "platform/v8_inspector/public/V8DebuggerClient.h"
17 #include "platform/v8_inspector/public/V8EventListenerInfo.h" 13 #include "platform/v8_inspector/public/V8EventListenerInfo.h"
18 #include "platform/v8_inspector/public/V8ToProtocolValue.h"
19 #include <algorithm>
20 14
21 namespace blink { 15 namespace blink {
22 16
23 namespace { 17 namespace {
24 18
25 template<typename CallbackInfo, typename S> 19 void setFunctionProperty(v8::Local<v8::Context> context, v8::Local<v8::Object> o bj, const char* name, v8::FunctionCallback callback, v8::Local<v8::External> ext ernal)
26 inline void v8SetReturnValue(const CallbackInfo& info, const v8::Local<S> handle )
27 { 20 {
28 info.GetReturnValue().Set(handle); 21 v8::Local<v8::String> funcName = toV8StringInternalized(context->GetIsolate( ), name);
22 v8::Local<v8::Function> func;
23 if (!v8::Function::New(context, callback, external).ToLocal(&func))
24 return;
25 func->SetName(funcName);
26 if (!obj->Set(context, funcName, func).FromMaybe(false))
27 return;
29 } 28 }
30 29
31 template<typename CallbackInfo, typename S> 30 V8DebuggerImpl* unwrapDebugger(const v8::FunctionCallbackInfo<v8::Value>& info)
32 inline void v8SetReturnValue(const CallbackInfo& info, v8::MaybeLocal<S> maybe)
33 { 31 {
34 if (LIKELY(!maybe.IsEmpty())) 32 ASSERT(!info.Data().IsEmpty());
35 info.GetReturnValue().Set(maybe.ToLocalChecked()); 33 ASSERT(!info.Data()->IsExternal());
dgozman 2016/04/27 18:28:54 ASSERT(info.Data()->IsExternal());
kozy 2016/04/27 18:41:51 Done.
34 v8::Local<v8::External> debuggerExternal = info.Data().As<v8::External>();
35 V8DebuggerImpl* debugger = static_cast<V8DebuggerImpl*>(debuggerExternal.As< v8::External>()->Value());
dgozman 2016/04/27 18:28:54 redundant .As<v8::External>
kozy 2016/04/27 18:41:51 Done.
36 ASSERT(debugger);
37 return debugger;
36 } 38 }
37 39
38 template<typename CallbackInfo> 40 } // namespace
39 inline void v8SetReturnValue(const CallbackInfo& info, bool value) 41
42 v8::Local<v8::Object> V8InjectedScriptHost::create(V8DebuggerImpl* debugger)
40 { 43 {
41 info.GetReturnValue().Set(value); 44 v8::Isolate* isolate = debugger->isolate();
42 } 45 v8::Local<v8::Context> context = isolate->GetCurrentContext();
dgozman 2016/04/27 18:28:54 Let's pass context for the case we create injected
kozy 2016/04/27 18:41:51 Done.
43 46 v8::Local<v8::Object> injectedScriptHost = v8::Object::New(isolate);
47 v8::Local<v8::External> debuggerExternal = v8::External::New(isolate, debugg er);
48 setFunctionProperty(context, injectedScriptHost, "internalConstructorName", V8InjectedScriptHost::internalConstructorNameCallback, debuggerExternal);
49 setFunctionProperty(context, injectedScriptHost, "formatAccessorsAsPropertie s", V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal);
50 setFunctionProperty(context, injectedScriptHost, "isTypedArray", V8InjectedS criptHost::isTypedArrayCallback, debuggerExternal);
51 setFunctionProperty(context, injectedScriptHost, "subtype", V8InjectedScript Host::subtypeCallback, debuggerExternal);
52 setFunctionProperty(context, injectedScriptHost, "collectionEntries", V8Inje ctedScriptHost::collectionEntriesCallback, debuggerExternal);
53 setFunctionProperty(context, injectedScriptHost, "getInternalProperties", V8 InjectedScriptHost::getInternalPropertiesCallback, debuggerExternal);
54 setFunctionProperty(context, injectedScriptHost, "getEventListeners", V8Inje ctedScriptHost::getEventListenersCallback, debuggerExternal);
55 setFunctionProperty(context, injectedScriptHost, "suppressWarningsAndCallFun ction", V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback, debuggerE xternal);
56 setFunctionProperty(context, injectedScriptHost, "setNonEnumProperty", V8Inj ectedScriptHost::setNonEnumPropertyCallback, debuggerExternal);
57 setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHos t::bindCallback, debuggerExternal);
58 return injectedScriptHost;
44 } 59 }
45 60
46 void V8InjectedScriptHost::internalConstructorNameCallback(const v8::FunctionCal lbackInfo<v8::Value>& info) 61 void V8InjectedScriptHost::internalConstructorNameCallback(const v8::FunctionCal lbackInfo<v8::Value>& info)
47 { 62 {
48 if (info.Length() < 1 || !info[0]->IsObject()) 63 if (info.Length() < 1 || !info[0]->IsObject())
49 return; 64 return;
50 65
51 v8::Local<v8::Object> object = info[0].As<v8::Object>(); 66 v8::Local<v8::Object> object = info[0].As<v8::Object>();
52 v8::Local<v8::String> result = object->GetConstructorName(); 67 info.GetReturnValue().Set(object->GetConstructorName());
53
54 v8SetReturnValue(info, result);
55 } 68 }
56 69
57 void V8InjectedScriptHost::formatAccessorsAsProperties(const v8::FunctionCallbac kInfo<v8::Value>& info) 70 void V8InjectedScriptHost::formatAccessorsAsProperties(const v8::FunctionCallbac kInfo<v8::Value>& info)
58 { 71 {
59 if (info.Length() < 1) 72 if (info.Length() < 1)
60 return; 73 return;
61 74
62 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.GetIsolate()->G etCurrentContext(), info.Holder()); 75 info.GetReturnValue().Set(unwrapDebugger(info)->client()->formatAccessorsAsP roperties(info[0]));
63 if (!host->debugger())
64 return;
65 v8SetReturnValue(info, host->debugger()->client()->formatAccessorsAsProperti es(info[0]));
66 } 76 }
67 77
68 void V8InjectedScriptHost::isTypedArrayCallback(const v8::FunctionCallbackInfo<v 8::Value>& info) 78 void V8InjectedScriptHost::isTypedArrayCallback(const v8::FunctionCallbackInfo<v 8::Value>& info)
69 { 79 {
70 if (info.Length() < 1) 80 if (info.Length() < 1)
71 return; 81 return;
72 v8SetReturnValue(info, info[0]->IsTypedArray()); 82
83 info.GetReturnValue().Set(info[0]->IsTypedArray());
73 } 84 }
74 85
75 void V8InjectedScriptHost::subtypeCallback(const v8::FunctionCallbackInfo<v8::Va lue>& info) 86 void V8InjectedScriptHost::subtypeCallback(const v8::FunctionCallbackInfo<v8::Va lue>& info)
76 { 87 {
77 if (info.Length() < 1) 88 if (info.Length() < 1)
78 return; 89 return;
90
79 v8::Isolate* isolate = info.GetIsolate(); 91 v8::Isolate* isolate = info.GetIsolate();
80
81 v8::Local<v8::Value> value = info[0]; 92 v8::Local<v8::Value> value = info[0];
82 if (value->IsArray() || value->IsTypedArray() || value->IsArgumentsObject()) { 93 if (value->IsArray() || value->IsTypedArray() || value->IsArgumentsObject()) {
83 v8SetReturnValue(info, toV8StringInternalized(isolate, "array")); 94 info.GetReturnValue().Set(toV8StringInternalized(isolate, "array"));
84 return; 95 return;
85 } 96 }
86 if (value->IsDate()) { 97 if (value->IsDate()) {
87 v8SetReturnValue(info, toV8StringInternalized(isolate, "date")); 98 info.GetReturnValue().Set(toV8StringInternalized(isolate, "date"));
88 return; 99 return;
89 } 100 }
90 if (value->IsRegExp()) { 101 if (value->IsRegExp()) {
91 v8SetReturnValue(info, toV8StringInternalized(isolate, "regexp")); 102 info.GetReturnValue().Set(toV8StringInternalized(isolate, "regexp"));
92 return; 103 return;
93 } 104 }
94 if (value->IsMap() || value->IsWeakMap()) { 105 if (value->IsMap() || value->IsWeakMap()) {
95 v8SetReturnValue(info, toV8StringInternalized(isolate, "map")); 106 info.GetReturnValue().Set(toV8StringInternalized(isolate, "map"));
96 return; 107 return;
97 } 108 }
98 if (value->IsSet() || value->IsWeakSet()) { 109 if (value->IsSet() || value->IsWeakSet()) {
99 v8SetReturnValue(info, toV8StringInternalized(isolate, "set")); 110 info.GetReturnValue().Set(toV8StringInternalized(isolate, "set"));
100 return; 111 return;
101 } 112 }
102 if (value->IsMapIterator() || value->IsSetIterator()) { 113 if (value->IsMapIterator() || value->IsSetIterator()) {
103 v8SetReturnValue(info, toV8StringInternalized(isolate, "iterator")); 114 info.GetReturnValue().Set(toV8StringInternalized(isolate, "iterator"));
104 return; 115 return;
105 } 116 }
106 if (value->IsGeneratorObject()) { 117 if (value->IsGeneratorObject()) {
107 v8SetReturnValue(info, toV8StringInternalized(isolate, "generator")); 118 info.GetReturnValue().Set(toV8StringInternalized(isolate, "generator"));
108 return; 119 return;
109 } 120 }
110 121
111 if (value->IsNativeError()) { 122 if (value->IsNativeError()) {
112 v8SetReturnValue(info, toV8StringInternalized(isolate, "error")); 123 info.GetReturnValue().Set(toV8StringInternalized(isolate, "error"));
113 return; 124 return;
114 } 125 }
115 126 String16 subtype = unwrapDebugger(info)->client()->valueSubtype(value);
116 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.GetIsolate()->G etCurrentContext(), info.Holder());
117 if (!host->debugger())
118 return;
119 String16 subtype = host->debugger()->client()->valueSubtype(value);
120 if (!subtype.isEmpty()) { 127 if (!subtype.isEmpty()) {
121 v8SetReturnValue(info, toV8String(isolate, subtype)); 128 info.GetReturnValue().Set(toV8String(isolate, subtype));
122 return; 129 return;
123 } 130 }
124 } 131 }
125 132
126 void V8InjectedScriptHost::collectionEntriesCallback(const v8::FunctionCallbackI nfo<v8::Value>& info) 133 void V8InjectedScriptHost::collectionEntriesCallback(const v8::FunctionCallbackI nfo<v8::Value>& info)
127 { 134 {
128 if (info.Length() < 1 || !info[0]->IsObject()) 135 if (info.Length() < 1 || !info[0]->IsObject())
129 return; 136 return;
130 137
131 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(info[0]); 138 v8::Local<v8::Object> object = info[0].As<v8::Object>();
132 139 info.GetReturnValue().Set(unwrapDebugger(info)->collectionEntries(object));
133 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.GetIsolate()->G etCurrentContext(), info.Holder());
134 if (!host->debugger())
135 return;
136 v8SetReturnValue(info, host->debugger()->collectionEntries(object));
137 } 140 }
138 141
139 void V8InjectedScriptHost::getInternalPropertiesCallback(const v8::FunctionCallb ackInfo<v8::Value>& info) 142 void V8InjectedScriptHost::getInternalPropertiesCallback(const v8::FunctionCallb ackInfo<v8::Value>& info)
140 { 143 {
141 if (info.Length() < 1 || !info[0]->IsObject()) 144 if (info.Length() < 1 || !info[0]->IsObject())
142 return; 145 return;
143 146
144 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(info[0]); 147 v8::Local<v8::Object> object = info[0].As<v8::Object>();
145 v8::MaybeLocal<v8::Array> properties = v8::Debug::GetInternalProperties(info .GetIsolate(), object); 148 v8::Local<v8::Array> properties;
146 v8SetReturnValue(info, properties); 149 if (v8::Debug::GetInternalProperties(info.GetIsolate(), object).ToLocal(&pro perties))
150 info.GetReturnValue().Set(properties);
147 } 151 }
148 152
149 static v8::Local<v8::Array> wrapListenerFunctions(v8::Isolate* isolate, const V8 EventListenerInfoList& listeners, const String16& type) 153 static v8::Local<v8::Array> wrapListenerFunctions(v8::Isolate* isolate, const V8 EventListenerInfoList& listeners, const String16& type)
150 { 154 {
151 v8::Local<v8::Array> result = v8::Array::New(isolate); 155 v8::Local<v8::Array> result = v8::Array::New(isolate);
152 size_t handlersCount = listeners.size(); 156 size_t handlersCount = listeners.size();
153 for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) { 157 for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) {
154 if (listeners[i].eventType != type) 158 if (listeners[i].eventType != type)
155 continue; 159 continue;
156 v8::Local<v8::Object> function = listeners[i].handler; 160 v8::Local<v8::Object> function = listeners[i].handler;
157 v8::Local<v8::Object> listenerEntry = v8::Object::New(isolate); 161 v8::Local<v8::Object> listenerEntry = v8::Object::New(isolate);
158 listenerEntry->Set(toV8StringInternalized(isolate, "listener"), function ); 162 listenerEntry->Set(toV8StringInternalized(isolate, "listener"), function );
159 listenerEntry->Set(toV8StringInternalized(isolate, "useCapture"), v8::Bo olean::New(isolate, listeners[i].useCapture)); 163 listenerEntry->Set(toV8StringInternalized(isolate, "useCapture"), v8::Bo olean::New(isolate, listeners[i].useCapture));
160 listenerEntry->Set(toV8StringInternalized(isolate, "passive"), v8::Boole an::New(isolate, listeners[i].passive)); 164 listenerEntry->Set(toV8StringInternalized(isolate, "passive"), v8::Boole an::New(isolate, listeners[i].passive));
161 result->Set(v8::Number::New(isolate, outputIndex++), listenerEntry); 165 result->Set(v8::Number::New(isolate, outputIndex++), listenerEntry);
162 } 166 }
163 return result; 167 return result;
164 } 168 }
165 169
166 void V8InjectedScriptHost::getEventListenersCallback(const v8::FunctionCallbackI nfo<v8::Value>& info) 170 void V8InjectedScriptHost::getEventListenersCallback(const v8::FunctionCallbackI nfo<v8::Value>& info)
167 { 171 {
168 if (info.Length() < 1) 172 if (info.Length() < 1)
169 return; 173 return;
170 174
171 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.GetIsolate()->G etCurrentContext(), info.Holder()); 175 V8DebuggerClient* client = unwrapDebugger(info)->client();
172 if (!host->debugger())
173 return;
174 V8DebuggerClient* client = host->debugger()->client();
175 V8EventListenerInfoList listenerInfo; 176 V8EventListenerInfoList listenerInfo;
176 client->eventListeners(info[0], listenerInfo); 177 client->eventListeners(info[0], listenerInfo);
177 178
178 v8::Local<v8::Object> result = v8::Object::New(info.GetIsolate()); 179 v8::Local<v8::Object> result = v8::Object::New(info.GetIsolate());
179 protocol::HashSet<String16> types; 180 protocol::HashSet<String16> types;
180 for (auto& info : listenerInfo) 181 for (auto& info : listenerInfo)
181 types.add(info.eventType); 182 types.add(info.eventType);
182 for (const auto& it : types) { 183 for (const auto& it : types) {
183 v8::Local<v8::Array> listeners = wrapListenerFunctions(info.GetIsolate() , listenerInfo, it.first); 184 v8::Local<v8::Array> listeners = wrapListenerFunctions(info.GetIsolate() , listenerInfo, it.first);
184 if (!listeners->Length()) 185 if (!listeners->Length())
185 continue; 186 continue;
186 result->Set(toV8String(info.GetIsolate(), it.first), listeners); 187 result->Set(toV8String(info.GetIsolate(), it.first), listeners);
187 } 188 }
188 189 info.GetReturnValue().Set(result);
189 v8SetReturnValue(info, result);
190 } 190 }
191 191
192 void V8InjectedScriptHost::callFunctionCallback(const v8::FunctionCallbackInfo<v 8::Value>& info) 192 void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::Fun ctionCallbackInfo<v8::Value>& info)
193 { 193 {
194 if (info.Length() < 2 || info.Length() > 3 || !info[0]->IsFunction()) { 194 if (info.Length() < 2 || info.Length() > 3 || !info[0]->IsFunction() || (inf o.Length() > 2 && (!info[2]->IsArray() && !info[2]->IsUndefined()))) {
dgozman 2016/04/27 18:28:54 Let's make two early returns.
kozy 2016/04/27 18:41:51 Done.
195 ASSERT_NOT_REACHED(); 195 ASSERT_NOT_REACHED();
196 return; 196 return;
197 } 197 }
198 198
199 v8::MicrotasksScope microtasks(info.GetIsolate(), v8::MicrotasksScope::kDoNo tRunMicrotasks); 199 v8::Isolate* isolate = info.GetIsolate();
200 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(info[0]); 200 v8::Local<v8::Context> context = isolate->GetCurrentContext();
201
202 v8::Local<v8::Function> function = info[0].As<v8::Function>();
201 v8::Local<v8::Value> receiver = info[1]; 203 v8::Local<v8::Value> receiver = info[1];
204 OwnPtr<v8::Local<v8::Value>[]> argv = nullptr;
205 size_t argc = 0;
202 206
203 if (info.Length() < 3 || info[2]->IsUndefined()) { 207 if (info.Length() > 2 && info[2]->IsArray()) {
204 v8::Local<v8::Value> result = function->Call(receiver, 0, 0); 208 v8::Local<v8::Array> arguments = info[2].As<v8::Array>();
205 v8SetReturnValue(info, result); 209 argc = arguments->Length();
206 return; 210 argv = adoptArrayPtr(new v8::Local<v8::Value>[argc]);
211 for (size_t i = 0; i < argc; ++i) {
212 if (!arguments->Get(context, i).ToLocal(&argv[i]))
213 return;
214 }
207 } 215 }
208 216
209 if (!info[2]->IsArray()) { 217 V8DebuggerClient* client = unwrapDebugger(info)->client();
210 ASSERT_NOT_REACHED(); 218 client->muteWarningsAndDeprecations();
211 return;
212 }
213 219
214 v8::Local<v8::Array> arguments = v8::Local<v8::Array>::Cast(info[2]); 220 v8::MicrotasksScope microtasks(isolate, v8::MicrotasksScope::kDoNotRunMicrot asks);
215 size_t argc = arguments->Length(); 221 v8::Local<v8::Value> result;
216 OwnPtr<v8::Local<v8::Value>[]> argv = adoptArrayPtr(new v8::Local<v8::Value> [argc]); 222 if (function->Call(context, receiver, argc, argv.get()).ToLocal(&result))
217 for (size_t i = 0; i < argc; ++i) { 223 info.GetReturnValue().Set(result);
218 if (!arguments->Get(info.GetIsolate()->GetCurrentContext(), v8::Integer: :New(info.GetIsolate(), i)).ToLocal(&argv[i]))
219 return;
220 }
221 224
222 v8::Local<v8::Value> result = function->Call(receiver, argc, argv.get()); 225 client->unmuteWarningsAndDeprecations();
223 v8SetReturnValue(info, result);
224 }
225
226 void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::Fun ctionCallbackInfo<v8::Value>& info)
227 {
228 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.GetIsolate()->G etCurrentContext(), info.Holder());
229 if (!host->debugger())
230 return;
231 host->debugger()->client()->muteWarningsAndDeprecations();
232 callFunctionCallback(info);
233 host->debugger()->client()->unmuteWarningsAndDeprecations();
234 } 226 }
235 227
236 void V8InjectedScriptHost::setNonEnumPropertyCallback(const v8::FunctionCallback Info<v8::Value>& info) 228 void V8InjectedScriptHost::setNonEnumPropertyCallback(const v8::FunctionCallback Info<v8::Value>& info)
237 { 229 {
238 if (info.Length() < 3 || !info[0]->IsObject() || !info[1]->IsString()) 230 if (info.Length() < 3 || !info[0]->IsObject() || !info[1]->IsString())
239 return; 231 return;
240 232
241 v8::Local<v8::Object> object = info[0].As<v8::Object>(); 233 v8::Local<v8::Object> object = info[0].As<v8::Object>();
242 v8::Maybe<bool> success = object->DefineOwnProperty(info.GetIsolate()->GetCu rrentContext(), info[1].As<v8::String>(), info[2], v8::DontEnum); 234 v8::Maybe<bool> success = object->DefineOwnProperty(info.GetIsolate()->GetCu rrentContext(), info[1].As<v8::String>(), info[2], v8::DontEnum);
243 ASSERT_UNUSED(!success.IsNothing(), !success.IsNothing()); 235 ASSERT_UNUSED(!success.IsNothing(), !success.IsNothing());
(...skipping 16 matching lines...) Expand all
260 v8::Local<v8::Private> V8Debugger::scopeExtensionPrivate(v8::Isolate* isolate) 252 v8::Local<v8::Private> V8Debugger::scopeExtensionPrivate(v8::Isolate* isolate)
261 { 253 {
262 return v8::Private::ForApi(isolate, toV8StringInternalized(isolate, "V8Debug ger#scopeExtension")); 254 return v8::Private::ForApi(isolate, toV8StringInternalized(isolate, "V8Debug ger#scopeExtension"));
263 } 255 }
264 256
265 bool V8Debugger::isRemoteObjectAPIMethod(const String16& name) 257 bool V8Debugger::isRemoteObjectAPIMethod(const String16& name)
266 { 258 {
267 return name == "bindRemoteObject"; 259 return name == "bindRemoteObject";
268 } 260 }
269 261
270 namespace {
271
272 char hiddenPropertyName[] = "v8inspector::InjectedScriptHost";
273 char className[] = "V8InjectedScriptHost";
274 using InjectedScriptHostWrapper = InspectorWrapper<InjectedScriptHost, hiddenPro pertyName, className>;
275
276 const InjectedScriptHostWrapper::V8MethodConfiguration V8InjectedScriptHostMetho ds[] = {
277 {"internalConstructorName", V8InjectedScriptHost::internalConstructorNameCal lback},
278 {"formatAccessorsAsProperties", V8InjectedScriptHost::formatAccessorsAsPrope rties},
279 {"isTypedArray", V8InjectedScriptHost::isTypedArrayCallback},
280 {"subtype", V8InjectedScriptHost::subtypeCallback},
281 {"collectionEntries", V8InjectedScriptHost::collectionEntriesCallback},
282 {"getInternalProperties", V8InjectedScriptHost::getInternalPropertiesCallbac k},
283 {"getEventListeners", V8InjectedScriptHost::getEventListenersCallback},
284 {"callFunction", V8InjectedScriptHost::callFunctionCallback},
285 {"suppressWarningsAndCallFunction", V8InjectedScriptHost::suppressWarningsAn dCallFunctionCallback},
286 {"setNonEnumProperty", V8InjectedScriptHost::setNonEnumPropertyCallback},
287 {"bind", V8InjectedScriptHost::bindCallback}
288 };
289
290 } // namespace
291
292 v8::Local<v8::FunctionTemplate> V8InjectedScriptHost::createWrapperTemplate(v8:: Isolate* isolate)
293 {
294 protocol::Vector<InspectorWrapperBase::V8MethodConfiguration> methods(WTF_AR RAY_LENGTH(V8InjectedScriptHostMethods));
295 std::copy(V8InjectedScriptHostMethods, V8InjectedScriptHostMethods + WTF_ARR AY_LENGTH(V8InjectedScriptHostMethods), methods.begin());
296 protocol::Vector<InspectorWrapperBase::V8AttributeConfiguration> attributes;
297 return InjectedScriptHostWrapper::createWrapperTemplate(isolate, methods, at tributes);
298 }
299
300 v8::Local<v8::Object> V8InjectedScriptHost::wrap(v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context, InjectedScriptHost* host)
301 {
302 return InjectedScriptHostWrapper::wrap(constructorTemplate, context, host);
303 }
304
305 InjectedScriptHost* V8InjectedScriptHost::unwrap(v8::Local<v8::Context> context, v8::Local<v8::Object> object)
306 {
307 return InjectedScriptHostWrapper::unwrap(context, object);
308 }
309
310 } // namespace blink 262 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698