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

Unified Diff: Source/core/inspector/ConsoleMessage.cpp

Issue 20191003: Route JS Error Info From Blink to Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@gclient
Patch Set: Adam's requests Created 7 years, 5 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: Source/core/inspector/ConsoleMessage.cpp
diff --git a/Source/core/inspector/ConsoleMessage.cpp b/Source/core/inspector/ConsoleMessage.cpp
index 7ce1741749c1c61035d32e1775ee3525a3a52e6b..3f39e70ea8559a32b245a09ff3089d91bbbb45c0 100644
--- a/Source/core/inspector/ConsoleMessage.cpp
+++ b/Source/core/inspector/ConsoleMessage.cpp
@@ -51,7 +51,6 @@ ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source,
, m_type(type)
, m_level(level)
, m_message(message)
- , m_url()
, m_line(0)
, m_column(0)
, m_repeatCount(1)
@@ -61,11 +60,12 @@ ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source,
autogenerateMetadata(canGenerateCallStack);
}
-ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& url, unsigned line, unsigned column, ScriptState* state, unsigned long requestIdentifier)
+ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& executionContextURL, const String& url, unsigned line, unsigned column, ScriptState* state, unsigned long requestIdentifier)
: m_source(source)
, m_type(type)
, m_level(level)
, m_message(message)
+ , m_executionContextURL(executionContextURL)
, m_url(url)
, m_line(line)
, m_column(column)
@@ -76,11 +76,12 @@ ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source,
autogenerateMetadata(canGenerateCallStack, state);
}
-ConsoleMessage::ConsoleMessage(bool, MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack, unsigned long requestIdentifier)
+ConsoleMessage::ConsoleMessage(bool, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& executionContextURL, PassRefPtr<ScriptCallStack> callStack, unsigned long requestIdentifier)
: m_source(source)
, m_type(type)
, m_level(level)
, m_message(message)
+ , m_executionContextURL(executionContextURL)
, m_arguments(0)
, m_line(0)
, m_column(0)
@@ -97,13 +98,13 @@ ConsoleMessage::ConsoleMessage(bool, MessageSource source, MessageType type, Mes
m_callStack = callStack;
}
-ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptArguments> arguments, ScriptState* state, unsigned long requestIdentifier)
+ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& executionContextURL, PassRefPtr<ScriptArguments> arguments, ScriptState* state, unsigned long requestIdentifier)
: m_source(source)
, m_type(type)
, m_level(level)
, m_message(message)
+ , m_executionContextURL(executionContextURL)
, m_arguments(arguments)
- , m_url()
, m_line(0)
, m_column(0)
, m_repeatCount(1)
@@ -122,10 +123,10 @@ void ConsoleMessage::autogenerateMetadata(bool canGenerateCallStack, ScriptState
if (m_type == EndGroupMessageType)
return;
- if (state)
+ if (canGenerateCallStack)
+ generateCallStack(ScriptCallStack::maxCallStackSizeToCapture);
+ else if (state)
m_callStack = createScriptCallStackForConsole(state);
- else if (canGenerateCallStack)
- m_callStack = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true);
else
return;
@@ -140,6 +141,11 @@ void ConsoleMessage::autogenerateMetadata(bool canGenerateCallStack, ScriptState
m_callStack.clear();
}
+void ConsoleMessage::generateCallStack(size_t maxSizeToCapture)
+{
+ m_callStack = createScriptCallStack(maxSizeToCapture, true);
+}
+
static TypeBuilder::Console::ConsoleMessage::Source::Enum messageSourceValue(MessageSource source)
{
switch (source) {
@@ -189,7 +195,7 @@ static TypeBuilder::Console::ConsoleMessage::Level::Enum messageLevelValue(Messa
return TypeBuilder::Console::ConsoleMessage::Level::Log;
}
-void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager, bool generatePreview)
+PassRefPtr<TypeBuilder::Console::ConsoleMessage> ConsoleMessage::generateJSONWithoutArguments() const
{
RefPtr<TypeBuilder::Console::ConsoleMessage> jsonObj = TypeBuilder::Console::ConsoleMessage::create()
.setSource(messageSourceValue(m_source))
@@ -201,9 +207,18 @@ void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, Injecte
jsonObj->setLine(static_cast<int>(m_line));
jsonObj->setColumn(static_cast<int>(m_column));
jsonObj->setUrl(m_url);
+ jsonObj->setExecutionContextURL(m_executionContextURL);
jsonObj->setRepeatCount(static_cast<int>(m_repeatCount));
if (m_source == NetworkMessageSource && !m_requestId.isEmpty())
jsonObj->setNetworkRequestId(m_requestId);
+ if (m_callStack)
+ jsonObj->setStackTrace(m_callStack->buildInspectorArray());
+ return jsonObj;
+}
+
+void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager, bool generatePreview)
+{
+ RefPtr<TypeBuilder::Console::ConsoleMessage> jsonObj = generateJSONWithoutArguments();
if (m_arguments && m_arguments->argumentCount()) {
InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_arguments->globalState());
if (!injectedScript.hasNoValue()) {
@@ -230,8 +245,6 @@ void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, Injecte
jsonObj->setParameters(jsonArgs);
}
}
- if (m_callStack)
- jsonObj->setStackTrace(m_callStack->buildInspectorArray());
frontend->messageAdded(jsonObj);
}
@@ -275,6 +288,11 @@ bool ConsoleMessage::isEqual(ConsoleMessage* msg) const
&& msg->m_requestId == m_requestId;
}
+bool ConsoleMessage::hasGeneratedCallStack() const
+{
+ return m_callStack;
+}
+
void ConsoleMessage::windowCleared(DOMWindow* window)
{
if (!m_arguments)

Powered by Google App Engine
This is Rietveld 408576698