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

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

Issue 26848007: Move Navigation Timing and other various window-level objects out of page/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/page/ConsoleBase.h ('k') | Source/core/page/ConsoleBase.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27 */
28
29 #include "config.h"
30 #include "core/page/Console.h"
31
32 #include "bindings/v8/ScriptCallStackFactory.h"
33 #include "bindings/v8/ScriptProfiler.h"
34 #include "core/dom/Document.h"
35 #include "core/inspector/ConsoleAPITypes.h"
36 #include "core/inspector/InspectorConsoleInstrumentation.h"
37 #include "core/inspector/ScriptArguments.h"
38 #include "core/inspector/ScriptCallStack.h"
39 #include "core/inspector/ScriptProfile.h"
40 #include "core/page/ConsoleTypes.h"
41 #include "platform/TraceEvent.h"
42 #include "wtf/text/CString.h"
43 #include "wtf/text/WTFString.h"
44
45 namespace WebCore {
46
47 ConsoleBase::~ConsoleBase()
48 {
49 }
50
51 void ConsoleBase::debug(ScriptState* state, PassRefPtr<ScriptArguments> argument s)
52 {
53 internalAddMessage(LogMessageType, DebugMessageLevel, state, arguments);
54 }
55
56 void ConsoleBase::error(ScriptState* state, PassRefPtr<ScriptArguments> argument s)
57 {
58 internalAddMessage(LogMessageType, ErrorMessageLevel, state, arguments);
59 }
60
61 void ConsoleBase::info(ScriptState* state, PassRefPtr<ScriptArguments> arguments )
62 {
63 log(state, arguments);
64 }
65
66 void ConsoleBase::log(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
67 {
68 internalAddMessage(LogMessageType, LogMessageLevel, state, arguments);
69 }
70
71 void ConsoleBase::warn(ScriptState* state, PassRefPtr<ScriptArguments> arguments )
72 {
73 internalAddMessage(LogMessageType, WarningMessageLevel, state, arguments);
74 }
75
76 void ConsoleBase::dir(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
77 {
78 internalAddMessage(DirMessageType, LogMessageLevel, state, arguments);
79 }
80
81 void ConsoleBase::dirxml(ScriptState* state, PassRefPtr<ScriptArguments> argumen ts)
82 {
83 internalAddMessage(DirXMLMessageType, LogMessageLevel, state, arguments);
84 }
85
86 void ConsoleBase::table(ScriptState* state, PassRefPtr<ScriptArguments> argument s)
87 {
88 internalAddMessage(TableMessageType, LogMessageLevel, state, arguments);
89 }
90
91 void ConsoleBase::clear(ScriptState* state, PassRefPtr<ScriptArguments> argument s)
92 {
93 InspectorInstrumentation::addMessageToConsole(context(), ConsoleAPIMessageSo urce, ClearMessageType, LogMessageLevel, String(), state, arguments);
94 }
95
96 void ConsoleBase::trace(ScriptState* state, PassRefPtr<ScriptArguments> argument s)
97 {
98 internalAddMessage(TraceMessageType, LogMessageLevel, state, arguments, true , true);
99 }
100
101 void ConsoleBase::assertCondition(ScriptState* state, PassRefPtr<ScriptArguments > arguments, bool condition)
102 {
103 if (condition)
104 return;
105
106 internalAddMessage(AssertMessageType, ErrorMessageLevel, state, arguments, t rue);
107 }
108
109 void ConsoleBase::count(ScriptState* state, PassRefPtr<ScriptArguments> argument s)
110 {
111 InspectorInstrumentation::consoleCount(context(), state, arguments);
112 }
113
114 void ConsoleBase::markTimeline(const String& title)
115 {
116 InspectorInstrumentation::consoleTimeStamp(context(), title);
117 }
118
119 void ConsoleBase::profile(ScriptState* state, const String& title)
120 {
121 ScriptExecutionContext* context = this->context();
122 if (!context)
123 return;
124
125 // FIXME: log a console message when profiling is disabled.
126 if (!profilerEnabled())
127 return;
128
129 String resolvedTitle = title;
130 if (title.isNull()) // no title so give it the next user initiated profile t itle.
131 resolvedTitle = InspectorInstrumentation::getCurrentUserInitiatedProfile Name(context, true);
132
133 ScriptProfiler::start(resolvedTitle);
134 InspectorInstrumentation::addMessageToConsole(context, ConsoleAPIMessageSour ce, ProfileMessageType, DebugMessageLevel, resolvedTitle, String(), 0, 0, state) ;
135 }
136
137 void ConsoleBase::profileEnd(ScriptState* state, const String& title)
138 {
139 ScriptExecutionContext* context = this->context();
140 if (!context)
141 return;
142
143 if (!profilerEnabled())
144 return;
145
146 RefPtr<ScriptProfile> profile = ScriptProfiler::stop(title);
147 if (!profile)
148 return;
149
150 RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(1));
151 InspectorInstrumentation::addProfile(context, profile, callStack);
152 }
153
154 void ConsoleBase::time(const String& title)
155 {
156 InspectorInstrumentation::consoleTime(context(), title);
157 TRACE_EVENT_COPY_ASYNC_BEGIN0("webkit.console", title.utf8().data(), this);
158 }
159
160 void ConsoleBase::timeEnd(ScriptState* state, const String& title)
161 {
162 TRACE_EVENT_COPY_ASYNC_END0("webkit.console", title.utf8().data(), this);
163 InspectorInstrumentation::consoleTimeEnd(context(), title, state);
164 }
165
166 void ConsoleBase::timeStamp(const String& title)
167 {
168 InspectorInstrumentation::consoleTimeStamp(context(), title);
169 }
170
171 void ConsoleBase::timeline(ScriptState* state, const String& title)
172 {
173 InspectorInstrumentation::consoleTimeline(context(), title, state);
174 }
175
176 void ConsoleBase::timelineEnd(ScriptState* state, const String& title)
177 {
178 InspectorInstrumentation::consoleTimelineEnd(context(), title, state);
179 }
180
181 void ConsoleBase::group(ScriptState* state, PassRefPtr<ScriptArguments> argument s)
182 {
183 InspectorInstrumentation::addMessageToConsole(context(), ConsoleAPIMessageSo urce, StartGroupMessageType, LogMessageLevel, String(), state, arguments);
184 }
185
186 void ConsoleBase::groupCollapsed(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
187 {
188 InspectorInstrumentation::addMessageToConsole(context(), ConsoleAPIMessageSo urce, StartGroupCollapsedMessageType, LogMessageLevel, String(), state, argument s);
189 }
190
191 void ConsoleBase::groupEnd()
192 {
193 InspectorInstrumentation::addMessageToConsole(context(), ConsoleAPIMessageSo urce, EndGroupMessageType, LogMessageLevel, String(), 0);
194 }
195
196 void ConsoleBase::internalAddMessage(MessageType type, MessageLevel level, Scrip tState* state, PassRefPtr<ScriptArguments> scriptArguments, bool acceptNoArgumen ts, bool printTrace)
197 {
198 if (!context())
199 return;
200
201 RefPtr<ScriptArguments> arguments = scriptArguments;
202 if (!acceptNoArguments && !arguments->argumentCount())
203 return;
204
205 size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1;
206 RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(stackSize) );
207 const ScriptCallFrame& lastCaller = callStack->at(0);
208
209 String message;
210 bool gotStringMessage = arguments->getFirstArgumentAsString(message);
211 InspectorInstrumentation::addMessageToConsole(context(), ConsoleAPIMessageSo urce, type, level, message, state, arguments);
212 if (gotStringMessage)
213 reportMessageToClient(level, message, callStack);
214 }
215
216 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/ConsoleBase.h ('k') | Source/core/page/ConsoleBase.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698