Changeset 149905 in webkit


Ignore:
Timestamp:
May 10, 2013 1:54:54 PM (11 years ago)
Author:
timothy@apple.com
Message:

Web Inspector: determine the resource type in InspectorResourceAgent::willSendRequest.

This allows the Network timeline and Resources sidebar to filter Resources earlier,
before the server sends a response. Useful for long polling (comet) XHRs.

https://webkit.org/b/74935
rdar://problem/13726105

Reviewed by Joseph Pecoraro.

  • inspector/Inspector.json:

(Network.requestWillBeSent): Added.

  • inspector/InspectorResourceAgent.cpp:

(WebCore::InspectorResourceAgent::willSendRequest): Send the type if it isn't Other along in requestWillBeSent.
(WebCore::InspectorResourceAgent::didReceiveResponse): Don't determine the type here anymore. Clear the CachedResource
if isNotModified like the old code path did by not setting cachedResource if !isNotModified.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r149899 r149905  
     12013-05-10  Timothy Hatcher  <timothy@apple.com>
     2
     3        Web Inspector: determine the resource type in InspectorResourceAgent::willSendRequest.
     4
     5        This allows the Network timeline and Resources sidebar to filter Resources earlier,
     6        before the server sends a response. Useful for long polling (comet) XHRs.
     7
     8        https://webkit.org/b/74935
     9        rdar://problem/13726105
     10
     11        Reviewed by Joseph Pecoraro.
     12
     13        * inspector/Inspector.json:
     14        (Network.requestWillBeSent): Added.
     15        * inspector/InspectorResourceAgent.cpp:
     16        (WebCore::InspectorResourceAgent::willSendRequest): Send the type if it isn't Other along in requestWillBeSent.
     17        (WebCore::InspectorResourceAgent::didReceiveResponse): Don't determine the type here anymore. Clear the CachedResource
     18        if isNotModified like the old code path did by not setting cachedResource if !isNotModified.
     19
    1202013-05-10  Laszlo Gombos  <l.gombos@samsung.com>
    221
  • trunk/Source/WebCore/inspector/Inspector.json

    r149202 r149905  
    10941094                    { "name": "timestamp", "$ref": "Timestamp", "description": "Timestamp." },
    10951095                    { "name": "initiator", "$ref": "Initiator", "description": "Request initiator." },
    1096                     { "name": "redirectResponse", "optional": true, "$ref": "Response", "description": "Redirect response data." }
     1096                    { "name": "redirectResponse", "optional": true, "$ref": "Response", "description": "Redirect response data." },
     1097                    { "name": "type", "$ref": "Page.ResourceType", "optional": true, "description": "Resource type." }
    10971098                ]
    10981099            },
  • trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp

    r148921 r149905  
    199199    m_resourcesData->resourceCreated(requestId, m_pageAgent->loaderId(loader));
    200200
    201     RefPtr<InspectorObject> headers = m_state->getObject(ResourceAgentState::extraRequestHeaders);
    202 
    203     if (headers) {
     201    CachedResource* cachedResource = loader ? InspectorPageAgent::cachedResource(loader->frame(), request.url()) : 0;
     202    InspectorPageAgent::ResourceType type = cachedResource ? InspectorPageAgent::cachedResourceType(*cachedResource) : m_resourcesData->resourceType(requestId);
     203    if (type == InspectorPageAgent::OtherResource) {
     204        if (m_loadingXHRSynchronously)
     205            type = InspectorPageAgent::XHRResource;
     206        else if (equalIgnoringFragmentIdentifier(request.url(), loader->frameLoader()->icon()->url()))
     207            type = InspectorPageAgent::ImageResource;
     208        else if (equalIgnoringFragmentIdentifier(request.url(), loader->url()) && !loader->isCommitted())
     209            type = InspectorPageAgent::DocumentResource;
     210    }
     211
     212    m_resourcesData->setResourceType(requestId, type);
     213
     214    if (RefPtr<InspectorObject> headers = m_state->getObject(ResourceAgentState::extraRequestHeaders)) {
    204215        InspectorObject::const_iterator end = headers->end();
    205216        for (InspectorObject::const_iterator it = headers->begin(); it != end; ++it) {
     
    219230    }
    220231
     232    TypeBuilder::Page::ResourceType::Enum resourceType = InspectorPageAgent::resourceTypeJson(type);
     233
    221234    RefPtr<TypeBuilder::Network::Initiator> initiatorObject = buildInitiatorObject(loader->frame() ? loader->frame()->document() : 0);
    222     m_frontend->requestWillBeSent(requestId, m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), loader->url().string(), buildObjectForResourceRequest(request), currentTime(), initiatorObject, buildObjectForResourceResponse(redirectResponse, loader));
     235    m_frontend->requestWillBeSent(requestId, m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), loader->url().string(), buildObjectForResourceRequest(request), currentTime(), initiatorObject, buildObjectForResourceResponse(redirectResponse, loader), type != InspectorPageAgent::OtherResource ? &resourceType : 0);
    223236}
    224237
     
    248261    }
    249262
    250     InspectorPageAgent::ResourceType type = cachedResource ? InspectorPageAgent::cachedResourceType(*cachedResource) : InspectorPageAgent::OtherResource;
    251     if (m_loadingXHRSynchronously || m_resourcesData->resourceType(requestId) == InspectorPageAgent::XHRResource)
    252         type = InspectorPageAgent::XHRResource;
    253     else if (m_resourcesData->resourceType(requestId) == InspectorPageAgent::ScriptResource)
    254         type = InspectorPageAgent::ScriptResource;
    255     else if (equalIgnoringFragmentIdentifier(response.url(), loader->frameLoader()->icon()->url()))
    256         type = InspectorPageAgent::ImageResource;
    257     else if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && !loader->isCommitted())
    258         type = InspectorPageAgent::DocumentResource;
     263    InspectorPageAgent::ResourceType type = m_resourcesData->resourceType(requestId);
     264    InspectorPageAgent::ResourceType newType = cachedResource ? InspectorPageAgent::cachedResourceType(*cachedResource) : type;
     265
     266    // FIXME: XHRResource is returned for CachedResource::RawResource, it should be OtherResource unless it truly is an XHR.
     267    // RawResource is used for loading worker scripts, and those should stay as ScriptResource and not change to XHRResource.
     268    if (type != newType && newType != InspectorPageAgent::XHRResource && newType != InspectorPageAgent::OtherResource)
     269        type = newType;
    259270
    260271    m_resourcesData->responseReceived(requestId, m_pageAgent->frameId(loader->frame()), response);
    261272    m_resourcesData->setResourceType(requestId, type);
     273
    262274    m_frontend->responseReceived(requestId, m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), currentTime(), InspectorPageAgent::resourceTypeJson(type), resourceResponse);
     275
    263276    // If we revalidated the resource and got Not modified, send content length following didReceiveResponse
    264277    // as there will be no calls to didReceiveData from the network stack.
Note: See TracChangeset for help on using the changeset viewer.