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

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: Extracted Formatting Created 7 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) 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 21 matching lines...) Expand all
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/InspectorConsoleInstrumentation.h" 35 #include "core/inspector/InspectorConsoleInstrumentation.h"
36 #include "core/inspector/ScriptArguments.h" 36 #include "core/inspector/ScriptArguments.h"
37 #include "core/inspector/ScriptCallStack.h" 37 #include "core/inspector/ScriptCallStack.h"
38 #include "core/inspector/ScriptProfile.h" 38 #include "core/inspector/ScriptProfile.h"
39 #include "core/page/Chrome.h" 39 #include "core/page/Chrome.h"
40 #include "core/page/ChromeClient.h" 40 #include "core/page/ChromeClient.h"
41 #include "core/page/ConsoleTypes.h" 41 #include "core/page/ConsoleTypes.h"
42 #include "core/page/FormatConsoleMessage.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"
45 #include "wtf/text/CString.h" 46 #include "wtf/text/CString.h"
46 #include "wtf/text/WTFString.h" 47 #include "wtf/text/WTFString.h"
47 48
48 #include "core/platform/chromium/TraceEvent.h" 49 #include "core/platform/chromium/TraceEvent.h"
49 50
50 namespace WebCore { 51 namespace WebCore {
51 52
(...skipping 10 matching lines...) Expand all
62 static void internalAddMessage(Page* page, MessageType type, MessageLevel level, ScriptState* state, PassRefPtr<ScriptArguments> prpArguments, bool acceptNoArgu ments = false, bool printTrace = false) 63 static void internalAddMessage(Page* page, MessageType type, MessageLevel level, ScriptState* state, PassRefPtr<ScriptArguments> prpArguments, bool acceptNoArgu ments = false, bool printTrace = false)
63 { 64 {
64 RefPtr<ScriptArguments> arguments = prpArguments; 65 RefPtr<ScriptArguments> arguments = prpArguments;
65 66
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 RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, stackSize));
74 const ScriptCallFrame& lastCaller = callStack->at(0);
75
76 String message; 73 String message;
77 bool gotMessage = arguments->getFirstArgumentAsString(message); 74 bool gotMessage = arguments->getFirstArgumentAsString(message);
78 InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource, type, level, message, state, arguments); 75 InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource, type, level, message, state, arguments);
79 76
80 if (gotMessage) 77 if (gotMessage) {
81 page->chrome().client()->addMessageToConsole(ConsoleAPIMessageSource, ty pe, level, message, lastCaller.lineNumber(), lastCaller.sourceURL()); 78 RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, 1));
79 if (page->chrome().client()->shouldReportDetailedMessageForSource(callSt ack->at(0).sourceURL())) {
80 callStack = createScriptCallStack(ScriptCallStack::maxCallStackSizeT oCapture);
81 message = formatConsoleMessage(message, callStack);
82 }
83 page->chrome().client()->addMessageToConsole(ConsoleAPIMessageSource, ty pe, level, message, callStack->at(0).lineNumber(), callStack->at(0).sourceURL()) ;
84 }
82 } 85 }
83 86
84 void Console::debug(ScriptState* state, PassRefPtr<ScriptArguments> arguments) 87 void Console::debug(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
85 { 88 {
86 internalAddMessage(page(), LogMessageType, DebugMessageLevel, state, argumen ts); 89 internalAddMessage(page(), LogMessageType, DebugMessageLevel, state, argumen ts);
87 } 90 }
88 91
89 void Console::error(ScriptState* state, PassRefPtr<ScriptArguments> arguments) 92 void Console::error(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
90 { 93 {
91 internalAddMessage(page(), LogMessageType, ErrorMessageLevel, state, argumen ts); 94 internalAddMessage(page(), LogMessageType, ErrorMessageLevel, state, argumen ts);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 233 }
231 234
232 Page* Console::page() const 235 Page* Console::page() const
233 { 236 {
234 if (!m_frame) 237 if (!m_frame)
235 return 0; 238 return 0;
236 return m_frame->page(); 239 return m_frame->page();
237 } 240 }
238 241
239 } // namespace WebCore 242 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698