OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 17 matching lines...) Expand all Loading... | |
28 | 28 |
29 #include "InspectorFrontend.h" | 29 #include "InspectorFrontend.h" |
30 #include "bindings/v8/ScriptCallStackFactory.h" | 30 #include "bindings/v8/ScriptCallStackFactory.h" |
31 #include "bindings/v8/ScriptController.h" | 31 #include "bindings/v8/ScriptController.h" |
32 #include "bindings/v8/ScriptObject.h" | 32 #include "bindings/v8/ScriptObject.h" |
33 #include "bindings/v8/ScriptProfiler.h" | 33 #include "bindings/v8/ScriptProfiler.h" |
34 #include "core/inspector/ConsoleMessage.h" | 34 #include "core/inspector/ConsoleMessage.h" |
35 #include "core/inspector/InjectedScriptHost.h" | 35 #include "core/inspector/InjectedScriptHost.h" |
36 #include "core/inspector/InjectedScriptManager.h" | 36 #include "core/inspector/InjectedScriptManager.h" |
37 #include "core/inspector/InspectorState.h" | 37 #include "core/inspector/InspectorState.h" |
38 #include "core/inspector/InspectorTimelineAgent.h" | |
38 #include "core/inspector/InstrumentingAgents.h" | 39 #include "core/inspector/InstrumentingAgents.h" |
39 #include "core/inspector/ScriptArguments.h" | 40 #include "core/inspector/ScriptArguments.h" |
40 #include "core/inspector/ScriptCallFrame.h" | 41 #include "core/inspector/ScriptCallFrame.h" |
41 #include "core/inspector/ScriptCallStack.h" | 42 #include "core/inspector/ScriptCallStack.h" |
42 #include "core/loader/DocumentLoader.h" | 43 #include "core/loader/DocumentLoader.h" |
43 #include "core/page/Frame.h" | 44 #include "core/page/Frame.h" |
44 #include "core/page/Page.h" | 45 #include "core/page/Page.h" |
45 #include "core/platform/network/ResourceError.h" | 46 #include "core/platform/network/ResourceError.h" |
46 #include "core/platform/network/ResourceResponse.h" | 47 #include "core/platform/network/ResourceResponse.h" |
47 #include "wtf/CurrentTime.h" | 48 #include "wtf/CurrentTime.h" |
48 #include "wtf/OwnPtr.h" | 49 #include "wtf/OwnPtr.h" |
49 #include "wtf/PassOwnPtr.h" | 50 #include "wtf/PassOwnPtr.h" |
50 #include "wtf/text/StringBuilder.h" | 51 #include "wtf/text/StringBuilder.h" |
51 #include "wtf/text/WTFString.h" | 52 #include "wtf/text/WTFString.h" |
52 | 53 |
53 namespace WebCore { | 54 namespace WebCore { |
54 | 55 |
55 static const unsigned maximumConsoleMessages = 1000; | 56 static const unsigned maximumConsoleMessages = 1000; |
56 static const int expireConsoleMessagesStep = 100; | 57 static const int expireConsoleMessagesStep = 100; |
57 | 58 |
58 namespace ConsoleAgentState { | 59 namespace ConsoleAgentState { |
59 static const char monitoringXHR[] = "monitoringXHR"; | 60 static const char monitoringXHR[] = "monitoringXHR"; |
60 static const char consoleMessagesEnabled[] = "consoleMessagesEnabled"; | 61 static const char consoleMessagesEnabled[] = "consoleMessagesEnabled"; |
61 } | 62 } |
62 | 63 |
63 int InspectorConsoleAgent::s_enabledAgentCount = 0; | 64 int InspectorConsoleAgent::s_enabledAgentCount = 0; |
64 | 65 |
65 InspectorConsoleAgent::InspectorConsoleAgent(InstrumentingAgents* instrumentingA gents, InspectorCompositeState* state, InjectedScriptManager* injectedScriptMana ger) | 66 InspectorConsoleAgent::InspectorConsoleAgent(InstrumentingAgents* instrumentingA gents, InspectorTimelineAgent* timelineAgent, InspectorCompositeState* state, In jectedScriptManager* injectedScriptManager) |
66 : InspectorBaseAgent<InspectorConsoleAgent>("Console", instrumentingAgents, state) | 67 : InspectorBaseAgent<InspectorConsoleAgent>("Console", instrumentingAgents, state) |
68 , m_timelineAgent(timelineAgent) | |
67 , m_injectedScriptManager(injectedScriptManager) | 69 , m_injectedScriptManager(injectedScriptManager) |
68 , m_frontend(0) | 70 , m_frontend(0) |
69 , m_previousMessage(0) | 71 , m_previousMessage(0) |
70 , m_expiredConsoleMessageCount(0) | 72 , m_expiredConsoleMessageCount(0) |
71 , m_enabled(false) | 73 , m_enabled(false) |
72 { | 74 { |
73 m_instrumentingAgents->setInspectorConsoleAgent(this); | 75 m_instrumentingAgents->setInspectorConsoleAgent(this); |
74 } | 76 } |
75 | 77 |
76 InspectorConsoleAgent::~InspectorConsoleAgent() | 78 InspectorConsoleAgent::~InspectorConsoleAgent() |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 } | 186 } |
185 | 187 |
186 Vector<unsigned> InspectorConsoleAgent::consoleMessageArgumentCounts() | 188 Vector<unsigned> InspectorConsoleAgent::consoleMessageArgumentCounts() |
187 { | 189 { |
188 Vector<unsigned> result(m_consoleMessages.size()); | 190 Vector<unsigned> result(m_consoleMessages.size()); |
189 for (size_t i = 0; i < m_consoleMessages.size(); i++) | 191 for (size_t i = 0; i < m_consoleMessages.size(); i++) |
190 result[i] = m_consoleMessages[i]->argumentCount(); | 192 result[i] = m_consoleMessages[i]->argumentCount(); |
191 return result; | 193 return result; |
192 } | 194 } |
193 | 195 |
194 void InspectorConsoleAgent::startConsoleTiming(ScriptExecutionContext*, const St ring& title) | 196 void InspectorConsoleAgent::consoleTime(ScriptExecutionContext*, const String& t itle) |
195 { | 197 { |
196 // Follow Firebug's behavior of requiring a title that is not null or | 198 // Follow Firebug's behavior of requiring a title that is not null or |
197 // undefined for timing functions | 199 // undefined for timing functions |
198 if (title.isNull()) | 200 if (title.isNull()) |
199 return; | 201 return; |
200 | 202 |
201 m_times.add(title, monotonicallyIncreasingTime()); | 203 m_times.add(title, monotonicallyIncreasingTime()); |
202 } | 204 } |
203 | 205 |
204 void InspectorConsoleAgent::stopConsoleTiming(ScriptExecutionContext*, const Str ing& title, PassRefPtr<ScriptCallStack> callStack) | 206 void InspectorConsoleAgent::consoleTimeEnd(ScriptExecutionContext*, const String & title, ScriptState* state) |
205 { | 207 { |
206 // Follow Firebug's behavior of requiring a title that is not null or | 208 // Follow Firebug's behavior of requiring a title that is not null or |
207 // undefined for timing functions | 209 // undefined for timing functions |
208 if (title.isNull()) | 210 if (title.isNull()) |
209 return; | 211 return; |
210 | 212 |
211 HashMap<String, double>::iterator it = m_times.find(title); | 213 HashMap<String, double>::iterator it = m_times.find(title); |
212 if (it == m_times.end()) | 214 if (it == m_times.end()) |
213 return; | 215 return; |
214 | 216 |
215 double startTime = it->value; | 217 double startTime = it->value; |
216 m_times.remove(it); | 218 m_times.remove(it); |
217 | 219 |
218 double elapsed = monotonicallyIncreasingTime() - startTime; | 220 double elapsed = monotonicallyIncreasingTime() - startTime; |
219 String message = title + String::format(": %.3fms", elapsed * 1000); | 221 String message = title + String::format(": %.3fms", elapsed * 1000); |
220 const ScriptCallFrame& lastCaller = callStack->at(0); | 222 addMessageToConsole(ConsoleAPIMessageSource, LogMessageType, DebugMessageLev el, message, String(), 0, 0, state); |
caseq
2013/09/13 15:36:18
are we intentionally loosing call-site location he
| |
221 addMessageToConsole(ConsoleAPIMessageSource, TimingMessageType, DebugMessage Level, message, lastCaller.sourceURL(), lastCaller.lineNumber(), lastCaller.colu mnNumber()); | 223 } |
224 | |
225 void InspectorConsoleAgent::consoleTimeline(ScriptExecutionContext* context, con st String& title, ScriptState* state) | |
226 { | |
227 m_timelineAgent->consoleTimeline(context, title, state); | |
228 } | |
229 | |
230 void InspectorConsoleAgent::consoleTimelineEnd(ScriptExecutionContext* context, const String& title, ScriptState* state) | |
231 { | |
232 m_timelineAgent->consoleTimelineEnd(context, title, state); | |
222 } | 233 } |
223 | 234 |
224 void InspectorConsoleAgent::consoleCount(ScriptState* state, PassRefPtr<ScriptAr guments> arguments) | 235 void InspectorConsoleAgent::consoleCount(ScriptState* state, PassRefPtr<ScriptAr guments> arguments) |
225 { | 236 { |
226 RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state)); | 237 RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state)); |
227 const ScriptCallFrame& lastCaller = callStack->at(0); | 238 const ScriptCallFrame& lastCaller = callStack->at(0); |
228 // Follow Firebug's behavior of counting with null and undefined title in | 239 // Follow Firebug's behavior of counting with null and undefined title in |
229 // the same bucket as no argument | 240 // the same bucket as no argument |
230 String title; | 241 String title; |
231 arguments->getFirstArgumentAsString(title); | 242 arguments->getFirstArgumentAsString(title); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
337 int m_heapObjectId; | 348 int m_heapObjectId; |
338 }; | 349 }; |
339 | 350 |
340 void InspectorConsoleAgent::addInspectedHeapObject(ErrorString*, int inspectedHe apObjectId) | 351 void InspectorConsoleAgent::addInspectedHeapObject(ErrorString*, int inspectedHe apObjectId) |
341 { | 352 { |
342 m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(n ew InspectableHeapObject(inspectedHeapObjectId))); | 353 m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(n ew InspectableHeapObject(inspectedHeapObjectId))); |
343 } | 354 } |
344 | 355 |
345 } // namespace WebCore | 356 } // namespace WebCore |
346 | 357 |
OLD | NEW |