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

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

Issue 2104063002: [DevTools] Store script source in v8::Global. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 33eebe954b4fc31847e8ec4bcc40f6779c107371..4b2af59a8cafd01f360ae4d9686b9bd7e1eeb1dc 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp
@@ -190,10 +190,10 @@ void V8DebuggerAgentImpl::enable()
m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true);
debugger().debuggerAgentEnabled();
- protocol::Vector<V8DebuggerParsedScript> compiledScripts;
+ std::vector<std::unique_ptr<V8DebuggerScript>> compiledScripts;
debugger().getCompiledScripts(m_session->contextGroupId(), compiledScripts);
for (size_t i = 0; i < compiledScripts.size(); i++)
- didParseSource(compiledScripts[i]);
+ didParseSource(std::move(compiledScripts[i]), true);
// FIXME(WK44513): breakpoints activated flag should be synchronized between all front-ends
debugger().setBreakpointsActivated(true);
@@ -575,9 +575,10 @@ void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String16& sc
const Maybe<bool>& optionalIsRegex,
std::unique_ptr<Array<protocol::Debugger::SearchMatch>>* results)
{
+ v8::HandleScope handles(m_isolate);
ScriptsMap::iterator it = m_scripts.find(scriptId);
if (it != m_scripts.end())
- *results = V8ContentSearchUtil::searchInTextByLines(m_session, it->second->source(), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fromMaybe(false));
+ *results = V8ContentSearchUtil::searchInTextByLines(m_session, toProtocolString(it->second->source(m_isolate)), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fromMaybe(false));
else
*error = String16("No script for id: " + scriptId);
}
@@ -593,19 +594,21 @@ void V8DebuggerAgentImpl::setScriptSource(ErrorString* errorString,
{
if (!checkEnabled(errorString))
return;
- if (!debugger().setScriptSource(scriptId, newContent, preview.fromMaybe(false), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged))
+
+ v8::HandleScope handles(m_isolate);
+ v8::Local<v8::String> newSource = toV8String(m_isolate, newContent);
+ if (!debugger().setScriptSource(scriptId, newSource, preview.fromMaybe(false), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged))
return;
+ ScriptsMap::iterator it = m_scripts.find(scriptId);
+ if (it != m_scripts.end())
+ it->second->setSource(m_isolate, newSource);
+
std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString);
if (!callFrames)
return;
*newCallFrames = std::move(callFrames);
*asyncStackTrace = currentAsyncStackTrace();
-
- ScriptsMap::iterator it = m_scripts.find(scriptId);
- if (it == m_scripts.end())
- return;
- it->second->setSource(newContent);
}
void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString,
@@ -646,7 +649,8 @@ void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc
*error = "No script for id: " + scriptId;
return;
}
- *scriptSource = it->second->source();
+ v8::HandleScope handles(m_isolate);
+ *scriptSource = toProtocolString(it->second->source(m_isolate));
}
void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const String16& functionId, std::unique_ptr<FunctionDetails>* details)
@@ -1133,31 +1137,32 @@ std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace()
return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) : nullptr;
}
-void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScript)
+void V8DebuggerAgentImpl::didParseSource(std::unique_ptr<V8DebuggerScript> script, bool success)
{
- V8DebuggerScript script = parsedScript.script;
-
+ v8::HandleScope handles(m_isolate);
+ String16 scriptSource = toProtocolString(script->source(m_isolate));
bool isDeprecatedSourceURL = false;
- if (!parsedScript.success)
- script.setSourceURL(V8ContentSearchUtil::findSourceURL(script.source(), false, &isDeprecatedSourceURL));
- else if (script.hasSourceURL())
- V8ContentSearchUtil::findSourceURL(script.source(), false, &isDeprecatedSourceURL);
+ if (!success)
+ script->setSourceURL(V8ContentSearchUtil::findSourceURL(scriptSource, false, &isDeprecatedSourceURL));
+ else if (script->hasSourceURL())
+ V8ContentSearchUtil::findSourceURL(scriptSource, false, &isDeprecatedSourceURL);
bool isDeprecatedSourceMappingURL = false;
- if (!parsedScript.success)
- script.setSourceMappingURL(V8ContentSearchUtil::findSourceMapURL(script.source(), false, &isDeprecatedSourceMappingURL));
- else if (!script.sourceMappingURL().isEmpty())
- V8ContentSearchUtil::findSourceMapURL(script.source(), false, &isDeprecatedSourceMappingURL);
-
- script.setHash(calculateHash(script.source()));
-
- int executionContextId = script.executionContextId();
- bool isContentScript = script.isContentScript();
- bool isInternalScript = script.isInternalScript();
- bool isLiveEdit = script.isLiveEdit();
- bool hasSourceURL = script.hasSourceURL();
- String16 scriptURL = script.sourceURL();
- String16 sourceMapURL = script.sourceMappingURL();
+ if (!success)
+ script->setSourceMappingURL(V8ContentSearchUtil::findSourceMapURL(scriptSource, false, &isDeprecatedSourceMappingURL));
+ else if (!script->sourceMappingURL().isEmpty())
+ V8ContentSearchUtil::findSourceMapURL(scriptSource, false, &isDeprecatedSourceMappingURL);
+
+ script->setHash(calculateHash(scriptSource));
+
+ int executionContextId = script->executionContextId();
+ bool isContentScript = script->isContentScript();
+ bool isInternalScript = script->isInternalScript();
+ bool isLiveEdit = script->isLiveEdit();
+ bool hasSourceURL = script->hasSourceURL();
+ String16 scriptId = script->scriptId();
+ String16 scriptURL = script->sourceURL();
+ String16 sourceMapURL = script->sourceMappingURL();
bool deprecatedCommentWasUsed = isDeprecatedSourceURL || isDeprecatedSourceMappingURL;
const Maybe<String16>& sourceMapURLParam = sourceMapURL;
@@ -1166,14 +1171,14 @@ void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr
const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr;
const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr;
const bool* deprecatedCommentWasUsedParam = deprecatedCommentWasUsed ? &deprecatedCommentWasUsed : nullptr;
- if (parsedScript.success)
- m_frontend.scriptParsed(parsedScript.scriptId, scriptURL, script.startLine(), script.startColumn(), script.endLine(), script.endColumn(), executionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, isLiveEditParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam);
+ if (success)
+ m_frontend.scriptParsed(scriptId, scriptURL, script->startLine(), script->startColumn(), script->endLine(), script->endColumn(), executionContextId, script->hash(), isContentScriptParam, isInternalScriptParam, isLiveEditParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam);
else
- m_frontend.scriptFailedToParse(parsedScript.scriptId, scriptURL, script.startLine(), script.startColumn(), script.endLine(), script.endColumn(), executionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam);
+ m_frontend.scriptFailedToParse(scriptId, scriptURL, script->startLine(), script->startColumn(), script->endLine(), script->endColumn(), executionContextId, script->hash(), isContentScriptParam, isInternalScriptParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam);
- m_scripts.set(parsedScript.scriptId, script);
+ m_scripts.set(scriptId, std::move(script));
- if (scriptURL.isEmpty() || !parsedScript.success)
+ if (scriptURL.isEmpty() || !success)
return;
protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints);
@@ -1193,7 +1198,7 @@ void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr
breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint.lineNumber);
breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoint.columnNumber);
breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.condition);
- std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoint(cookie.first, parsedScript.scriptId, breakpoint, UserBreakpointSource);
+ std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoint(cookie.first, scriptId, breakpoint, UserBreakpointSource);
if (location)
m_frontend.breakpointResolved(cookie.first, std::move(location));
}

Powered by Google App Engine
This is Rietveld 408576698