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

Unified Diff: Source/core/page/FormatConsoleMessage.cpp

Issue 18822004: Extension Error Piping - Blink: WebKit Side (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Extracted Formatting Created 7 years, 4 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/page/FormatConsoleMessage.cpp
diff --git a/Source/modules/crypto/Algorithm.cpp b/Source/core/page/FormatConsoleMessage.cpp
similarity index 52%
copy from Source/modules/crypto/Algorithm.cpp
copy to Source/core/page/FormatConsoleMessage.cpp
index a6b3637691cf0e3085570899520038e788ce7d73..33ca1594555fd52ecdb291dbf77bcbec057f591e 100644
--- a/Source/modules/crypto/Algorithm.cpp
+++ b/Source/core/page/FormatConsoleMessage.cpp
@@ -29,46 +29,44 @@
*/
#include "config.h"
-#include "modules/crypto/Algorithm.h"
+#include "core/page/FormatConsoleMessage.h"
-#include "modules/crypto/AesCbcParams.h"
-#include "modules/crypto/AesKeyGenParams.h"
-#include "modules/crypto/HmacParams.h"
-#include "modules/crypto/RsaKeyGenParams.h"
-#include "modules/crypto/RsaSsaParams.h"
+#include "core/inspector/ScriptCallFrame.h"
+#include "core/inspector/ScriptCallStack.h"
+#include "wtf/NotFound.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
-PassRefPtr<Algorithm> Algorithm::create(const WebKit::WebCryptoAlgorithm& algorithm)
+// If there is already a callstack in the message (which can happen when we execute internal code with try-catch and error reporting), we don't want to include another.
+static bool containsStackTrace(const String& message)
{
- switch (algorithm.paramsType()) {
- case WebKit::WebCryptoAlgorithmParamsTypeNone:
- return adoptRef(new Algorithm(algorithm));
- case WebKit::WebCryptoAlgorithmParamsTypeAesCbcParams:
- return AesCbcParams::create(algorithm);
- case WebKit::WebCryptoAlgorithmParamsTypeAesKeyGenParams:
- return AesKeyGenParams::create(algorithm);
- case WebKit::WebCryptoAlgorithmParamsTypeHmacParams:
- return HmacParams::create(algorithm);
- case WebKit::WebCryptoAlgorithmParamsTypeRsaSsaParams:
- return RsaSsaParams::create(algorithm);
- case WebKit::WebCryptoAlgorithmParamsTypeRsaKeyGenParams:
- return RsaKeyGenParams::create(algorithm);
- }
- ASSERT_NOT_REACHED();
- return 0;
+ return message.find("\n at ") != WTF::notFound;
pfeldman 2013/08/14 09:53:00 This looks like a very fragile heuristic.
Devlin 2013/08/14 17:00:40 It is fragile, but there's not really a solution (
}
-Algorithm::Algorithm(const WebKit::WebCryptoAlgorithm& algorithm)
- : m_algorithm(algorithm)
+String formatConsoleMessage(const String& originalMessage, PassRefPtr<ScriptCallStack> callStack)
{
- ScriptWrappable::init(this);
+ String formattedMessage = originalMessage;
+ if (containsStackTrace(formattedMessage))
+ return formattedMessage;
+
+ for (size_t i = 0; i < callStack->size(); ++i) {
+ const ScriptCallFrame& frame = callStack->at(i);
+ formattedMessage.append("\n at " + (frame.functionName().length() ? frame.functionName() : String("(anonymous function)")) + " (" + frame.sourceURL() + ":" + String::number(frame.lineNumber()) + ":" + String::number(frame.columnNumber()) + ")");
+ }
+
+ return formattedMessage;
}
-String Algorithm::name()
+String formatConsoleMessage(const WTF::String& originalMessage, const WTF::String& url, unsigned lineNumber, unsigned columnNumber)
pfeldman 2013/08/14 09:53:00 Console message already has url, line number and c
Devlin 2013/08/14 17:00:40 Mostly it was for completeness purposes - this way
{
- return m_algorithm.name();
+ String formattedMessage = originalMessage;
+ if (containsStackTrace(formattedMessage))
+ return formattedMessage;
+
+ formattedMessage.append("\n at (anonymous function) (" + url + ":" + String::number(lineNumber) + ":" + String::number(columnNumber) + ")");
+
+ return formattedMessage;
}
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698