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

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

Issue 1818473002: [DevTools] Move getInternalProperties to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-call-function-on
Patch Set: Created 4 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 namespace blink { 43 namespace blink {
44 44
45 namespace V8RuntimeAgentImplState { 45 namespace V8RuntimeAgentImplState {
46 static const char customObjectFormatterEnabled[] = "customObjectFormatterEnabled "; 46 static const char customObjectFormatterEnabled[] = "customObjectFormatterEnabled ";
47 }; 47 };
48 48
49 using protocol::Runtime::ExceptionDetails; 49 using protocol::Runtime::ExceptionDetails;
50 using protocol::Runtime::RemoteObject; 50 using protocol::Runtime::RemoteObject;
51 51
52 static bool checkInternalError(ErrorString* errorString, bool success)
53 {
54 if (!success)
55 *errorString = "Internal error";
56 return success;
57 }
58
52 PassOwnPtr<V8RuntimeAgent> V8RuntimeAgent::create(V8Debugger* debugger, int cont extGroupId) 59 PassOwnPtr<V8RuntimeAgent> V8RuntimeAgent::create(V8Debugger* debugger, int cont extGroupId)
53 { 60 {
54 return adoptPtr(new V8RuntimeAgentImpl(static_cast<V8DebuggerImpl*>(debugger ), contextGroupId)); 61 return adoptPtr(new V8RuntimeAgentImpl(static_cast<V8DebuggerImpl*>(debugger ), contextGroupId));
55 } 62 }
56 63
57 V8RuntimeAgentImpl::V8RuntimeAgentImpl(V8DebuggerImpl* debugger, int contextGrou pId) 64 V8RuntimeAgentImpl::V8RuntimeAgentImpl(V8DebuggerImpl* debugger, int contextGrou pId)
58 : m_contextGroupId(contextGroupId) 65 : m_contextGroupId(contextGroupId)
59 , m_state(nullptr) 66 , m_state(nullptr)
60 , m_frontend(nullptr) 67 , m_frontend(nullptr)
61 , m_injectedScriptManager(InjectedScriptManager::create(debugger)) 68 , m_injectedScriptManager(InjectedScriptManager::create(debugger))
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 v8::HandleScope scope(injectedScript->isolate()); 159 v8::HandleScope scope(injectedScript->isolate());
153 v8::Local<v8::Context> localContext = injectedScript->context(); 160 v8::Local<v8::Context> localContext = injectedScript->context();
154 v8::Context::Scope contextScope(localContext); 161 v8::Context::Scope contextScope(localContext);
155 162
156 if (!injectedScript->canAccessInspectedWindow()) { 163 if (!injectedScript->canAccessInspectedWindow()) {
157 *errorString = "Can not access given context"; 164 *errorString = "Can not access given context";
158 return; 165 return;
159 } 166 }
160 167
161 String16 objectGroupName = injectedScript->objectGroupName(*remoteId); 168 String16 objectGroupName = injectedScript->objectGroupName(*remoteId);
162 v8::Local<v8::Value> object = injectedScript->findObject(*remoteId); 169 v8::Local<v8::Value> object;
163 if (object.IsEmpty()) { 170 if (!injectedScript->findObject(errorString, *remoteId, &object))
164 *errorString = "Could not find object with given id";
165 return; 171 return;
166 }
167 OwnPtr<v8::Local<v8::Value>[]> argv = nullptr; 172 OwnPtr<v8::Local<v8::Value>[]> argv = nullptr;
168 int argc = 0; 173 int argc = 0;
169 if (optionalArguments.isJust()) { 174 if (optionalArguments.isJust()) {
170 protocol::Array<protocol::Runtime::CallArgument>* arguments = optionalAr guments.fromJust(); 175 protocol::Array<protocol::Runtime::CallArgument>* arguments = optionalAr guments.fromJust();
171 argc = arguments->length(); 176 argc = arguments->length();
172 argv = adoptArrayPtr(new v8::Local<v8::Value>[argc]); 177 argv = adoptArrayPtr(new v8::Local<v8::Value>[argc]);
173 for (int i = 0; i < argc; ++i) { 178 for (int i = 0; i < argc; ++i) {
174 v8::Local<v8::Value> argumentValue; 179 v8::Local<v8::Value> argumentValue;
175 if (!injectedScript->resolveCallArgument(errorString, arguments->get (i)).ToLocal(&argumentValue)) 180 if (!injectedScript->resolveCallArgument(errorString, arguments->get (i)).ToLocal(&argumentValue))
176 return; 181 return;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 void V8RuntimeAgentImpl::getProperties( 215 void V8RuntimeAgentImpl::getProperties(
211 ErrorString* errorString, 216 ErrorString* errorString,
212 const String16& objectId, 217 const String16& objectId,
213 const Maybe<bool>& ownProperties, 218 const Maybe<bool>& ownProperties,
214 const Maybe<bool>& accessorPropertiesOnly, 219 const Maybe<bool>& accessorPropertiesOnly,
215 const Maybe<bool>& generatePreview, 220 const Maybe<bool>& generatePreview,
216 OwnPtr<protocol::Array<protocol::Runtime::PropertyDescriptor>>* result, 221 OwnPtr<protocol::Array<protocol::Runtime::PropertyDescriptor>>* result,
217 Maybe<protocol::Array<protocol::Runtime::InternalPropertyDescriptor>>* inter nalProperties, 222 Maybe<protocol::Array<protocol::Runtime::InternalPropertyDescriptor>>* inter nalProperties,
218 Maybe<ExceptionDetails>* exceptionDetails) 223 Maybe<ExceptionDetails>* exceptionDetails)
219 { 224 {
225 using protocol::Runtime::InternalPropertyDescriptor;
226
220 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, objectI d); 227 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, objectI d);
221 if (!remoteId) 228 if (!remoteId)
222 return; 229 return;
223 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get()); 230 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get());
224 if (!injectedScript) 231 if (!injectedScript)
225 return; 232 return;
226 233
227 IgnoreExceptionsScope ignoreExceptionsScope(m_debugger); 234 IgnoreExceptionsScope ignoreExceptionsScope(m_debugger);
228 235
236 v8::HandleScope handles(injectedScript->isolate());
237 v8::Context::Scope scope(injectedScript->context());
238 v8::Local<v8::Value> object;
239 if (!injectedScript->findObject(errorString, *remoteId, &object))
240 return;
241 String16 objectGroupName = injectedScript->objectGroupName(*remoteId);
242
229 injectedScript->getProperties(errorString, objectId, ownProperties.fromMaybe (false), accessorPropertiesOnly.fromMaybe(false), generatePreview.fromMaybe(fals e), result, exceptionDetails); 243 injectedScript->getProperties(errorString, objectId, ownProperties.fromMaybe (false), accessorPropertiesOnly.fromMaybe(false), generatePreview.fromMaybe(fals e), result, exceptionDetails);
230 244 if (!object->IsSymbol() && errorString->isEmpty() && !exceptionDetails->isJu st() && !accessorPropertiesOnly.fromMaybe(false)) {
dgozman 2016/03/18 23:07:49 if (error) return with error; if (isSymbol) return
kozy 2016/03/18 23:58:34 Done.
231 if (errorString->isEmpty() && !exceptionDetails->isJust() && !accessorProper tiesOnly.fromMaybe(false)) 245 v8::Local<v8::Array> propertiesArray;
232 injectedScript->getInternalProperties(errorString, objectId, internalPro perties, exceptionDetails); 246 if (!v8::Debug::GetInternalProperties(injectedScript->isolate(), object) .ToLocal(&propertiesArray))
247 return;
dgozman 2016/03/18 23:07:49 errorString!
kozy 2016/03/18 23:58:34 Done.
248 OwnPtr<protocol::Array<InternalPropertyDescriptor>> propertiesProtocolAr ray = protocol::Array<InternalPropertyDescriptor>::create();
249 for (uint32_t i = 0; i < propertiesArray->Length(); i += 2) {
250 v8::Local<v8::Value> name;
251 if (!checkInternalError(errorString, propertiesArray->Get(injectedSc ript->context(), i).ToLocal(&name)) || !name->IsString())
252 return;
253 v8::Local<v8::Value> value;
254 if (!checkInternalError(errorString, propertiesArray->Get(injectedSc ript->context(), i + 1).ToLocal(&value)))
255 return;
256 OwnPtr<RemoteObject> wrappedValue = injectedScript->wrapObject(error String, value, objectGroupName);
257 if (!wrappedValue)
258 return;
259 propertiesProtocolArray->addItem(InternalPropertyDescriptor::create( )
260 .setName(toProtocolString(name.As<v8::String>()))
261 .setValue(wrappedValue.release()).build());
262 }
263 if (propertiesProtocolArray->length() > 0)
264 *internalProperties = propertiesProtocolArray.release();
265 }
233 } 266 }
234 267
235 void V8RuntimeAgentImpl::releaseObject(ErrorString* errorString, const String16& objectId) 268 void V8RuntimeAgentImpl::releaseObject(ErrorString* errorString, const String16& objectId)
236 { 269 {
237 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, objectI d); 270 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, objectI d);
238 if (!remoteId) 271 if (!remoteId)
239 return; 272 return;
240 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get()); 273 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get());
241 if (!injectedScript) 274 if (!injectedScript)
242 return; 275 return;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 481
449 v8::Local<v8::Value> V8RuntimeAgentImpl::findObject(ErrorString* errorString, co nst String16& objectId, v8::Local<v8::Context>* context, String16* groupName) 482 v8::Local<v8::Value> V8RuntimeAgentImpl::findObject(ErrorString* errorString, co nst String16& objectId, v8::Local<v8::Context>* context, String16* groupName)
450 { 483 {
451 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, objectI d); 484 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, objectI d);
452 if (!remoteId) 485 if (!remoteId)
453 return v8::Local<v8::Value>(); 486 return v8::Local<v8::Value>();
454 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get()); 487 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get());
455 if (!injectedScript) 488 if (!injectedScript)
456 return v8::Local<v8::Value>(); 489 return v8::Local<v8::Value>();
457 if (context) 490 if (context)
458 *context = injectedScript->context(); 491 *context = injectedScript->context();
dgozman 2016/03/18 23:07:50 Should not set context if object was not found.
kozy 2016/03/18 23:58:34 Done.
459 if (groupName) 492 if (groupName)
460 *groupName = injectedScript->objectGroupName(*remoteId); 493 *groupName = injectedScript->objectGroupName(*remoteId);
461 return injectedScript->findObject(*remoteId); 494 v8::Local<v8::Value> objectValue;
495 injectedScript->findObject(errorString, *remoteId, &objectValue);
496 return objectValue;
462 } 497 }
463 498
464 void V8RuntimeAgentImpl::addInspectedObject(PassOwnPtr<Inspectable> inspectable) 499 void V8RuntimeAgentImpl::addInspectedObject(PassOwnPtr<Inspectable> inspectable)
465 { 500 {
466 m_injectedScriptManager->injectedScriptHost()->addInspectedObject(inspectabl e); 501 m_injectedScriptManager->injectedScriptHost()->addInspectedObject(inspectabl e);
467 } 502 }
468 503
469 void V8RuntimeAgentImpl::clearInspectedObjects() 504 void V8RuntimeAgentImpl::clearInspectedObjects()
470 { 505 {
471 m_injectedScriptManager->injectedScriptHost()->clearInspectedObjects(); 506 m_injectedScriptManager->injectedScriptHost()->clearInspectedObjects();
(...skipping 19 matching lines...) Expand all
491 526
492 void V8RuntimeAgentImpl::reportExecutionContextDestroyed(v8::Local<v8::Context> context) 527 void V8RuntimeAgentImpl::reportExecutionContextDestroyed(v8::Local<v8::Context> context)
493 { 528 {
494 int contextId = m_injectedScriptManager->discardInjectedScriptFor(context); 529 int contextId = m_injectedScriptManager->discardInjectedScriptFor(context);
495 if (!m_enabled) 530 if (!m_enabled)
496 return; 531 return;
497 m_frontend->executionContextDestroyed(contextId); 532 m_frontend->executionContextDestroyed(contextId);
498 } 533 }
499 534
500 } // namespace blink 535 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698