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

Unified Diff: Source/core/dom/ExecutionContext.cpp

Issue 376213002: DevTools: Make FrameConsole methods accept ConsoleMessage objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@scriptFailedToParse
Patch Set: Created 6 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/dom/ExecutionContext.cpp
diff --git a/Source/core/dom/ExecutionContext.cpp b/Source/core/dom/ExecutionContext.cpp
index a542cf32d8c6797830cb5cd772ccbaed403d2d8d..4ae5af8171509c36b2268350366b41cd41626052 100644
--- a/Source/core/dom/ExecutionContext.cpp
+++ b/Source/core/dom/ExecutionContext.cpp
@@ -34,6 +34,7 @@
#include "core/events/ErrorEvent.h"
#include "core/events/EventTarget.h"
#include "core/html/PublicURLManager.h"
+#include "core/inspector/ConsoleMessage.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/inspector/ScriptCallStack.h"
#include "core/workers/WorkerGlobalScope.h"
@@ -45,23 +46,15 @@ namespace WebCore {
class ExecutionContext::PendingException : public NoBaseWillBeGarbageCollectedFinalized<ExecutionContext::PendingException> {
WTF_MAKE_NONCOPYABLE(PendingException);
public:
- PendingException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, PassRefPtrWillBeRawPtr<ScriptCallStack> callStack)
- : m_errorMessage(errorMessage)
- , m_lineNumber(lineNumber)
- , m_columnNumber(columnNumber)
- , m_sourceURL(sourceURL)
- , m_callStack(callStack)
+ PendingException(PassRefPtrWillBeRawPtr<ConsoleMessage> consoleError)
+ : m_consoleError(consoleError)
{
}
void trace(Visitor* visitor)
{
- visitor->trace(m_callStack);
+ visitor->trace(m_consoleError);
}
- String m_errorMessage;
- int m_lineNumber;
- int m_columnNumber;
- String m_sourceURL;
- RefPtrWillBeMember<ScriptCallStack> m_callStack;
+ RefPtrWillBeMember<ConsoleMessage> m_consoleError;
};
ExecutionContext::ExecutionContext()
@@ -133,19 +126,25 @@ bool ExecutionContext::shouldSanitizeScriptError(const String& sourceURL, Access
return !(securityOrigin()->canRequest(completeURL(sourceURL)) || corsStatus == SharableCrossOrigin);
}
-void ExecutionContext::reportException(PassRefPtrWillBeRawPtr<ErrorEvent> event, PassRefPtrWillBeRawPtr<ScriptCallStack> callStack, AccessControlStatus corsStatus)
+void ExecutionContext::reportException(PassRefPtrWillBeRawPtr<ErrorEvent> event, PassRefPtrWillBeRawPtr<ConsoleMessage> consoleError)
{
RefPtrWillBeRawPtr<ErrorEvent> errorEvent = event;
+ RefPtrWillBeRawPtr<ConsoleMessage> errorDetails = consoleError;
+
if (m_inDispatchErrorEvent) {
if (!m_pendingExceptions)
m_pendingExceptions = adoptPtrWillBeNoop(new WillBeHeapVector<OwnPtrWillBeMember<PendingException> >());
- m_pendingExceptions->append(adoptPtrWillBeNoop(new PendingException(errorEvent->messageForConsole(), errorEvent->lineno(), errorEvent->colno(), errorEvent->filename(), callStack)));
+ m_pendingExceptions->append(adoptPtrWillBeNoop(new PendingException(errorDetails.release())));
return;
}
+ AccessControlStatus corsStatus = errorDetails->corsStatus();
// First report the original exception and only then all the nested ones.
- if (!dispatchErrorEvent(errorEvent, corsStatus) && m_client)
- m_client->logExceptionToConsole(errorEvent->messageForConsole(), errorEvent->filename(), errorEvent->lineno(), errorEvent->colno(), callStack);
+ if (!dispatchErrorEvent(errorEvent, corsStatus) && m_client /* redundancy check */) {
+ errorDetails->setMessage(errorEvent->messageForConsole());
+ errorDetails->setURL(errorEvent->filename());
+ m_client->logExceptionToConsole(errorDetails.release());
+ }
if (!m_pendingExceptions)
return;
@@ -153,7 +152,7 @@ void ExecutionContext::reportException(PassRefPtrWillBeRawPtr<ErrorEvent> event,
for (size_t i = 0; i < m_pendingExceptions->size(); i++) {
PendingException* e = m_pendingExceptions->at(i).get();
if (m_client)
- m_client->logExceptionToConsole(e->m_errorMessage, e->m_sourceURL, e->m_lineNumber, e->m_columnNumber, e->m_callStack);
+ m_client->logExceptionToConsole(e->m_consoleError);
}
m_pendingExceptions.clear();
}
@@ -162,14 +161,14 @@ void ExecutionContext::addConsoleMessage(MessageSource source, MessageLevel leve
{
if (!m_client)
return;
- m_client->addMessage(source, level, message, sourceURL, lineNumber, 0);
+ m_client->addMessage(ConsoleMessage::create(source, level, message, sourceURL, lineNumber, 0, nullptr, nullptr, 0, NotSharableCrossOrigin));
}
void ExecutionContext::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, ScriptState* scriptState)
{
if (!m_client)
return;
- m_client->addMessage(source, level, message, String(), 0, scriptState);
+ m_client->addMessage(ConsoleMessage::create(source, level, message, String(), 0, 0, nullptr, scriptState, 0, NotSharableCrossOrigin));
}
bool ExecutionContext::dispatchErrorEvent(PassRefPtrWillBeRawPtr<ErrorEvent> event, AccessControlStatus corsStatus)

Powered by Google App Engine
This is Rietveld 408576698