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

Unified Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.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/V8DebuggerImpl.cpp
diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp
index 27396fc72dce1c85dde16cfdafd4226bebdd7ded..52838bdc4bfec935d67e015b57d7607e331a8869 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp
@@ -173,7 +173,7 @@ V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(v8::Local<v8::Cont
return findEnabledDebuggerAgent(getGroupId(context));
}
-void V8DebuggerImpl::getCompiledScripts(int contextGroupId, protocol::Vector<V8DebuggerParsedScript>& result)
+void V8DebuggerImpl::getCompiledScripts(int contextGroupId, std::vector<std::unique_ptr<V8DebuggerScript>>& result)
{
v8::HandleScope scope(m_isolate);
v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks);
@@ -186,9 +186,9 @@ void V8DebuggerImpl::getCompiledScripts(int contextGroupId, protocol::Vector<V8D
return;
DCHECK(value->IsArray());
v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value);
- result.resize(scriptsArray->Length());
+ result.reserve(scriptsArray->Length());
for (unsigned i = 0; i < scriptsArray->Length(); ++i)
- result[i] = createParsedScript(v8::Local<v8::Object>::Cast(scriptsArray->Get(v8::Integer::New(m_isolate, i))), true);
+ result.push_back(createScript(v8::Local<v8::Object>::Cast(scriptsArray->Get(v8::Integer::New(m_isolate, i)))));
}
String16 V8DebuggerImpl::setBreakpoint(const String16& sourceID, const ScriptBreakpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool interstatementLocation)
@@ -356,7 +356,7 @@ void V8DebuggerImpl::clearStepping()
callDebuggerMethod("clearStepping", 0, argv);
}
-bool V8DebuggerImpl::setScriptSource(const String16& sourceID, const String16& newContent, bool preview, ErrorString* error, Maybe<protocol::Debugger::SetScriptSourceError>* errorData, JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged)
+bool V8DebuggerImpl::setScriptSource(const String16& sourceID, v8::Local<v8::String> newSource, bool preview, ErrorString* error, Maybe<protocol::Debugger::SetScriptSourceError>* errorData, JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged)
{
class EnableLiveEditScope {
public:
@@ -381,7 +381,7 @@ bool V8DebuggerImpl::setScriptSource(const String16& sourceID, const String16& n
if (!isPaused())
contextScope = wrapUnique(new v8::Context::Scope(debuggerContext()));
- v8::Local<v8::Value> argv[] = { toV8String(m_isolate, sourceID), toV8String(m_isolate, newContent), v8Boolean(preview, m_isolate) };
+ v8::Local<v8::Value> argv[] = { toV8String(m_isolate, sourceID), newSource, v8Boolean(preview, m_isolate) };
v8::Local<v8::Value> v8result;
{
@@ -559,7 +559,7 @@ void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDeta
v8::Local<v8::Value> value = callDebuggerMethod("getAfterCompileScript", 1, argv).ToLocalChecked();
DCHECK(value->IsObject());
v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
- agent->didParseSource(createParsedScript(object, event == v8::AfterCompile));
+ agent->didParseSource(createScript(object), event == v8::AfterCompile);
} else if (event == v8::Exception) {
v8::Local<v8::Object> eventData = eventDetails.GetEventData();
v8::Local<v8::Value> exception = callInternalGetterFunction(eventData, "exception");
@@ -602,27 +602,30 @@ V8StackTraceImpl* V8DebuggerImpl::currentAsyncCallChain()
return m_currentStacks.last();
}
-V8DebuggerParsedScript V8DebuggerImpl::createParsedScript(v8::Local<v8::Object> object, bool success)
+std::unique_ptr<V8DebuggerScript> V8DebuggerImpl::createScript(v8::Local<v8::Object> object)
{
v8::Local<v8::Value> id = object->Get(v8InternalizedString("id"));
DCHECK(!id.IsEmpty() && id->IsInt32());
- V8DebuggerParsedScript parsedScript;
- parsedScript.scriptId = String16::number(id->Int32Value());
- parsedScript.script.setURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("name"))))
- .setSourceURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("sourceURL"))))
- .setSourceMappingURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("sourceMappingURL"))))
- .setSource(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("source"))))
- .setStartLine(object->Get(v8InternalizedString("startLine"))->ToInteger(m_isolate)->Value())
- .setStartColumn(object->Get(v8InternalizedString("startColumn"))->ToInteger(m_isolate)->Value())
- .setEndLine(object->Get(v8InternalizedString("endLine"))->ToInteger(m_isolate)->Value())
- .setEndColumn(object->Get(v8InternalizedString("endColumn"))->ToInteger(m_isolate)->Value())
- .setIsContentScript(object->Get(v8InternalizedString("isContentScript"))->ToBoolean(m_isolate)->Value())
- .setIsInternalScript(object->Get(v8InternalizedString("isInternalScript"))->ToBoolean(m_isolate)->Value())
- .setExecutionContextId(object->Get(v8InternalizedString("executionContextId"))->ToInteger(m_isolate)->Value())
- .setIsLiveEdit(inLiveEditScope);
- parsedScript.success = success;
- return parsedScript;
+ std::unique_ptr<V8DebuggerScript> script(new V8DebuggerScript());
+ script->setScriptId(String16::number(id->Int32Value()))
+ ->setURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("name"))))
+ ->setSourceURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("sourceURL"))))
+ ->setSourceMappingURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("sourceMappingURL"))))
+ ->setStartLine(object->Get(v8InternalizedString("startLine"))->ToInteger(m_isolate)->Value())
+ ->setStartColumn(object->Get(v8InternalizedString("startColumn"))->ToInteger(m_isolate)->Value())
+ ->setEndLine(object->Get(v8InternalizedString("endLine"))->ToInteger(m_isolate)->Value())
+ ->setEndColumn(object->Get(v8InternalizedString("endColumn"))->ToInteger(m_isolate)->Value())
+ ->setIsContentScript(object->Get(v8InternalizedString("isContentScript"))->ToBoolean(m_isolate)->Value())
+ ->setIsInternalScript(object->Get(v8InternalizedString("isInternalScript"))->ToBoolean(m_isolate)->Value())
+ ->setExecutionContextId(object->Get(v8InternalizedString("executionContextId"))->ToInteger(m_isolate)->Value())
+ ->setIsLiveEdit(inLiveEditScope);
+
+ v8::Local<v8::Value> sourceValue = object->Get(v8InternalizedString("source"));
+ if (!sourceValue.IsEmpty() && sourceValue->IsString())
+ script->setSource(m_isolate, sourceValue.As<v8::String>());
+
+ return script;
}
void V8DebuggerImpl::compileDebuggerScript()

Powered by Google App Engine
This is Rietveld 408576698