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

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

Issue 1921413002: [DevTools] Move inspect and copy to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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/inspector_protocol/Values.h"
9 #include "platform/v8_inspector/InjectedScript.h" 9 #include "platform/v8_inspector/InjectedScript.h"
10 #include "platform/v8_inspector/InjectedScriptHost.h" 10 #include "platform/v8_inspector/InjectedScriptHost.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 for (const auto& it : types) { 182 for (const auto& it : types) {
183 v8::Local<v8::Array> listeners = wrapListenerFunctions(info.GetIsolate() , listenerInfo, it.first); 183 v8::Local<v8::Array> listeners = wrapListenerFunctions(info.GetIsolate() , listenerInfo, it.first);
184 if (!listeners->Length()) 184 if (!listeners->Length())
185 continue; 185 continue;
186 result->Set(toV8String(info.GetIsolate(), it.first), listeners); 186 result->Set(toV8String(info.GetIsolate(), it.first), listeners);
187 } 187 }
188 188
189 v8SetReturnValue(info, result); 189 v8SetReturnValue(info, result);
190 } 190 }
191 191
192 void V8InjectedScriptHost::inspectCallback(const v8::FunctionCallbackInfo<v8::Va lue>& info)
193 {
194 if (info.Length() < 2)
195 return;
196
197 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
198 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(context, info.Holder ());
199 host->inspectImpl(toProtocolValue(context, info[0]), toProtocolValue(context , info[1]));
200 }
201
202 void V8InjectedScriptHost::callFunctionCallback(const v8::FunctionCallbackInfo<v 8::Value>& info) 192 void V8InjectedScriptHost::callFunctionCallback(const v8::FunctionCallbackInfo<v 8::Value>& info)
203 { 193 {
204 if (info.Length() < 2 || info.Length() > 3 || !info[0]->IsFunction()) { 194 if (info.Length() < 2 || info.Length() > 3 || !info[0]->IsFunction()) {
205 ASSERT_NOT_REACHED(); 195 ASSERT_NOT_REACHED();
206 return; 196 return;
207 } 197 }
208 198
209 v8::MicrotasksScope microtasks(info.GetIsolate(), v8::MicrotasksScope::kDoNo tRunMicrotasks); 199 v8::MicrotasksScope microtasks(info.GetIsolate(), v8::MicrotasksScope::kDoNo tRunMicrotasks);
210 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(info[0]); 200 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(info[0]);
211 v8::Local<v8::Value> receiver = info[1]; 201 v8::Local<v8::Value> receiver = info[1];
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 return name == "bindRemoteObject"; 267 return name == "bindRemoteObject";
278 } 268 }
279 269
280 namespace { 270 namespace {
281 271
282 char hiddenPropertyName[] = "v8inspector::InjectedScriptHost"; 272 char hiddenPropertyName[] = "v8inspector::InjectedScriptHost";
283 char className[] = "V8InjectedScriptHost"; 273 char className[] = "V8InjectedScriptHost";
284 using InjectedScriptHostWrapper = InspectorWrapper<InjectedScriptHost, hiddenPro pertyName, className>; 274 using InjectedScriptHostWrapper = InspectorWrapper<InjectedScriptHost, hiddenPro pertyName, className>;
285 275
286 const InjectedScriptHostWrapper::V8MethodConfiguration V8InjectedScriptHostMetho ds[] = { 276 const InjectedScriptHostWrapper::V8MethodConfiguration V8InjectedScriptHostMetho ds[] = {
287 {"inspect", V8InjectedScriptHost::inspectCallback},
288 {"internalConstructorName", V8InjectedScriptHost::internalConstructorNameCal lback}, 277 {"internalConstructorName", V8InjectedScriptHost::internalConstructorNameCal lback},
289 {"formatAccessorsAsProperties", V8InjectedScriptHost::formatAccessorsAsPrope rties}, 278 {"formatAccessorsAsProperties", V8InjectedScriptHost::formatAccessorsAsPrope rties},
290 {"isTypedArray", V8InjectedScriptHost::isTypedArrayCallback}, 279 {"isTypedArray", V8InjectedScriptHost::isTypedArrayCallback},
291 {"subtype", V8InjectedScriptHost::subtypeCallback}, 280 {"subtype", V8InjectedScriptHost::subtypeCallback},
292 {"collectionEntries", V8InjectedScriptHost::collectionEntriesCallback}, 281 {"collectionEntries", V8InjectedScriptHost::collectionEntriesCallback},
293 {"getInternalProperties", V8InjectedScriptHost::getInternalPropertiesCallbac k}, 282 {"getInternalProperties", V8InjectedScriptHost::getInternalPropertiesCallbac k},
294 {"getEventListeners", V8InjectedScriptHost::getEventListenersCallback}, 283 {"getEventListeners", V8InjectedScriptHost::getEventListenersCallback},
295 {"callFunction", V8InjectedScriptHost::callFunctionCallback}, 284 {"callFunction", V8InjectedScriptHost::callFunctionCallback},
296 {"suppressWarningsAndCallFunction", V8InjectedScriptHost::suppressWarningsAn dCallFunctionCallback}, 285 {"suppressWarningsAndCallFunction", V8InjectedScriptHost::suppressWarningsAn dCallFunctionCallback},
297 {"setNonEnumProperty", V8InjectedScriptHost::setNonEnumPropertyCallback}, 286 {"setNonEnumProperty", V8InjectedScriptHost::setNonEnumPropertyCallback},
(...skipping 14 matching lines...) Expand all
312 { 301 {
313 return InjectedScriptHostWrapper::wrap(constructorTemplate, context, host); 302 return InjectedScriptHostWrapper::wrap(constructorTemplate, context, host);
314 } 303 }
315 304
316 InjectedScriptHost* V8InjectedScriptHost::unwrap(v8::Local<v8::Context> context, v8::Local<v8::Object> object) 305 InjectedScriptHost* V8InjectedScriptHost::unwrap(v8::Local<v8::Context> context, v8::Local<v8::Object> object)
317 { 306 {
318 return InjectedScriptHostWrapper::unwrap(context, object); 307 return InjectedScriptHostWrapper::unwrap(context, object);
319 } 308 }
320 309
321 } // namespace blink 310 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698