Modified: trunk/Source/WebCore/ChangeLog (149904 => 149905)
--- trunk/Source/WebCore/ChangeLog 2013-05-10 20:46:12 UTC (rev 149904)
+++ trunk/Source/WebCore/ChangeLog 2013-05-10 20:54:54 UTC (rev 149905)
@@ -1,3 +1,22 @@
+2013-05-10 Timothy Hatcher <[email protected]>
+
+ 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.
+
2013-05-10 Laszlo Gombos <[email protected]>
[CMake] Consolidate list of files to build for WebCore plugin support
Modified: trunk/Source/WebCore/inspector/Inspector.json (149904 => 149905)
--- trunk/Source/WebCore/inspector/Inspector.json 2013-05-10 20:46:12 UTC (rev 149904)
+++ trunk/Source/WebCore/inspector/Inspector.json 2013-05-10 20:54:54 UTC (rev 149905)
@@ -1093,7 +1093,8 @@
{ "name": "request", "$ref": "Request", "description": "Request data." },
{ "name": "timestamp", "$ref": "Timestamp", "description": "Timestamp." },
{ "name": "initiator", "$ref": "Initiator", "description": "Request initiator." },
- { "name": "redirectResponse", "optional": true, "$ref": "Response", "description": "Redirect response data." }
+ { "name": "redirectResponse", "optional": true, "$ref": "Response", "description": "Redirect response data." },
+ { "name": "type", "$ref": "Page.ResourceType", "optional": true, "description": "Resource type." }
]
},
{
Modified: trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp (149904 => 149905)
--- trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp 2013-05-10 20:46:12 UTC (rev 149904)
+++ trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp 2013-05-10 20:54:54 UTC (rev 149905)
@@ -198,9 +198,20 @@
String requestId = IdentifiersFactory::requestId(identifier);
m_resourcesData->resourceCreated(requestId, m_pageAgent->loaderId(loader));
- RefPtr<InspectorObject> headers = m_state->getObject(ResourceAgentState::extraRequestHeaders);
+ CachedResource* cachedResource = loader ? InspectorPageAgent::cachedResource(loader->frame(), request.url()) : 0;
+ InspectorPageAgent::ResourceType type = cachedResource ? InspectorPageAgent::cachedResourceType(*cachedResource) : m_resourcesData->resourceType(requestId);
+ if (type == InspectorPageAgent::OtherResource) {
+ if (m_loadingXHRSynchronously)
+ type = InspectorPageAgent::XHRResource;
+ else if (equalIgnoringFragmentIdentifier(request.url(), loader->frameLoader()->icon()->url()))
+ type = InspectorPageAgent::ImageResource;
+ else if (equalIgnoringFragmentIdentifier(request.url(), loader->url()) && !loader->isCommitted())
+ type = InspectorPageAgent::DocumentResource;
+ }
- if (headers) {
+ m_resourcesData->setResourceType(requestId, type);
+
+ if (RefPtr<InspectorObject> headers = m_state->getObject(ResourceAgentState::extraRequestHeaders)) {
InspectorObject::const_iterator end = headers->end();
for (InspectorObject::const_iterator it = headers->begin(); it != end; ++it) {
String value;
@@ -218,8 +229,10 @@
request.setHTTPHeaderField("Cache-Control", "no-cache");
}
+ TypeBuilder::Page::ResourceType::Enum resourceType = InspectorPageAgent::resourceTypeJson(type);
+
RefPtr<TypeBuilder::Network::Initiator> initiatorObject = buildInitiatorObject(loader->frame() ? loader->frame()->document() : 0);
- m_frontend->requestWillBeSent(requestId, m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), loader->url().string(), buildObjectForResourceRequest(request), currentTime(), initiatorObject, buildObjectForResourceResponse(redirectResponse, loader));
+ 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);
}
void InspectorResourceAgent::markResourceAsCached(unsigned long identifier)
@@ -247,19 +260,19 @@
m_resourcesData->addCachedResource(requestId, cachedResource);
}
- InspectorPageAgent::ResourceType type = cachedResource ? InspectorPageAgent::cachedResourceType(*cachedResource) : InspectorPageAgent::OtherResource;
- if (m_loadingXHRSynchronously || m_resourcesData->resourceType(requestId) == InspectorPageAgent::XHRResource)
- type = InspectorPageAgent::XHRResource;
- else if (m_resourcesData->resourceType(requestId) == InspectorPageAgent::ScriptResource)
- type = InspectorPageAgent::ScriptResource;
- else if (equalIgnoringFragmentIdentifier(response.url(), loader->frameLoader()->icon()->url()))
- type = InspectorPageAgent::ImageResource;
- else if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && !loader->isCommitted())
- type = InspectorPageAgent::DocumentResource;
+ InspectorPageAgent::ResourceType type = m_resourcesData->resourceType(requestId);
+ InspectorPageAgent::ResourceType newType = cachedResource ? InspectorPageAgent::cachedResourceType(*cachedResource) : type;
+ // FIXME: XHRResource is returned for CachedResource::RawResource, it should be OtherResource unless it truly is an XHR.
+ // RawResource is used for loading worker scripts, and those should stay as ScriptResource and not change to XHRResource.
+ if (type != newType && newType != InspectorPageAgent::XHRResource && newType != InspectorPageAgent::OtherResource)
+ type = newType;
+
m_resourcesData->responseReceived(requestId, m_pageAgent->frameId(loader->frame()), response);
m_resourcesData->setResourceType(requestId, type);
+
m_frontend->responseReceived(requestId, m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), currentTime(), InspectorPageAgent::resourceTypeJson(type), resourceResponse);
+
// If we revalidated the resource and got Not modified, send content length following didReceiveResponse
// as there will be no calls to didReceiveData from the network stack.
if (isNotModified && cachedResource && cachedResource->encodedSize())