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

Side by Side Diff: src/inspector/v8-debugger-agent-impl.cc

Issue 2558913004: [inspector] Store interger in context embedder data instead of a string. (Closed)
Patch Set: review comments Created 4 years 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
« no previous file with comments | « src/inspector/v8-debugger.cc ('k') | src/inspector/v8-debugger-script.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project 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 "src/inspector/v8-debugger-agent-impl.h" 5 #include "src/inspector/v8-debugger-agent-impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/debug/debug-interface.h" 9 #include "src/debug/debug-interface.h"
10 #include "src/inspector/injected-script.h" 10 #include "src/inspector/injected-script.h"
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 } 1043 }
1044 1044
1045 void V8DebuggerAgentImpl::didParseSource( 1045 void V8DebuggerAgentImpl::didParseSource(
1046 std::unique_ptr<V8DebuggerScript> script, bool success) { 1046 std::unique_ptr<V8DebuggerScript> script, bool success) {
1047 v8::HandleScope handles(m_isolate); 1047 v8::HandleScope handles(m_isolate);
1048 String16 scriptSource = script->source(m_isolate); 1048 String16 scriptSource = script->source(m_isolate);
1049 if (!success) script->setSourceURL(findSourceURL(scriptSource, false)); 1049 if (!success) script->setSourceURL(findSourceURL(scriptSource, false));
1050 if (!success) 1050 if (!success)
1051 script->setSourceMappingURL(findSourceMapURL(scriptSource, false)); 1051 script->setSourceMappingURL(findSourceMapURL(scriptSource, false));
1052 1052
1053 int contextId = script->executionContextId();
1054 int contextGroupId = m_inspector->contextGroupId(contextId);
1055 InspectedContext* inspected =
1056 m_inspector->getContext(contextGroupId, contextId);
1053 std::unique_ptr<protocol::DictionaryValue> executionContextAuxData; 1057 std::unique_ptr<protocol::DictionaryValue> executionContextAuxData;
1054 if (!script->executionContextAuxData().isEmpty()) 1058 if (inspected) {
1059 // Script reused between different groups/sessions can have a stale
1060 // execution context id.
1055 executionContextAuxData = protocol::DictionaryValue::cast( 1061 executionContextAuxData = protocol::DictionaryValue::cast(
1056 protocol::StringUtil::parseJSON(script->executionContextAuxData())); 1062 protocol::StringUtil::parseJSON(inspected->auxData()));
1063 }
1057 bool isLiveEdit = script->isLiveEdit(); 1064 bool isLiveEdit = script->isLiveEdit();
1058 bool hasSourceURL = script->hasSourceURL(); 1065 bool hasSourceURL = script->hasSourceURL();
1059 String16 scriptId = script->scriptId(); 1066 String16 scriptId = script->scriptId();
1060 String16 scriptURL = script->sourceURL(); 1067 String16 scriptURL = script->sourceURL();
1061 1068
1062 m_scripts[scriptId] = std::move(script); 1069 m_scripts[scriptId] = std::move(script);
1063 1070
1064 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); 1071 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId);
1065 DCHECK(scriptIterator != m_scripts.end()); 1072 DCHECK(scriptIterator != m_scripts.end());
1066 V8DebuggerScript* scriptRef = scriptIterator->second.get(); 1073 V8DebuggerScript* scriptRef = scriptIterator->second.get();
1067 1074
1068 Maybe<String16> sourceMapURLParam = scriptRef->sourceMappingURL(); 1075 Maybe<String16> sourceMapURLParam = scriptRef->sourceMappingURL();
1069 Maybe<protocol::DictionaryValue> executionContextAuxDataParam( 1076 Maybe<protocol::DictionaryValue> executionContextAuxDataParam(
1070 std::move(executionContextAuxData)); 1077 std::move(executionContextAuxData));
1071 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; 1078 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr;
1072 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; 1079 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr;
1073 if (success) 1080 if (success)
1074 m_frontend.scriptParsed( 1081 m_frontend.scriptParsed(
1075 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), 1082 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(),
1076 scriptRef->endLine(), scriptRef->endColumn(), 1083 scriptRef->endLine(), scriptRef->endColumn(), contextId,
1077 scriptRef->executionContextId(), scriptRef->hash(m_isolate), 1084 scriptRef->hash(m_isolate), std::move(executionContextAuxDataParam),
1078 std::move(executionContextAuxDataParam), isLiveEditParam, 1085 isLiveEditParam, std::move(sourceMapURLParam), hasSourceURLParam);
1079 std::move(sourceMapURLParam), hasSourceURLParam);
1080 else 1086 else
1081 m_frontend.scriptFailedToParse( 1087 m_frontend.scriptFailedToParse(
1082 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), 1088 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(),
1083 scriptRef->endLine(), scriptRef->endColumn(), 1089 scriptRef->endLine(), scriptRef->endColumn(), contextId,
1084 scriptRef->executionContextId(), scriptRef->hash(m_isolate), 1090 scriptRef->hash(m_isolate), std::move(executionContextAuxDataParam),
1085 std::move(executionContextAuxDataParam), std::move(sourceMapURLParam), 1091 std::move(sourceMapURLParam), hasSourceURLParam);
1086 hasSourceURLParam);
1087 1092
1088 if (scriptURL.isEmpty() || !success) return; 1093 if (scriptURL.isEmpty() || !success) return;
1089 1094
1090 protocol::DictionaryValue* breakpointsCookie = 1095 protocol::DictionaryValue* breakpointsCookie =
1091 m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); 1096 m_state->getObject(DebuggerAgentState::javaScriptBreakpoints);
1092 if (!breakpointsCookie) return; 1097 if (!breakpointsCookie) return;
1093 1098
1094 for (size_t i = 0; i < breakpointsCookie->size(); ++i) { 1099 for (size_t i = 0; i < breakpointsCookie->size(); ++i) {
1095 auto cookie = breakpointsCookie->at(i); 1100 auto cookie = breakpointsCookie->at(i);
1096 protocol::DictionaryValue* breakpointObject = 1101 protocol::DictionaryValue* breakpointObject =
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 if (!topCallFrame) return RequestContinue; 1148 if (!topCallFrame) return RequestContinue;
1144 1149
1145 DCHECK(m_pausedContext.IsEmpty()); 1150 DCHECK(m_pausedContext.IsEmpty());
1146 JavaScriptCallFrames frames = m_debugger->currentCallFrames(); 1151 JavaScriptCallFrames frames = m_debugger->currentCallFrames();
1147 m_pausedCallFrames.swap(frames); 1152 m_pausedCallFrames.swap(frames);
1148 m_pausedContext.Reset(m_isolate, context); 1153 m_pausedContext.Reset(m_isolate, context);
1149 v8::HandleScope handles(m_isolate); 1154 v8::HandleScope handles(m_isolate);
1150 1155
1151 if (!exception.IsEmpty()) { 1156 if (!exception.IsEmpty()) {
1152 InjectedScript* injectedScript = nullptr; 1157 InjectedScript* injectedScript = nullptr;
1153 m_session->findInjectedScript(V8Debugger::contextId(context), 1158 m_session->findInjectedScript(InspectedContext::contextId(context),
1154 injectedScript); 1159 injectedScript);
1155 if (injectedScript) { 1160 if (injectedScript) {
1156 m_breakReason = 1161 m_breakReason =
1157 isPromiseRejection 1162 isPromiseRejection
1158 ? protocol::Debugger::Paused::ReasonEnum::PromiseRejection 1163 ? protocol::Debugger::Paused::ReasonEnum::PromiseRejection
1159 : protocol::Debugger::Paused::ReasonEnum::Exception; 1164 : protocol::Debugger::Paused::ReasonEnum::Exception;
1160 std::unique_ptr<protocol::Runtime::RemoteObject> obj; 1165 std::unique_ptr<protocol::Runtime::RemoteObject> obj;
1161 injectedScript->wrapObject(exception, kBacktraceObjectGroup, false, false, 1166 injectedScript->wrapObject(exception, kBacktraceObjectGroup, false, false,
1162 &obj); 1167 &obj);
1163 if (obj) { 1168 if (obj) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 1267
1263 void V8DebuggerAgentImpl::reset() { 1268 void V8DebuggerAgentImpl::reset() {
1264 if (!enabled()) return; 1269 if (!enabled()) return;
1265 m_scheduledDebuggerStep = NoStep; 1270 m_scheduledDebuggerStep = NoStep;
1266 m_scripts.clear(); 1271 m_scripts.clear();
1267 m_blackboxedPositions.clear(); 1272 m_blackboxedPositions.clear();
1268 m_breakpointIdToDebuggerBreakpointIds.clear(); 1273 m_breakpointIdToDebuggerBreakpointIds.clear();
1269 } 1274 }
1270 1275
1271 } // namespace v8_inspector 1276 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/v8-debugger.cc ('k') | src/inspector/v8-debugger-script.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698