| 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 #include "ScriptCallStack.h" | 64 #include "ScriptCallStack.h" |
| 65 #include "ScriptProfile.h" | 65 #include "ScriptProfile.h" |
| 66 #include "WorkerContext.h" | 66 #include "WorkerContext.h" |
| 67 #include "WorkerThread.h" | 67 #include "WorkerThread.h" |
| 68 #include "XMLHttpRequest.h" | 68 #include "XMLHttpRequest.h" |
| 69 #include <wtf/StdLibExtras.h> | 69 #include <wtf/StdLibExtras.h> |
| 70 #include <wtf/text/CString.h> | 70 #include <wtf/text/CString.h> |
| 71 | 71 |
| 72 namespace WebCore { | 72 namespace WebCore { |
| 73 | 73 |
| 74 static const char* const listenerEventCategoryType = "listener"; | |
| 75 static const char* const instrumentationEventCategoryType = "instrumentation"; | |
| 76 | |
| 77 static const char* const setTimerEventName = "setTimer"; | 74 static const char* const setTimerEventName = "setTimer"; |
| 78 static const char* const clearTimerEventName = "clearTimer"; | 75 static const char* const clearTimerEventName = "clearTimer"; |
| 79 static const char* const timerFiredEventName = "timerFired"; | 76 static const char* const timerFiredEventName = "timerFired"; |
| 80 | 77 |
| 81 int InspectorInstrumentation::s_frontendCounter = 0; | 78 int InspectorInstrumentation::s_frontendCounter = 0; |
| 82 | 79 |
| 83 static bool eventHasListeners(const AtomicString& eventType, DOMWindow* window,
Node* node, const Vector<EventContext>& ancestors) | 80 static bool eventHasListeners(const AtomicString& eventType, DOMWindow* window,
Node* node, const Vector<EventContext>& ancestors) |
| 84 { | 81 { |
| 85 if (window && window->hasEventListeners(eventType)) | 82 if (window && window->hasEventListeners(eventType)) |
| 86 return true; | 83 return true; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } | 231 } |
| 235 | 232 |
| 236 void InspectorInstrumentation::didScheduleResourceRequestImpl(InstrumentingAgent
s* instrumentingAgents, const String& url) | 233 void InspectorInstrumentation::didScheduleResourceRequestImpl(InstrumentingAgent
s* instrumentingAgents, const String& url) |
| 237 { | 234 { |
| 238 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTi
melineAgent()) | 235 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTi
melineAgent()) |
| 239 timelineAgent->didScheduleResourceRequest(url); | 236 timelineAgent->didScheduleResourceRequest(url); |
| 240 } | 237 } |
| 241 | 238 |
| 242 void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents* instrume
ntingAgents, int timerId, int timeout, bool singleShot) | 239 void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents* instrume
ntingAgents, int timerId, int timeout, bool singleShot) |
| 243 { | 240 { |
| 244 pauseOnNativeEventIfNeeded(instrumentingAgents, instrumentationEventCategory
Type, setTimerEventName, true); | 241 pauseOnNativeEventIfNeeded(instrumentingAgents, false, setTimerEventName, tr
ue); |
| 245 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTi
melineAgent()) | 242 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTi
melineAgent()) |
| 246 timelineAgent->didInstallTimer(timerId, timeout, singleShot); | 243 timelineAgent->didInstallTimer(timerId, timeout, singleShot); |
| 247 } | 244 } |
| 248 | 245 |
| 249 void InspectorInstrumentation::didRemoveTimerImpl(InstrumentingAgents* instrumen
tingAgents, int timerId) | 246 void InspectorInstrumentation::didRemoveTimerImpl(InstrumentingAgents* instrumen
tingAgents, int timerId) |
| 250 { | 247 { |
| 251 pauseOnNativeEventIfNeeded(instrumentingAgents, instrumentationEventCategory
Type, clearTimerEventName, true); | 248 pauseOnNativeEventIfNeeded(instrumentingAgents, false, clearTimerEventName,
true); |
| 252 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTi
melineAgent()) | 249 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTi
melineAgent()) |
| 253 timelineAgent->didRemoveTimer(timerId); | 250 timelineAgent->didRemoveTimer(timerId); |
| 254 } | 251 } |
| 255 | 252 |
| 256 InspectorInstrumentationCookie InspectorInstrumentation::willCallFunctionImpl(In
strumentingAgents* instrumentingAgents, const String& scriptName, int scriptLine
) | 253 InspectorInstrumentationCookie InspectorInstrumentation::willCallFunctionImpl(In
strumentingAgents* instrumentingAgents, const String& scriptName, int scriptLine
) |
| 257 { | 254 { |
| 258 int timelineAgentId = 0; | 255 int timelineAgentId = 0; |
| 259 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTi
melineAgent()) { | 256 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTi
melineAgent()) { |
| 260 timelineAgent->willCallFunction(scriptName, scriptLine); | 257 timelineAgent->willCallFunction(scriptName, scriptLine); |
| 261 timelineAgentId = timelineAgent->id(); | 258 timelineAgentId = timelineAgent->id(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 281 } | 278 } |
| 282 | 279 |
| 283 void InspectorInstrumentation::didChangeXHRReadyStateImpl(const InspectorInstrum
entationCookie& cookie) | 280 void InspectorInstrumentation::didChangeXHRReadyStateImpl(const InspectorInstrum
entationCookie& cookie) |
| 284 { | 281 { |
| 285 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie)) | 282 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie)) |
| 286 timelineAgent->didChangeXHRReadyState(); | 283 timelineAgent->didChangeXHRReadyState(); |
| 287 } | 284 } |
| 288 | 285 |
| 289 InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventImpl(I
nstrumentingAgents* instrumentingAgents, const Event& event, DOMWindow* window,
Node* node, const Vector<EventContext>& ancestors) | 286 InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventImpl(I
nstrumentingAgents* instrumentingAgents, const Event& event, DOMWindow* window,
Node* node, const Vector<EventContext>& ancestors) |
| 290 { | 287 { |
| 291 pauseOnNativeEventIfNeeded(instrumentingAgents, listenerEventCategoryType, e
vent.type(), false); | 288 pauseOnNativeEventIfNeeded(instrumentingAgents, true, event.type(), false); |
| 292 | 289 |
| 293 int timelineAgentId = 0; | 290 int timelineAgentId = 0; |
| 294 InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimeli
neAgent(); | 291 InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimeli
neAgent(); |
| 295 if (timelineAgent && eventHasListeners(event.type(), window, node, ancestors
)) { | 292 if (timelineAgent && eventHasListeners(event.type(), window, node, ancestors
)) { |
| 296 timelineAgent->willDispatchEvent(event); | 293 timelineAgent->willDispatchEvent(event); |
| 297 timelineAgentId = timelineAgent->id(); | 294 timelineAgentId = timelineAgent->id(); |
| 298 } | 295 } |
| 299 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId); | 296 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId); |
| 300 } | 297 } |
| 301 | 298 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 } | 336 } |
| 340 | 337 |
| 341 void InspectorInstrumentation::didEvaluateScriptImpl(const InspectorInstrumentat
ionCookie& cookie) | 338 void InspectorInstrumentation::didEvaluateScriptImpl(const InspectorInstrumentat
ionCookie& cookie) |
| 342 { | 339 { |
| 343 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie)) | 340 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie)) |
| 344 timelineAgent->didEvaluateScript(); | 341 timelineAgent->didEvaluateScript(); |
| 345 } | 342 } |
| 346 | 343 |
| 347 InspectorInstrumentationCookie InspectorInstrumentation::willFireTimerImpl(Instr
umentingAgents* instrumentingAgents, int timerId) | 344 InspectorInstrumentationCookie InspectorInstrumentation::willFireTimerImpl(Instr
umentingAgents* instrumentingAgents, int timerId) |
| 348 { | 345 { |
| 349 pauseOnNativeEventIfNeeded(instrumentingAgents, instrumentationEventCategory
Type, timerFiredEventName, false); | 346 pauseOnNativeEventIfNeeded(instrumentingAgents, false, timerFiredEventName,
false); |
| 350 | 347 |
| 351 int timelineAgentId = 0; | 348 int timelineAgentId = 0; |
| 352 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTi
melineAgent()) { | 349 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTi
melineAgent()) { |
| 353 timelineAgent->willFireTimer(timerId); | 350 timelineAgent->willFireTimer(timerId); |
| 354 timelineAgentId = timelineAgent->id(); | 351 timelineAgentId = timelineAgent->id(); |
| 355 } | 352 } |
| 356 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId); | 353 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId); |
| 357 } | 354 } |
| 358 | 355 |
| 359 void InspectorInstrumentation::didFireTimerImpl(const InspectorInstrumentationCo
okie& cookie) | 356 void InspectorInstrumentation::didFireTimerImpl(const InspectorInstrumentationCo
okie& cookie) |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 return workerInspectorController && workerInspectorController->hasFronte
nd(); | 957 return workerInspectorController && workerInspectorController->hasFronte
nd(); |
| 961 } | 958 } |
| 962 #endif | 959 #endif |
| 963 | 960 |
| 964 ASSERT(scriptExecutionContext->isDocument()); | 961 ASSERT(scriptExecutionContext->isDocument()); |
| 965 Document* document = static_cast<Document*>(scriptExecutionContext); | 962 Document* document = static_cast<Document*>(scriptExecutionContext); |
| 966 Page* page = document->page(); | 963 Page* page = document->page(); |
| 967 return page && page->inspectorController()->hasFrontend(); | 964 return page && page->inspectorController()->hasFrontend(); |
| 968 } | 965 } |
| 969 | 966 |
| 970 void InspectorInstrumentation::pauseOnNativeEventIfNeeded(InstrumentingAgents* i
nstrumentingAgents, const String& categoryType, const String& eventName, bool sy
nchronous) | 967 void InspectorInstrumentation::pauseOnNativeEventIfNeeded(InstrumentingAgents* i
nstrumentingAgents, bool isDOMEvent, const String& eventName, bool synchronous) |
| 971 { | 968 { |
| 972 #if ENABLE(JAVASCRIPT_DEBUGGER) | 969 #if ENABLE(JAVASCRIPT_DEBUGGER) |
| 973 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspe
ctorDOMDebuggerAgent()) | 970 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspe
ctorDOMDebuggerAgent()) |
| 974 domDebuggerAgent->pauseOnNativeEventIfNeeded(categoryType, eventName, sy
nchronous); | 971 domDebuggerAgent->pauseOnNativeEventIfNeeded(isDOMEvent, eventName, sync
hronous); |
| 975 #endif | 972 #endif |
| 976 } | 973 } |
| 977 | 974 |
| 978 void InspectorInstrumentation::cancelPauseOnNativeEvent(InstrumentingAgents* ins
trumentingAgents) | 975 void InspectorInstrumentation::cancelPauseOnNativeEvent(InstrumentingAgents* ins
trumentingAgents) |
| 979 { | 976 { |
| 980 #if ENABLE(JAVASCRIPT_DEBUGGER) | 977 #if ENABLE(JAVASCRIPT_DEBUGGER) |
| 981 if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDe
buggerAgent()) | 978 if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDe
buggerAgent()) |
| 982 debuggerAgent->cancelPauseOnNextStatement(); | 979 debuggerAgent->cancelPauseOnNextStatement(); |
| 983 #endif | 980 #endif |
| 984 } | 981 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 { | 1030 { |
| 1034 if (!workerContext) | 1031 if (!workerContext) |
| 1035 return 0; | 1032 return 0; |
| 1036 return instrumentationForWorkerContext(workerContext); | 1033 return instrumentationForWorkerContext(workerContext); |
| 1037 } | 1034 } |
| 1038 #endif | 1035 #endif |
| 1039 | 1036 |
| 1040 } // namespace WebCore | 1037 } // namespace WebCore |
| 1041 | 1038 |
| 1042 #endif // !ENABLE(INSPECTOR) | 1039 #endif // !ENABLE(INSPECTOR) |
| 1040 |
| OLD | NEW |