InspectorInstrumentationCookie InspectorInstrumentation::willLoadXHRImpl(InstrumentingAgents* instrumentingAgents, XMLHttpRequest* request)
{
    int timelineAgentId = 0;
    InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
    if (timelineAgent && request->hasEventListeners(eventNames().loadEvent)) {
        timelineAgent->willLoadXHR(request->url());
        timelineAgentId = timelineAgent->id();
    }
    return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
}
Ejemplo n.º 2
0
void XMLHttpRequest::callReadyStateChangeListener()
{
    if (!scriptExecutionContext())
        return;

#if ENABLE(INSPECTOR)
    InspectorTimelineAgent* timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext());
    bool callTimelineAgentOnReadyStateChange = timelineAgent && hasEventListeners(eventNames().readystatechangeEvent);
    if (callTimelineAgentOnReadyStateChange)
        timelineAgent->willChangeXHRReadyState(m_url.string(), m_state);
#endif

    if (m_async || (m_state <= OPENED || m_state == DONE))
        m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().readystatechangeEvent), m_state == DONE ? FlushProgressEvent : DoNotFlushProgressEvent);

#if ENABLE(INSPECTOR)
    if (callTimelineAgentOnReadyStateChange && (timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext())))
        timelineAgent->didChangeXHRReadyState();
#endif

    if (m_state == DONE && !m_error) {
#if ENABLE(INSPECTOR)
        timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext());
        bool callTimelineAgentOnLoad = timelineAgent && hasEventListeners(eventNames().loadEvent);
        if (callTimelineAgentOnLoad)
            timelineAgent->willLoadXHR(m_url.string());
#endif

        m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadEvent));

#if ENABLE(INSPECTOR)
        if (callTimelineAgentOnLoad && (timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext())))
            timelineAgent->didLoadXHR();
#endif
    }
}