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

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
« no previous file with comments | « third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f08606d4c84254ee3b569d7053d82b8d53597201 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp
@@ -49,6 +49,13 @@ static const char customObjectFormatterEnabled[] = "customObjectFormatterEnabled
using protocol::Runtime::ExceptionDetails;
using protocol::Runtime::RemoteObject;
+static bool checkInternalError(ErrorString* errorString, bool success)
+{
+ 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 +166,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 +222,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 +233,39 @@ 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 (!errorString->isEmpty() || exceptionDetails->isJust() || accessorPropertiesOnly.fromMaybe(false))
+ return;
+ if (object->IsSymbol())
+ return;
+ v8::Local<v8::Array> propertiesArray;
+ if (!checkInternalError(errorString, 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 (!checkInternalError(errorString, propertiesArray->Get(injectedScript->context(), i).ToLocal(&name)) && name->IsString())
+ return;
+ v8::Local<v8::Value> value;
+ if (!checkInternalError(errorString, propertiesArray->Get(injectedScript->context(), i + 1).ToLocal(&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())
+ return;
+ *internalProperties = propertiesProtocolArray.release();
}
void V8RuntimeAgentImpl::releaseObject(ErrorString* errorString, const String16& objectId)
@@ -454,11 +490,15 @@ v8::Local<v8::Value> V8RuntimeAgentImpl::findObject(ErrorString* errorString, co
InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript(errorString, remoteId.get());
if (!injectedScript)
return v8::Local<v8::Value>();
+ v8::Local<v8::Value> objectValue;
+ injectedScript->findObject(errorString, *remoteId, &objectValue);
+ if (objectValue.IsEmpty())
+ return v8::Local<v8::Value>();
if (context)
*context = injectedScript->context();
if (groupName)
*groupName = injectedScript->objectGroupName(*remoteId);
- return injectedScript->findObject(*remoteId);
+ return objectValue;
}
void V8RuntimeAgentImpl::addInspectedObject(PassOwnPtr<Inspectable> inspectable)
« 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