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

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

Issue 18822004: Extension Error Piping - Blink: WebKit Side (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Consolidate [did]AddMessageToConsole() and reportDetailedMessage() 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 static void internalAddMessage(Page* page, MessageType type, MessageLevel level, ScriptState* state, PassRefPtr<ScriptArguments> prpArguments, bool acceptNoArgu ments = false, bool printTrace = false) 62 static void internalAddMessage(Page* page, MessageType type, MessageLevel level, ScriptState* state, PassRefPtr<ScriptArguments> prpArguments, bool acceptNoArgu ments = false, bool printTrace = false)
63 { 63 {
64 RefPtr<ScriptArguments> arguments = prpArguments; 64 RefPtr<ScriptArguments> arguments = prpArguments;
65 65
66 if (!page) 66 if (!page)
67 return; 67 return;
68 68
69 if (!acceptNoArguments && !arguments->argumentCount()) 69 if (!acceptNoArguments && !arguments->argumentCount())
70 return; 70 return;
71 71
72 size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1; 72 bool reportDetailedMessage = page->chrome().client()->shouldReportDetailedMe ssage(state->scriptExecutionContext()->url().string());
73 RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, stackSize)); 73
74 size_t stackSize = printTrace || reportDetailedMessage ? ScriptCallStack::ma xCallStackSizeToCapture : 1;
75 RefPtr<ScriptCallStack> callStack(createScriptCallStack(stackSize));
74 const ScriptCallFrame& lastCaller = callStack->at(0); 76 const ScriptCallFrame& lastCaller = callStack->at(0);
75 77
76 String message; 78 String message;
77 bool gotMessage = arguments->getFirstArgumentAsString(message); 79 bool gotMessage = arguments->getFirstArgumentAsString(message);
78 InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource, type, level, message, state, arguments); 80 InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource, type, level, message, state, arguments);
79 81
80 if (gotMessage) 82 if (gotMessage) {
81 page->chrome().client()->addMessageToConsole(ConsoleAPIMessageSource, ty pe, level, message, lastCaller.lineNumber(), lastCaller.sourceURL()); 83 RefPtr<ScriptCallStack> stackToUse = callStack;
84 // Unfortunately, the check above for whether or not we care is only heu ristically correct, since the url isn't always the same as the context in which the script was executed. In this case, we may decide we want detailed informatio n only after we generate the original stack trace.
85 if (!reportDetailedMessage && (reportDetailedMessage = page->chrome().cl ient()->shouldReportDetailedMessage(lastCaller.sourceURL())))
86 stackToUse = createScriptCallStack(ScriptCallStack::maxCallStackSize ToCapture);
87
88 String stackTrace;
89 if (reportDetailedMessage)
90 stackTrace = stackToUse->buildInspectorArray()->toJSONString();
91
92 page->chrome().client()->addMessageToConsole(ConsoleAPIMessageSource, le vel, message, lastCaller.lineNumber(), lastCaller.sourceURL(), stackTrace);
93 }
82 } 94 }
83 95
84 void Console::debug(ScriptState* state, PassRefPtr<ScriptArguments> arguments) 96 void Console::debug(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
85 { 97 {
86 internalAddMessage(page(), LogMessageType, DebugMessageLevel, state, argumen ts); 98 internalAddMessage(page(), LogMessageType, DebugMessageLevel, state, argumen ts);
87 } 99 }
88 100
89 void Console::error(ScriptState* state, PassRefPtr<ScriptArguments> arguments) 101 void Console::error(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
90 { 102 {
91 internalAddMessage(page(), LogMessageType, ErrorMessageLevel, state, argumen ts); 103 internalAddMessage(page(), LogMessageType, ErrorMessageLevel, state, argumen ts);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 242 }
231 243
232 Page* Console::page() const 244 Page* Console::page() const
233 { 245 {
234 if (!m_frame) 246 if (!m_frame)
235 return 0; 247 return 0;
236 return m_frame->page(); 248 return m_frame->page();
237 } 249 }
238 250
239 } // namespace WebCore 251 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698