void InspectorResourceAgent::didReceiveResponse(unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response) { RefPtr<InspectorObject> resourceResponse = buildObjectForResourceResponse(response); String type = "Other"; long cachedResourceSize = 0; if (loader) { CachedResource* cachedResource = InspectorResourceAgent::cachedResource(loader->frame(), response.url()); if (cachedResource) { type = cachedResourceTypeString(*cachedResource); cachedResourceSize = cachedResource->encodedSize(); // Use mime type from cached resource in case the one in response is empty. if (response.mimeType().isEmpty()) resourceResponse->setString("mimeType", cachedResource->response().mimeType()); } if (equalIgnoringFragmentIdentifier(response.url(), loader->frameLoader()->iconURL())) type = "Image"; else if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && type == "Other") type = "Document"; } m_frontend->didReceiveResponse(identifier, currentTime(), type, resourceResponse); // If we revalidated the resource and got Not modified, send content length following didReceiveResponse // as there will be no calls to didReceiveContentLength from the network stack. if (cachedResourceSize && response.httpStatusCode() == 304) didReceiveContentLength(identifier, cachedResourceSize); }
PassRefPtr<InspectorObject> InspectorPageAgent::buildObjectForFrameTree(Frame* frame) { RefPtr<InspectorObject> result = InspectorObject::create(); RefPtr<InspectorObject> frameObject = buildObjectForFrame(frame); result->setObject("frame", frameObject); RefPtr<InspectorArray> subresources = InspectorArray::create(); result->setArray("resources", subresources); Vector<CachedResource*> allResources = cachedResourcesForFrame(frame); for (Vector<CachedResource*>::const_iterator it = allResources.begin(); it != allResources.end(); ++it) { CachedResource* cachedResource = *it; RefPtr<InspectorObject> resourceObject = InspectorObject::create(); resourceObject->setString("url", cachedResource->url()); resourceObject->setString("type", cachedResourceTypeString(*cachedResource)); resourceObject->setString("mimeType", cachedResource->response().mimeType()); subresources->pushValue(resourceObject); } RefPtr<InspectorArray> childrenArray; for (Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) { if (!childrenArray) { childrenArray = InspectorArray::create(); result->setArray("childFrames", childrenArray); } childrenArray->pushObject(buildObjectForFrameTree(child)); } return result; }
static PassRefPtr<InspectorObject> buildObjectForFrameTree(Frame* frame) { RefPtr<InspectorObject> result = InspectorObject::create(); RefPtr<InspectorObject> frameObject = buildObjectForFrame(frame); result->setObject("frame", frameObject); RefPtr<InspectorArray> subresources = InspectorArray::create(); result->setArray("resources", subresources); const CachedResourceLoader::DocumentResourceMap& allResources = frame->document()->cachedResourceLoader()->allCachedResources(); CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources.end(); for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it) { CachedResource* cachedResource = it->second.get(); RefPtr<InspectorObject> resourceObject = InspectorObject::create(); resourceObject->setString("url", cachedResource->url()); resourceObject->setString("type", cachedResourceTypeString(*cachedResource)); subresources->pushValue(resourceObject); } RefPtr<InspectorArray> childrenArray; for (Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) { if (!childrenArray) { childrenArray = InspectorArray::create(); result->setArray("childFrames", childrenArray); } childrenArray->pushObject(buildObjectForFrameTree(child)); } return result; }
static PassRefPtr<InspectorObject> buildObjectForCachedResource(DocumentLoader* loader, const CachedResource& cachedResource) { RefPtr<InspectorObject> resourceObject = InspectorObject::create(); resourceObject->setString("url", cachedResource.url()); resourceObject->setString("type", cachedResourceTypeString(cachedResource)); resourceObject->setNumber("encodedSize", cachedResource.encodedSize()); resourceObject->setObject("response", buildObjectForResourceResponse(cachedResource.response())); resourceObject->setObject("loader", buildObjectForDocumentLoader(loader)); return resourceObject; }
static PassRefPtr<InspectorObject> buildObjectForCachedResource(const CachedResource& cachedResource) { RefPtr<InspectorObject> resourceObject = InspectorObject::create(); resourceObject->setString("url", cachedResource.url()); resourceObject->setString("type", cachedResourceTypeString(cachedResource)); resourceObject->setNumber("bodySize", cachedResource.encodedSize()); RefPtr<InspectorObject> resourceResponse = buildObjectForResourceResponse(cachedResource.response()); if (resourceResponse) resourceObject->setObject("response", resourceResponse); return resourceObject; }
void InspectorResourceAgent::didReceiveResponse(unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response) { RefPtr<InspectorObject> resourceResponse = buildObjectForResourceResponse(response); String type = "Other"; if (loader) { if (equalIgnoringFragmentIdentifier(response.url(), loader->frameLoader()->iconURL())) type = "Image"; else { CachedResource* cachedResource = InspectorResourceAgent::cachedResource(loader->frame(), response.url()); if (cachedResource) type = cachedResourceTypeString(*cachedResource); if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && type == "Other") type = "Document"; // Use mime type from cached resource in case the one in response is empty. if (response.mimeType().isEmpty() && cachedResource) resourceResponse->setString("mimeType", cachedResource->response().mimeType()); } } m_frontend->didReceiveResponse(identifier, currentTime(), type, resourceResponse); }