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

Side by Side Diff: Source/core/frame/FrameConsole.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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 13 matching lines...) Expand all
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "core/frame/FrameConsole.h" 30 #include "core/frame/FrameConsole.h"
31 31
32 #include "core/frame/FrameHost.h" 32 #include "core/frame/FrameHost.h"
33 #include "core/inspector/ConsoleAPITypes.h" 33 #include "core/inspector/ConsoleAPITypes.h"
34 #include "core/inspector/ConsoleMessage.h"
34 #include "core/inspector/InspectorConsoleInstrumentation.h" 35 #include "core/inspector/InspectorConsoleInstrumentation.h"
35 #include "core/page/Chrome.h" 36 #include "core/page/Chrome.h"
36 #include "core/page/ChromeClient.h" 37 #include "core/page/ChromeClient.h"
37 #include "core/page/Page.h" 38 #include "core/page/Page.h"
38 #include "wtf/text/StringBuilder.h" 39 #include "wtf/text/StringBuilder.h"
39 40
40 namespace WebCore { 41 namespace WebCore {
41 42
42 namespace { 43 namespace {
43 44
44 int muteCount = 0; 45 int muteCount = 0;
45 46
46 } 47 }
47 48
48 FrameConsole::FrameConsole(LocalFrame& frame) 49 FrameConsole::FrameConsole(LocalFrame& frame)
49 : m_frame(frame) 50 : m_frame(frame)
50 { 51 {
51 } 52 }
52 53
53 void FrameConsole::addMessage(MessageSource source, MessageLevel level, const St ring& message) 54 void FrameConsole::addMessage(PassRefPtr<ConsoleMessage> prpConsoleMessage)
54 {
55 addMessage(source, level, message, String(), 0, 0, nullptr, 0, 0);
56 }
57
58 void FrameConsole::addMessage(MessageSource source, MessageLevel level, const St ring& message, PassRefPtrWillBeRawPtr<ScriptCallStack> callStack)
59 {
60 addMessage(source, level, message, String(), 0, 0, callStack, 0);
61 }
62
63 void FrameConsole::addMessage(MessageSource source, MessageLevel level, const St ring& message, const String& url, unsigned lineNumber, unsigned columnNumber, Pa ssRefPtrWillBeRawPtr<ScriptCallStack> callStack, ScriptState* scriptState, unsig ned long requestIdentifier)
64 { 55 {
65 if (muteCount) 56 if (muteCount)
66 return; 57 return;
67 58
68 // FIXME: This should not need to reach for the main-frame. 59 // FIXME: This should not need to reach for the main-frame.
69 // Inspector code should just take the current frame and know how to walk it self. 60 // Inspector code should just take the current frame and know how to walk it self.
70 ExecutionContext* context = m_frame.document(); 61 ExecutionContext* context = m_frame.document();
71 if (!context) 62 if (!context)
72 return; 63 return;
73 64
65 RefPtr<ConsoleMessage> consoleMessage = prpConsoleMessage;
66
74 String messageURL; 67 String messageURL;
75 if (callStack) { 68 if (consoleMessage->callStack())
76 messageURL = callStack->at(0).sourceURL(); 69 messageURL = consoleMessage->callStack()->at(0).sourceURL();
77 InspectorInstrumentation::addMessageToConsole(context, source, LogMessag eType, level, message, callStack, requestIdentifier); 70 else
78 } else { 71 messageURL = consoleMessage->url();
79 messageURL = url;
80 InspectorInstrumentation::addMessageToConsole(context, source, LogMessag eType, level, message, url, lineNumber, columnNumber, scriptState, requestIdenti fier);
81 }
82 72
83 if (source == CSSMessageSource) 73 InspectorInstrumentation::addMessageToConsole(context, consoleMessage);
74
75 if (consoleMessage->source() == CSSMessageSource)
84 return; 76 return;
85 77
86 String stackTrace; 78 String stackTrace;
87 if (callStack && m_frame.chromeClient().shouldReportDetailedMessageForSource (messageURL)) 79 if (consoleMessage->callStack() && m_frame.chromeClient().shouldReportDetail edMessageForSource(messageURL))
88 stackTrace = FrameConsole::formatStackTraceString(message, callStack); 80 stackTrace = FrameConsole::formatStackTraceString(consoleMessage->messag e(), consoleMessage->callStack());
89 81
90 m_frame.chromeClient().addMessageToConsole(&m_frame, source, level, message, lineNumber, messageURL, stackTrace); 82 m_frame.chromeClient().addMessageToConsole(&m_frame, consoleMessage->source( ), consoleMessage->level(), consoleMessage->message(), consoleMessage->lineNumbe r(), messageURL, stackTrace);
91 } 83 }
92 84
93 String FrameConsole::formatStackTraceString(const String& originalMessage, PassR efPtrWillBeRawPtr<ScriptCallStack> callStack) 85 String FrameConsole::formatStackTraceString(const String& originalMessage, PassR efPtrWillBeRawPtr<ScriptCallStack> callStack)
94 { 86 {
95 StringBuilder stackTrace; 87 StringBuilder stackTrace;
96 for (size_t i = 0; i < callStack->size(); ++i) { 88 for (size_t i = 0; i < callStack->size(); ++i) {
97 const ScriptCallFrame& frame = callStack->at(i); 89 const ScriptCallFrame& frame = callStack->at(i);
98 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)")); 90 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)"));
99 stackTrace.append(" ("); 91 stackTrace.append(" (");
100 stackTrace.append(frame.sourceURL()); 92 stackTrace.append(frame.sourceURL());
(...skipping 12 matching lines...) Expand all
113 muteCount++; 105 muteCount++;
114 } 106 }
115 107
116 void FrameConsole::unmute() 108 void FrameConsole::unmute()
117 { 109 {
118 ASSERT(muteCount > 0); 110 ASSERT(muteCount > 0);
119 muteCount--; 111 muteCount--;
120 } 112 }
121 113
122 } // namespace WebCore 114 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698