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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp
diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp
index 2d50f2ac6d7255da1a5a68c3dc15cf05c9d95e0a..239c8b5b3ae410d6cd44f50ba532d74f74674ef1 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp
@@ -49,6 +49,14 @@ static const char customObjectFormatterEnabled[] = "customObjectFormatterEnabled
using protocol::Runtime::ExceptionDetails;
using protocol::Runtime::RemoteObject;
+static bool Get(ErrorString* errorString, v8::Local<v8::Context> context, v8::Local<v8::Array> array, int index, v8::Local<v8::Value>* value)
+{
+ bool success = array->Get(context, index).ToLocal(value);
+ if (!success)
+ *errorString = "Internal error";
+ return success;
+}
+
PassOwnPtr<V8RuntimeAgent> V8RuntimeAgent::create(V8Debugger* debugger, int contextGroupId)
{
return adoptPtr(new V8RuntimeAgentImpl(static_cast<V8DebuggerImpl*>(debugger), contextGroupId));
@@ -159,11 +167,9 @@ void V8RuntimeAgentImpl::callFunctionOn(ErrorString* errorString,
}
String16 objectGroupName = injectedScript->objectGroupName(*remoteId);
- v8::Local<v8::Value> object = injectedScript->findObject(*remoteId);
- if (object.IsEmpty()) {
- *errorString = "Could not find object with given id";
+ v8::Local<v8::Value> object;
+ if (!injectedScript->findObject(errorString, *remoteId, &object))
return;
- }
OwnPtr<v8::Local<v8::Value>[]> argv = nullptr;
int argc = 0;
if (optionalArguments.isJust()) {
@@ -217,6 +223,8 @@ void V8RuntimeAgentImpl::getProperties(
Maybe<protocol::Array<protocol::Runtime::InternalPropertyDescriptor>>* internalProperties,
Maybe<ExceptionDetails>* exceptionDetails)
{
+ using protocol::Runtime::InternalPropertyDescriptor;
+
OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, objectId);
if (!remoteId)
return;
@@ -226,10 +234,36 @@ void V8RuntimeAgentImpl::getProperties(
IgnoreExceptionsScope ignoreExceptionsScope(m_debugger);
- injectedScript->getProperties(errorString, objectId, ownProperties.fromMaybe(false), accessorPropertiesOnly.fromMaybe(false), generatePreview.fromMaybe(false), result, exceptionDetails);
+ v8::HandleScope handles(injectedScript->isolate());
+ v8::Context::Scope scope(injectedScript->context());
+ v8::Local<v8::Value> object;
+ if (!injectedScript->findObject(errorString, *remoteId, &object))
+ return;
+ String16 objectGroupName = injectedScript->objectGroupName(*remoteId);
- if (errorString->isEmpty() && !exceptionDetails->isJust() && !accessorPropertiesOnly.fromMaybe(false))
- injectedScript->getInternalProperties(errorString, objectId, internalProperties, exceptionDetails);
+ injectedScript->getProperties(errorString, objectId, ownProperties.fromMaybe(false), accessorPropertiesOnly.fromMaybe(false), generatePreview.fromMaybe(false), result, exceptionDetails);
+ if (!object->IsSymbol() && errorString->isEmpty() && !exceptionDetails->isJust() && !accessorPropertiesOnly.fromMaybe(false)) {
+ v8::Local<v8::Array> propertiesArray;
+ if (!v8::Debug::GetInternalProperties(injectedScript->isolate(), object).ToLocal(&propertiesArray))
+ return;
+ OwnPtr<protocol::Array<InternalPropertyDescriptor>> propertiesProtocolArray = protocol::Array<InternalPropertyDescriptor>::create();
+ for (uint32_t i = 0; i < propertiesArray->Length(); i += 2) {
+ v8::Local<v8::Value> name;
+ if (!Get(errorString, injectedScript->context(), propertiesArray, i, &name) || !name->IsString())
+ return;
+ v8::Local<v8::Value> value;
+ if (!Get(errorString, injectedScript->context(), propertiesArray, i + 1, &value))
+ return;
+ OwnPtr<RemoteObject> wrappedValue = injectedScript->wrapObject(errorString, value, objectGroupName);
+ if (!wrappedValue)
+ return;
+ propertiesProtocolArray->addItem(InternalPropertyDescriptor::create()
+ .setName(toProtocolString(name.As<v8::String>()))
+ .setValue(wrappedValue.release()).build());
+ }
+ if (propertiesProtocolArray->length() > 0)
+ *internalProperties = propertiesProtocolArray.release();
+ }
}
void V8RuntimeAgentImpl::releaseObject(ErrorString* errorString, const String16& objectId)
@@ -458,7 +492,9 @@ v8::Local<v8::Value> V8RuntimeAgentImpl::findObject(ErrorString* errorString, co
*context = injectedScript->context();
if (groupName)
*groupName = injectedScript->objectGroupName(*remoteId);
- return injectedScript->findObject(*remoteId);
+ v8::Local<v8::Value> objectValue;
+ injectedScript->findObject(errorString, *remoteId, &objectValue);
+ return objectValue;
}
void V8RuntimeAgentImpl::addInspectedObject(PassOwnPtr<Inspectable> inspectable)

Powered by Google App Engine
This is Rietveld 408576698