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

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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 int muteCount = 0; 44 int muteCount = 0;
45 45
46 } 46 }
47 47
48 FrameConsole::FrameConsole(LocalFrame& frame) 48 FrameConsole::FrameConsole(LocalFrame& frame)
49 : m_frame(frame) 49 : m_frame(frame)
50 { 50 {
51 } 51 }
52 52
53 void FrameConsole::addMessage(MessageSource source, MessageLevel level, const St ring& message) 53 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 { 54 {
65 if (muteCount) 55 if (muteCount)
66 return; 56 return;
67 57
68 // FIXME: This should not need to reach for the main-frame. 58 // 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. 59 // Inspector code should just take the current frame and know how to walk it self.
70 ExecutionContext* context = m_frame.document(); 60 ExecutionContext* context = m_frame.document();
71 if (!context) 61 if (!context)
72 return; 62 return;
73 63
74 String messageURL; 64 RefPtr<ConsoleMessage> consoleMessage = prpConsoleMessage;
75 if (callStack) { 65 InspectorInstrumentation::addMessageToConsole(context, consoleMessage.get()) ;
76 messageURL = callStack->at(0).sourceURL(); 66 if (consoleMessage->callStack())
77 InspectorInstrumentation::addMessageToConsole(context, source, LogMessag eType, level, message, callStack, requestIdentifier); 67 consoleMessage->setURL(consoleMessage->callStack()->at(0).sourceURL());
vsevik 2014/08/08 13:21:01 Please do not update console message object once i
kozyatinskiy1 2014/08/08 14:02:12 Done.
78 } else {
79 messageURL = url;
80 InspectorInstrumentation::addMessageToConsole(context, source, LogMessag eType, level, message, url, lineNumber, columnNumber, scriptState, requestIdenti fier);
81 }
82 68
83 if (source == CSSMessageSource) 69 if (consoleMessage->source() == CSSMessageSource)
84 return; 70 return;
85 71
86 String stackTrace; 72 String stackTrace;
87 if (callStack && m_frame.chromeClient().shouldReportDetailedMessageForSource (messageURL)) 73 if (consoleMessage->callStack() && m_frame.chromeClient().shouldReportDetail edMessageForSource(consoleMessage->url()))
88 stackTrace = FrameConsole::formatStackTraceString(message, callStack); 74 stackTrace = FrameConsole::formatStackTraceString(consoleMessage->messag e(), consoleMessage->callStack());
89 75
90 m_frame.chromeClient().addMessageToConsole(&m_frame, source, level, message, lineNumber, messageURL, stackTrace); 76 m_frame.chromeClient().addMessageToConsole(&m_frame, consoleMessage->source( ), consoleMessage->level(), consoleMessage->message(), consoleMessage->lineNumbe r(), consoleMessage->url(), stackTrace);
91 } 77 }
92 78
93 String FrameConsole::formatStackTraceString(const String& originalMessage, PassR efPtrWillBeRawPtr<ScriptCallStack> callStack) 79 String FrameConsole::formatStackTraceString(const String& originalMessage, PassR efPtrWillBeRawPtr<ScriptCallStack> callStack)
94 { 80 {
95 StringBuilder stackTrace; 81 StringBuilder stackTrace;
96 for (size_t i = 0; i < callStack->size(); ++i) { 82 for (size_t i = 0; i < callStack->size(); ++i) {
97 const ScriptCallFrame& frame = callStack->at(i); 83 const ScriptCallFrame& frame = callStack->at(i);
98 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)")); 84 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)"));
99 stackTrace.append(" ("); 85 stackTrace.append(" (");
100 stackTrace.append(frame.sourceURL()); 86 stackTrace.append(frame.sourceURL());
(...skipping 12 matching lines...) Expand all
113 muteCount++; 99 muteCount++;
114 } 100 }
115 101
116 void FrameConsole::unmute() 102 void FrameConsole::unmute()
117 { 103 {
118 ASSERT(muteCount > 0); 104 ASSERT(muteCount > 0);
119 muteCount--; 105 muteCount--;
120 } 106 }
121 107
122 } // namespace blink 108 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698