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

Side by Side Diff: Source/core/frame/ConsoleBase.cpp

Issue 472023002: [DevTools] ConsoleAPI messages pass through frame console (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: PassRefPtr<ConsoleMessage> -> PassRefPtrWillBeRawPtr<ConsoleMessage> 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/ConsoleBase.h ('k') | Source/core/frame/FrameConsole.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) 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 internalAddMessage(DirXMLMessageType, LogMessageLevel, scriptState, argument s); 78 internalAddMessage(DirXMLMessageType, LogMessageLevel, scriptState, argument s);
79 } 79 }
80 80
81 void ConsoleBase::table(ScriptState* scriptState, PassRefPtrWillBeRawPtr<ScriptA rguments> arguments) 81 void ConsoleBase::table(ScriptState* scriptState, PassRefPtrWillBeRawPtr<ScriptA rguments> arguments)
82 { 82 {
83 internalAddMessage(TableMessageType, LogMessageLevel, scriptState, arguments ); 83 internalAddMessage(TableMessageType, LogMessageLevel, scriptState, arguments );
84 } 84 }
85 85
86 void ConsoleBase::clear(ScriptState* scriptState, PassRefPtrWillBeRawPtr<ScriptA rguments> arguments) 86 void ConsoleBase::clear(ScriptState* scriptState, PassRefPtrWillBeRawPtr<ScriptA rguments> arguments)
87 { 87 {
88 InspectorInstrumentation::addConsoleAPIMessageToConsole(context(), ClearMess ageType, LogMessageLevel, String(), scriptState, arguments); 88 internalAddMessage(ClearMessageType, LogMessageLevel, scriptState, arguments , true);
89 } 89 }
90 90
91 void ConsoleBase::trace(ScriptState* scriptState, PassRefPtrWillBeRawPtr<ScriptA rguments> arguments) 91 void ConsoleBase::trace(ScriptState* scriptState, PassRefPtrWillBeRawPtr<ScriptA rguments> arguments)
92 { 92 {
93 internalAddMessage(TraceMessageType, LogMessageLevel, scriptState, arguments , true, true); 93 internalAddMessage(TraceMessageType, LogMessageLevel, scriptState, arguments , true, true);
94 } 94 }
95 95
96 void ConsoleBase::assertCondition(ScriptState* scriptState, PassRefPtrWillBeRawP tr<ScriptArguments> arguments, bool condition) 96 void ConsoleBase::assertCondition(ScriptState* scriptState, PassRefPtrWillBeRawP tr<ScriptArguments> arguments, bool condition)
97 { 97 {
98 if (condition) 98 if (condition)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 InspectorInstrumentation::consoleTimeline(context(), title, scriptState); 145 InspectorInstrumentation::consoleTimeline(context(), title, scriptState);
146 } 146 }
147 147
148 void ConsoleBase::timelineEnd(ScriptState* scriptState, const String& title) 148 void ConsoleBase::timelineEnd(ScriptState* scriptState, const String& title)
149 { 149 {
150 InspectorInstrumentation::consoleTimelineEnd(context(), title, scriptState); 150 InspectorInstrumentation::consoleTimelineEnd(context(), title, scriptState);
151 } 151 }
152 152
153 void ConsoleBase::group(ScriptState* scriptState, PassRefPtrWillBeRawPtr<ScriptA rguments> arguments) 153 void ConsoleBase::group(ScriptState* scriptState, PassRefPtrWillBeRawPtr<ScriptA rguments> arguments)
154 { 154 {
155 InspectorInstrumentation::addConsoleAPIMessageToConsole(context(), StartGrou pMessageType, LogMessageLevel, String(), scriptState, arguments); 155 internalAddMessage(StartGroupMessageType, LogMessageLevel, scriptState, argu ments, true);
156 } 156 }
157 157
158 void ConsoleBase::groupCollapsed(ScriptState* scriptState, PassRefPtrWillBeRawPt r<ScriptArguments> arguments) 158 void ConsoleBase::groupCollapsed(ScriptState* scriptState, PassRefPtrWillBeRawPt r<ScriptArguments> arguments)
159 { 159 {
160 InspectorInstrumentation::addConsoleAPIMessageToConsole(context(), StartGrou pCollapsedMessageType, LogMessageLevel, String(), scriptState, arguments); 160 internalAddMessage(StartGroupCollapsedMessageType, LogMessageLevel, scriptSt ate, arguments, true);
161 } 161 }
162 162
163 void ConsoleBase::groupEnd() 163 void ConsoleBase::groupEnd()
164 { 164 {
165 InspectorInstrumentation::addConsoleAPIMessageToConsole(context(), EndGroupM essageType, LogMessageLevel, String(), nullptr, nullptr); 165 internalAddMessage(EndGroupMessageType, LogMessageLevel, nullptr, nullptr, t rue);
166 } 166 }
167 167
168 void ConsoleBase::internalAddMessage(MessageType type, MessageLevel level, Scrip tState* scriptState, PassRefPtrWillBeRawPtr<ScriptArguments> scriptArguments, bo ol acceptNoArguments, bool printTrace) 168 void ConsoleBase::internalAddMessage(MessageType type, MessageLevel level, Scrip tState* scriptState, PassRefPtrWillBeRawPtr<ScriptArguments> scriptArguments, bo ol acceptNoArguments, bool printTrace)
169 { 169 {
170 if (!context()) 170 RefPtrWillBeRawPtr<ScriptArguments> arguments = scriptArguments;
171 if (!acceptNoArguments && (!arguments || !arguments->argumentCount()))
171 return; 172 return;
172 173
173 RefPtrWillBeRawPtr<ScriptArguments> arguments = scriptArguments; 174 String message;
174 if (!acceptNoArguments && !arguments->argumentCount()) 175 bool gotStringMessage = arguments ? arguments->getFirstArgumentAsString(mess age) : false;
175 return; 176
177 RefPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(ConsoleAPIMes sageSource, level, gotStringMessage? message : String());
178 consoleMessage->setType(type);
179 consoleMessage->setScriptState(scriptState);
180 consoleMessage->setScriptArguments(arguments);
176 181
177 size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1; 182 size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1;
178 RefPtrWillBeRawPtr<ScriptCallStack> callStack(createScriptCallStackForConsol e(stackSize)); 183 RefPtrWillBeRawPtr<ScriptCallStack> callStack(createScriptCallStackForConsol e(stackSize));
184 consoleMessage->setCallStack(callStack);
179 185
180 String message; 186 reportMessageToConsole(consoleMessage.release());
181 bool gotStringMessage = arguments->getFirstArgumentAsString(message);
182 InspectorInstrumentation::addConsoleAPIMessageToConsole(context(), type, lev el, message, scriptState, arguments);
183 if (gotStringMessage)
184 reportMessageToClient(level, message, callStack);
185 } 187 }
186 188
187 } // namespace blink 189 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/ConsoleBase.h ('k') | Source/core/frame/FrameConsole.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698