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

Unified Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp

Issue 1815753002: [DevTools] Move getFunctionDetails to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-get-internal-properties
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/V8DebuggerAgentImpl.cpp
diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp
index b269a5a39b8ed0bdbcba6a3407bd34d173a6d608..8a9c4d1eed6d71f5e6487d76c3883dae8c1f2b82 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp
@@ -687,7 +687,57 @@ void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const Str
InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript(errorString, remoteId.get());
if (!injectedScript)
return;
- injectedScript->getFunctionDetails(errorString, functionId, details);
+
+ v8::HandleScope scope(m_isolate);
+ v8::Local<v8::Context> context = injectedScript->context();
+ v8::Context::Scope contextScope(context);
+
+ v8::Local<v8::Value> value;
+ if (!injectedScript->findObject(errorString, *remoteId, &value))
+ return;
+ if (!value->IsObject() || !value->IsFunction()) {
dgozman 2016/03/18 23:27:55 Only function.
kozy 2016/03/19 00:40:23 Done.
+ *errorString = "Cannot resolve function by id";
dgozman 2016/03/18 23:27:55 Value with given id is not a function.
kozy 2016/03/19 00:40:23 Done.
+ return;
+ }
+ v8::Local<v8::Function> function = value.As<v8::Function>();
+
+ v8::Local<v8::Value> scopesValue;
+ v8::Local<v8::Array> scopes;
+ String16 objectGroupName = injectedScript->objectGroupName(*remoteId);
+ if (m_debugger->functionScopes(function).ToLocal(&scopesValue) && scopesValue->IsArray()) {
+ scopes = scopesValue.As<v8::Array>();
+ for (size_t i = 0; i < scopes->Length(); ++i) {
+ v8::Local<v8::Value> scope;
+ if (!scopes->Get(injectedScript->context(), i).ToLocal(&scope) || !scope->IsObject()) {
+ *errorString = "Internal error";
+ return;
+ }
+ if (!injectedScript->wrapObjectProperty(errorString, scope.As<v8::Object>(), toV8String(injectedScript->isolate(), "object"), objectGroupName))
+ return;
+ }
+ }
+
+ OwnPtr<protocol::Debugger::Location> location = protocol::Debugger::Location::create()
+ .setScriptId(String16::number(function->ScriptId()))
+ .setLineNumber(function->GetScriptLineNumber())
+ .setColumnNumber(function->GetScriptColumnNumber()).build();
+
+ OwnPtr<FunctionDetails> functionDetails = FunctionDetails::create()
+ .setLocation(location.release())
+ .setFunctionName(toProtocolStringWithTypeCheck(function->GetDebugName()))
+ .setIsGenerator(function->IsGeneratorFunction()).build();
+
+ if (!scopes.IsEmpty()) {
+ protocol::ErrorSupport errorSupport;
+ OwnPtr<protocol::Array<protocol::Debugger::Scope>> scopeChain = protocol::Array<protocol::Debugger::Scope>::parse(toProtocolValue(injectedScript->context(), scopes).get(), &errorSupport);
+ if (errorSupport.hasErrors()) {
+ *errorString = "Internal error";
+ return;
+ }
+ functionDetails->setScopeChain(scopeChain.release());
+ }
+
+ *details = functionDetails.release();
}
void V8DebuggerAgentImpl::getGeneratorObjectDetails(ErrorString* errorString, const String16& objectId, OwnPtr<GeneratorObjectDetails>* outDetails)
@@ -710,7 +760,7 @@ void V8DebuggerAgentImpl::getGeneratorObjectDetails(ErrorString* errorString, co
if (!injectedScript->findObject(errorString, *remoteId, &value))
return;
if (!value->IsObject() || !value->ToObject(context).ToLocal(&object)) {
- *errorString = "Could not find object with type Object and given id";
+ *errorString = "Cannot resolve function by id.";
dgozman 2016/03/18 23:27:55 revert
kozy 2016/03/19 00:40:23 Done.
return;
}

Powered by Google App Engine
This is Rietveld 408576698