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

Side by Side Diff: Source/core/page/Console.cpp

Issue 20191003: Route JS Error Info From Blink to Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@gclient
Patch Set: Adam's requests Created 7 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) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 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 14 matching lines...) Expand all
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/page/Console.h" 30 #include "core/page/Console.h"
31 31
32 #include "bindings/v8/ScriptCallStackFactory.h" 32 #include "bindings/v8/ScriptCallStackFactory.h"
33 #include "bindings/v8/ScriptProfiler.h" 33 #include "bindings/v8/ScriptProfiler.h"
34 #include "core/inspector/ConsoleAPITypes.h" 34 #include "core/inspector/ConsoleAPITypes.h"
35 #include "core/inspector/InspectorAgent.h"
35 #include "core/inspector/InspectorConsoleInstrumentation.h" 36 #include "core/inspector/InspectorConsoleInstrumentation.h"
36 #include "core/inspector/ScriptArguments.h" 37 #include "core/inspector/ScriptArguments.h"
37 #include "core/inspector/ScriptCallStack.h" 38 #include "core/inspector/ScriptCallStack.h"
38 #include "core/inspector/ScriptProfile.h" 39 #include "core/inspector/ScriptProfile.h"
39 #include "core/page/Chrome.h" 40 #include "core/page/Chrome.h"
40 #include "core/page/ChromeClient.h" 41 #include "core/page/ChromeClient.h"
41 #include "core/page/ConsoleTypes.h" 42 #include "core/page/ConsoleTypes.h"
42 #include "core/page/Frame.h" 43 #include "core/page/Frame.h"
43 #include "core/page/MemoryInfo.h" 44 #include "core/page/MemoryInfo.h"
44 #include "core/page/Page.h" 45 #include "core/page/Page.h"
(...skipping 21 matching lines...) Expand all
66 if (!page) 67 if (!page)
67 return; 68 return;
68 69
69 if (!acceptNoArguments && !arguments->argumentCount()) 70 if (!acceptNoArguments && !arguments->argumentCount())
70 return; 71 return;
71 72
72 size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1; 73 size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1;
73 RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, stackSize)); 74 RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, stackSize));
74 const ScriptCallFrame& lastCaller = callStack->at(0); 75 const ScriptCallFrame& lastCaller = callStack->at(0);
75 76
77 String executionContextURL = state->scriptExecutionContext()->url().string() ;
78 bool reportDetailedMessage = page->chrome().client()->shouldReportDetailedMe ssageForContext(state->context()) || page->chrome().client()->shouldReportDetail edMessageForURL(executionContextURL);
79
76 String message; 80 String message;
77 bool gotMessage = arguments->getFirstArgumentAsString(message); 81 bool gotMessage = arguments->getFirstArgumentAsString(message);
78 InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource, type, level, message, state, arguments); 82
83 OwnPtr<ConsoleMessage> consoleMessage = adoptPtr(new ConsoleMessage(reportDe tailedMessage, ConsoleAPIMessageSource, type, level, message, executionContextUR L, prpArguments, state, 0));
79 84
80 if (gotMessage) 85 if (gotMessage)
81 page->chrome().client()->addMessageToConsole(ConsoleAPIMessageSource, ty pe, level, message, lastCaller.lineNumber(), lastCaller.sourceURL()); 86 page->chrome().client()->addMessageToConsole(ConsoleAPIMessageSource, le vel, message, lastCaller.lineNumber(), lastCaller.sourceURL(), consoleMessage->g enerateJSONWithoutArguments()->toJSONString());
87
88 InspectorInstrumentation::addMessageToConsole(page, consoleMessage.release() , InspectorAgent::DontCheckFrontend);
82 } 89 }
83 90
84 void Console::debug(ScriptState* state, PassRefPtr<ScriptArguments> arguments) 91 void Console::debug(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
85 { 92 {
86 internalAddMessage(page(), LogMessageType, DebugMessageLevel, state, argumen ts); 93 internalAddMessage(page(), LogMessageType, DebugMessageLevel, state, argumen ts);
87 } 94 }
88 95
89 void Console::error(ScriptState* state, PassRefPtr<ScriptArguments> arguments) 96 void Console::error(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
90 { 97 {
91 internalAddMessage(page(), LogMessageType, ErrorMessageLevel, state, argumen ts); 98 internalAddMessage(page(), LogMessageType, ErrorMessageLevel, state, argumen ts);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 InspectorInstrumentation::stopConsoleTiming(m_frame, title, callStack.releas e()); 209 InspectorInstrumentation::stopConsoleTiming(m_frame, title, callStack.releas e());
203 } 210 }
204 211
205 void Console::timeStamp(PassRefPtr<ScriptArguments> arguments) 212 void Console::timeStamp(PassRefPtr<ScriptArguments> arguments)
206 { 213 {
207 InspectorInstrumentation::consoleTimeStamp(m_frame, arguments); 214 InspectorInstrumentation::consoleTimeStamp(m_frame, arguments);
208 } 215 }
209 216
210 void Console::group(ScriptState* state, PassRefPtr<ScriptArguments> arguments) 217 void Console::group(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
211 { 218 {
212 InspectorInstrumentation::addMessageToConsole(page(), ConsoleAPIMessageSourc e, StartGroupMessageType, LogMessageLevel, String(), state, arguments); 219 InspectorInstrumentation::addMessageToConsole(page(), adoptPtr(new ConsoleMe ssage(false, ConsoleAPIMessageSource, StartGroupMessageType, LogMessageLevel, St ring(), String(), arguments, state, 0)), InspectorAgent::DontCheckFrontend);
213 } 220 }
214 221
215 void Console::groupCollapsed(ScriptState* state, PassRefPtr<ScriptArguments> arg uments) 222 void Console::groupCollapsed(ScriptState* state, PassRefPtr<ScriptArguments> arg uments)
216 { 223 {
217 InspectorInstrumentation::addMessageToConsole(page(), ConsoleAPIMessageSourc e, StartGroupCollapsedMessageType, LogMessageLevel, String(), state, arguments); 224 InspectorInstrumentation::addMessageToConsole(page(), adoptPtr(new ConsoleMe ssage(false, ConsoleAPIMessageSource, StartGroupCollapsedMessageType, LogMessage Level, String(), String(), arguments, state, 0)), InspectorAgent::DontCheckFront end);
218 } 225 }
219 226
220 void Console::groupEnd() 227 void Console::groupEnd()
221 { 228 {
222 InspectorInstrumentation::addMessageToConsole(page(), ConsoleAPIMessageSourc e, EndGroupMessageType, LogMessageLevel, String(), String(), 0, 0); 229 InspectorInstrumentation::addMessageToConsole(page(), adoptPtr(new ConsoleMe ssage(false, ConsoleAPIMessageSource, EndGroupMessageType, LogMessageLevel, Stri ng(), String(), String(), 0, 0, 0, 0)), InspectorAgent::CheckFrontend);
223 } 230 }
224 231
225 PassRefPtr<MemoryInfo> Console::memory() const 232 PassRefPtr<MemoryInfo> Console::memory() const
226 { 233 {
227 // FIXME: Because we create a new object here each time, 234 // FIXME: Because we create a new object here each time,
228 // console.memory !== console.memory, which seems wrong. 235 // console.memory !== console.memory, which seems wrong.
229 return MemoryInfo::create(m_frame); 236 return MemoryInfo::create(m_frame);
230 } 237 }
231 238
232 Page* Console::page() const 239 Page* Console::page() const
233 { 240 {
234 if (!m_frame) 241 if (!m_frame)
235 return 0; 242 return 0;
236 return m_frame->page(); 243 return m_frame->page();
237 } 244 }
238 245
239 } // namespace WebCore 246 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698