Chromium Code Reviews| 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 dfe9817cd5ed84a783f61720c3f5cda937b24293..8b40ecffaa4b6a05af417f2e4d6e4547b1f52a3f 100644 |
| --- a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp |
| +++ b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp |
| @@ -649,9 +649,25 @@ void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, |
| } |
| v8::HandleScope scope(m_isolate); |
| - v8::Local<v8::Object> callStack = m_currentCallStack.Get(m_isolate); |
| - injectedScript->restartFrame(errorString, callStack, callFrameId); |
| + v8::Local<v8::Context> localContext = injectedScript->context(); |
| + v8::Context::Scope contextScope(localContext); |
| + |
| + v8::TryCatch tryCatch(m_isolate); |
| + |
| + OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrameNoScopes(remoteId->frameOrdinal()); |
| + if (!javaScriptCallFrame) { |
| + *errorString = "Could not find call frame with given id"; |
| + return; |
| + } |
| + v8::Local<v8::Value> resultValue; |
| + v8::Local<v8::Boolean> result; |
| + if (!javaScriptCallFrame->restart().ToLocal(&resultValue) || tryCatch.HasCaught() || !resultValue->ToBoolean(localContext).ToLocal(&result) || !result->Value()) { |
| + *errorString = "Internal error"; |
| + return; |
| + } |
| + |
| m_currentCallStack.Reset(m_isolate, debugger().currentCallFrames()); |
| + |
| *newCallFrames = currentCallFrames(); |
| *asyncStackTrace = currentAsyncStackTrace(); |
| } |
| @@ -920,41 +936,97 @@ void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, |
| { |
| if (!checkEnabled(errorString)) |
| return; |
| - InjectedScript* injectedScript = nullptr; |
| if (callFrameId.isJust()) { |
| - if (!isPaused() || m_currentCallStack.IsEmpty()) { |
| - *errorString = "Attempt to access callframe when debugger is not on pause"; |
| - return; |
| - } |
| - OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId.fromJust()); |
| - if (!remoteId) { |
| - *errorString = "Invalid call frame id"; |
| - return; |
| - } |
| - injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.get()); |
| - if (!injectedScript) { |
| - *errorString = "Inspected frame has gone"; |
| - return; |
| - } |
| + setCallFrameVariableValue(errorString, scopeNumber, variableName, newValue, callFrameId); |
| } else if (functionObjectId.isJust()) { |
| - OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionObjectId.fromJust()); |
| - if (!remoteId) { |
| - *errorString = "Invalid object id"; |
| - return; |
| - } |
| - injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.get()); |
| - if (!injectedScript) { |
| - *errorString = "Function object id cannot be resolved"; |
| - return; |
| - } |
| + setFunctionVariableValue(errorString, scopeNumber, variableName, newValue, functionObjectId); |
| } else { |
| *errorString = "Either call frame or function object must be specified"; |
| return; |
| } |
| - String16 newValueString = protocol::toValue(newValue.get())->toJSONString(); |
| +} |
| + |
| +void V8DebuggerAgentImpl::setCallFrameVariableValue(ErrorString* errorString, |
| + int scopeNumber, |
| + const String16& variableName, |
| + PassOwnPtr<protocol::Runtime::CallArgument> newValueArgument, |
| + const Maybe<String16>& callFrameId) |
| +{ |
| + if (!isPaused() || m_currentCallStack.IsEmpty()) { |
| + *errorString = "Attempt to access callframe when debugger is not on pause"; |
| + return; |
| + } |
| + OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId.fromJust()); |
| + if (!remoteId) { |
| + *errorString = "Invalid call frame id"; |
| + return; |
| + } |
| + InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.get()); |
| + if (!injectedScript) { |
| + *errorString = "Inspected frame has gone"; |
| + return; |
| + } |
| + |
| v8::HandleScope scope(m_isolate); |
| - v8::Local<v8::Object> currentCallStack = m_currentCallStack.Get(m_isolate); |
| - injectedScript->setVariableValue(errorString, currentCallStack, callFrameId, functionObjectId, scopeNumber, variableName, newValueString); |
| + v8::Local<v8::Context> localContext = injectedScript->context(); |
| + v8::Context::Scope contextScope(localContext); |
| + |
| + v8::TryCatch tryCatch(m_isolate); |
| + |
| + v8::Local<v8::Value> newValue; |
| + if (!injectedScript->resolveCallArgument(errorString, newValueArgument.get()).ToLocal(&newValue)) |
| + return; |
| + |
| + OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrameNoScopes(remoteId->frameOrdinal()); |
| + if (!javaScriptCallFrame) { |
| + *errorString = "Could not find call frame with given id"; |
| + return; |
| + } |
| + v8::MaybeLocal<v8::Value> result = javaScriptCallFrame->setVariableValue(scopeNumber, toV8String(m_isolate, variableName), newValue); |
| + if (tryCatch.HasCaught() || result.IsEmpty()) { |
| + *errorString = "Internal error"; |
| + return; |
| + } |
| +} |
| + |
| +void V8DebuggerAgentImpl::setFunctionVariableValue(ErrorString* errorString, |
| + int scopeNumber, |
| + const String16& variableName, |
| + PassOwnPtr<protocol::Runtime::CallArgument> newValueArgument, |
| + const Maybe<String16>& functionObjectId) |
| +{ |
| + OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionObjectId.fromJust()); |
| + if (!remoteId) { |
| + *errorString = "Invalid object id"; |
| + return; |
| + } |
| + InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.get()); |
| + if (!injectedScript) { |
| + *errorString = "Function object id cannot be resolved"; |
| + return; |
| + } |
| + |
| + v8::HandleScope scope(m_isolate); |
| + v8::Local<v8::Context> localContext = injectedScript->context(); |
| + v8::Context::Scope contextScope(localContext); |
| + |
| + v8::TryCatch tryCatch(m_isolate); |
| + |
| + v8::Local<v8::Value> newValue; |
| + if (!injectedScript->resolveCallArgument(errorString, newValueArgument.get()).ToLocal(&newValue)) |
|
pfeldman
2016/03/11 22:04:44
Can you extract resolving of the value using its i
kozy
2016/03/11 23:55:17
Removed setFunctionVariableValue.
|
| + return; |
| + |
| + v8::Local<v8::Value> functionValue = injectedScript->findObject(*remoteId); |
| + if (functionValue.IsEmpty() || !functionValue->IsFunction()) { |
| + *errorString = "Could not resolve function by id"; |
| + return; |
| + } |
| + |
| + v8::MaybeLocal<v8::Value> result = debugger().setFunctionVariableValue(functionValue, scopeNumber, variableName, newValue); |
| + if (tryCatch.HasCaught() || result.IsEmpty()) { |
| + *errorString = "Internal error"; |
| + return; |
| + } |
| } |
| void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int depth) |