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

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, 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 unified diff | Download patch
« no previous file with comments | « Source/core/frame/FrameConsole.h ('k') | Source/core/frame/LocalDOMWindow.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
36 #include "core/inspector/ScriptCallStack.h"
35 #include "core/page/Chrome.h" 37 #include "core/page/Chrome.h"
36 #include "core/page/ChromeClient.h" 38 #include "core/page/ChromeClient.h"
37 #include "core/page/Page.h" 39 #include "core/page/Page.h"
38 #include "wtf/text/StringBuilder.h" 40 #include "wtf/text/StringBuilder.h"
39 41
40 namespace blink { 42 namespace blink {
41 43
42 namespace { 44 namespace {
43 45
44 int muteCount = 0; 46 int muteCount = 0;
45 47
46 } 48 }
47 49
48 FrameConsole::FrameConsole(LocalFrame& frame) 50 FrameConsole::FrameConsole(LocalFrame& frame)
49 : m_frame(frame) 51 : m_frame(frame)
50 { 52 {
51 } 53 }
52 54
53 void FrameConsole::addMessage(MessageSource source, MessageLevel level, const St ring& message) 55 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 { 56 {
65 if (muteCount) 57 if (muteCount)
66 return; 58 return;
67 59
68 // FIXME: This should not need to reach for the main-frame. 60 // 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. 61 // Inspector code should just take the current frame and know how to walk it self.
70 ExecutionContext* context = m_frame.document(); 62 ExecutionContext* context = m_frame.document();
71 if (!context) 63 if (!context)
72 return; 64 return;
73 65
66 RefPtr<ConsoleMessage> consoleMessage = prpConsoleMessage;
67 InspectorInstrumentation::addMessageToConsole(context, consoleMessage.get()) ;
68
74 String messageURL; 69 String messageURL;
75 if (callStack) { 70 if (consoleMessage->callStack())
76 messageURL = callStack->at(0).sourceURL(); 71 messageURL = consoleMessage->callStack()->at(0).sourceURL();
77 InspectorInstrumentation::addMessageToConsole(context, source, LogMessag eType, level, message, callStack, requestIdentifier); 72 else
78 } else { 73 messageURL = consoleMessage->url();
79 messageURL = url;
80 InspectorInstrumentation::addMessageToConsole(context, source, LogMessag eType, level, message, url, lineNumber, columnNumber, scriptState, requestIdenti fier);
81 }
82 74
83 if (source == CSSMessageSource) 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(consoleMessage->url()))
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 blink 114 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/FrameConsole.h ('k') | Source/core/frame/LocalDOMWindow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698