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

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

Issue 1786243002: [DevTools] Move restartFrame and setCallFrameVariableValue to V8DebuggerAgent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dgozman-patch
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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" 5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
6 6
7 #include "platform/inspector_protocol/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/inspector_protocol/Values.h" 8 #include "platform/inspector_protocol/Values.h"
9 #include "platform/v8_inspector/IgnoreExceptionsScope.h" 9 #include "platform/v8_inspector/IgnoreExceptionsScope.h"
10 #include "platform/v8_inspector/InjectedScript.h" 10 #include "platform/v8_inspector/InjectedScript.h"
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 *errorString = "Invalid call frame id"; 642 *errorString = "Invalid call frame id";
643 return; 643 return;
644 } 644 }
645 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (remoteId.get()); 645 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (remoteId.get());
646 if (!injectedScript) { 646 if (!injectedScript) {
647 *errorString = "Inspected frame has gone"; 647 *errorString = "Inspected frame has gone";
648 return; 648 return;
649 } 649 }
650 650
651 v8::HandleScope scope(m_isolate); 651 v8::HandleScope scope(m_isolate);
652 v8::Local<v8::Object> callStack = m_currentCallStack.Get(m_isolate); 652 v8::Local<v8::Context> localContext = injectedScript->context();
653 injectedScript->restartFrame(errorString, callStack, callFrameId); 653 v8::Context::Scope contextScope(localContext);
654
655 v8::TryCatch tryCatch(m_isolate);
656
657 OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrameNoScop es(remoteId->frameOrdinal());
658 if (!javaScriptCallFrame) {
659 *errorString = "Could not find call frame with given id";
660 return;
661 }
662 v8::Local<v8::Value> resultValue;
663 v8::Local<v8::Boolean> result;
664 if (!javaScriptCallFrame->restart().ToLocal(&resultValue) || tryCatch.HasCau ght() || !resultValue->ToBoolean(localContext).ToLocal(&result) || !result->Valu e()) {
665 *errorString = "Internal error";
666 return;
667 }
668
654 m_currentCallStack.Reset(m_isolate, debugger().currentCallFrames()); 669 m_currentCallStack.Reset(m_isolate, debugger().currentCallFrames());
670
655 *newCallFrames = currentCallFrames(); 671 *newCallFrames = currentCallFrames();
656 *asyncStackTrace = currentAsyncStackTrace(); 672 *asyncStackTrace = currentAsyncStackTrace();
657 } 673 }
658 674
659 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc riptId, String16* scriptSource) 675 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc riptId, String16* scriptSource)
660 { 676 {
661 if (!checkEnabled(error)) 677 if (!checkEnabled(error))
662 return; 678 return;
663 ScriptsMap::iterator it = m_scripts.find(scriptId); 679 ScriptsMap::iterator it = m_scripts.find(scriptId);
664 if (it == m_scripts.end()) { 680 if (it == m_scripts.end()) {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 929
914 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, 930 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString,
915 int scopeNumber, 931 int scopeNumber,
916 const String16& variableName, 932 const String16& variableName,
917 PassOwnPtr<protocol::Runtime::CallArgument> newValue, 933 PassOwnPtr<protocol::Runtime::CallArgument> newValue,
918 const Maybe<String16>& callFrameId, 934 const Maybe<String16>& callFrameId,
919 const Maybe<String16>& functionObjectId) 935 const Maybe<String16>& functionObjectId)
920 { 936 {
921 if (!checkEnabled(errorString)) 937 if (!checkEnabled(errorString))
922 return; 938 return;
923 InjectedScript* injectedScript = nullptr;
924 if (callFrameId.isJust()) { 939 if (callFrameId.isJust()) {
925 if (!isPaused() || m_currentCallStack.IsEmpty()) { 940 setCallFrameVariableValue(errorString, scopeNumber, variableName, newVal ue, callFrameId);
926 *errorString = "Attempt to access callframe when debugger is not on pause";
927 return;
928 }
929 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameI d.fromJust());
930 if (!remoteId) {
931 *errorString = "Invalid call frame id";
932 return;
933 }
934 injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.ge t());
935 if (!injectedScript) {
936 *errorString = "Inspected frame has gone";
937 return;
938 }
939 } else if (functionObjectId.isJust()) { 941 } else if (functionObjectId.isJust()) {
940 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionObjectId .fromJust()); 942 setFunctionVariableValue(errorString, scopeNumber, variableName, newValu e, functionObjectId);
941 if (!remoteId) {
942 *errorString = "Invalid object id";
943 return;
944 }
945 injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.ge t());
946 if (!injectedScript) {
947 *errorString = "Function object id cannot be resolved";
948 return;
949 }
950 } else { 943 } else {
951 *errorString = "Either call frame or function object must be specified"; 944 *errorString = "Either call frame or function object must be specified";
952 return; 945 return;
953 } 946 }
954 String16 newValueString = protocol::toValue(newValue.get())->toJSONString(); 947 }
948
949 void V8DebuggerAgentImpl::setCallFrameVariableValue(ErrorString* errorString,
950 int scopeNumber,
951 const String16& variableName,
952 PassOwnPtr<protocol::Runtime::CallArgument> newValueArgument,
953 const Maybe<String16>& callFrameId)
954 {
955 if (!isPaused() || m_currentCallStack.IsEmpty()) {
956 *errorString = "Attempt to access callframe when debugger is not on paus e";
957 return;
958 }
959 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId.fr omJust());
960 if (!remoteId) {
961 *errorString = "Invalid call frame id";
962 return;
963 }
964 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (remoteId.get());
965 if (!injectedScript) {
966 *errorString = "Inspected frame has gone";
967 return;
968 }
969
955 v8::HandleScope scope(m_isolate); 970 v8::HandleScope scope(m_isolate);
956 v8::Local<v8::Object> currentCallStack = m_currentCallStack.Get(m_isolate); 971 v8::Local<v8::Context> localContext = injectedScript->context();
957 injectedScript->setVariableValue(errorString, currentCallStack, callFrameId, functionObjectId, scopeNumber, variableName, newValueString); 972 v8::Context::Scope contextScope(localContext);
973
974 v8::TryCatch tryCatch(m_isolate);
975
976 v8::Local<v8::Value> newValue;
977 if (!injectedScript->resolveCallArgument(errorString, newValueArgument.get() ).ToLocal(&newValue))
978 return;
979
980 OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrameNoScop es(remoteId->frameOrdinal());
981 if (!javaScriptCallFrame) {
982 *errorString = "Could not find call frame with given id";
983 return;
984 }
985 v8::MaybeLocal<v8::Value> result = javaScriptCallFrame->setVariableValue(sco peNumber, toV8String(m_isolate, variableName), newValue);
986 if (tryCatch.HasCaught() || result.IsEmpty()) {
987 *errorString = "Internal error";
988 return;
989 }
990 }
991
992 void V8DebuggerAgentImpl::setFunctionVariableValue(ErrorString* errorString,
993 int scopeNumber,
994 const String16& variableName,
995 PassOwnPtr<protocol::Runtime::CallArgument> newValueArgument,
996 const Maybe<String16>& functionObjectId)
997 {
998 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionObjectId.fro mJust());
999 if (!remoteId) {
1000 *errorString = "Invalid object id";
1001 return;
1002 }
1003 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (remoteId.get());
1004 if (!injectedScript) {
1005 *errorString = "Function object id cannot be resolved";
1006 return;
1007 }
1008
1009 v8::HandleScope scope(m_isolate);
1010 v8::Local<v8::Context> localContext = injectedScript->context();
1011 v8::Context::Scope contextScope(localContext);
1012
1013 v8::TryCatch tryCatch(m_isolate);
1014
1015 v8::Local<v8::Value> newValue;
1016 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.
1017 return;
1018
1019 v8::Local<v8::Value> functionValue = injectedScript->findObject(*remoteId);
1020 if (functionValue.IsEmpty() || !functionValue->IsFunction()) {
1021 *errorString = "Could not resolve function by id";
1022 return;
1023 }
1024
1025 v8::MaybeLocal<v8::Value> result = debugger().setFunctionVariableValue(funct ionValue, scopeNumber, variableName, newValue);
1026 if (tryCatch.HasCaught() || result.IsEmpty()) {
1027 *errorString = "Internal error";
1028 return;
1029 }
958 } 1030 }
959 1031
960 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d epth) 1032 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d epth)
961 { 1033 {
962 if (!checkEnabled(errorString)) 1034 if (!checkEnabled(errorString))
963 return; 1035 return;
964 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth); 1036 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth);
965 internalSetAsyncCallStackDepth(depth); 1037 internalSetAsyncCallStackDepth(depth);
966 } 1038 }
967 1039
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 m_scripts.clear(); 1601 m_scripts.clear();
1530 m_blackboxedPositions.clear(); 1602 m_blackboxedPositions.clear();
1531 m_breakpointIdToDebuggerBreakpointIds.clear(); 1603 m_breakpointIdToDebuggerBreakpointIds.clear();
1532 resetAsyncCallTracker(); 1604 resetAsyncCallTracker();
1533 m_promiseTracker->clear(); 1605 m_promiseTracker->clear();
1534 if (m_frontend) 1606 if (m_frontend)
1535 m_frontend->globalObjectCleared(); 1607 m_frontend->globalObjectCleared();
1536 } 1608 }
1537 1609
1538 } // namespace blink 1610 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698