Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(989)

Unified Diff: Source/core/inspector/InspectorPageAgent.cpp

Issue 267393003: DevTools: Load document (html) content from disk cache in page agent enabling. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/inspector/InspectorPageAgent.cpp
diff --git a/Source/core/inspector/InspectorPageAgent.cpp b/Source/core/inspector/InspectorPageAgent.cpp
index 811967c1b869bb282aaaa26127e2bd689135874b..ffc57827145833bd04e68114547a75f18a4de2fa 100644
--- a/Source/core/inspector/InspectorPageAgent.cpp
+++ b/Source/core/inspector/InspectorPageAgent.cpp
@@ -253,13 +253,26 @@ void InspectorPageAgent::resourceContent(ErrorString* errorString, LocalFrame* f
DocumentLoader* loader = assertDocumentLoader(errorString, frame);
if (!loader)
return;
+
if (!cachedResourceContent(cachedResource(frame, url), result, base64Encoded))
*errorString = "No resource with given URL found";
}
Resource* InspectorPageAgent::cachedResource(LocalFrame* frame, const KURL& url)
{
- Resource* cachedResource = frame->document()->fetcher()->cachedResource(url);
+ Document* document = frame->document();
+ if (!document)
+ return 0;
+ Resource* cachedResource = document->fetcher()->cachedResource(url);
+ if (!cachedResource) {
+ Vector<Document*> allImports = InspectorPageAgent::importsForFrame(frame);
+ for (Vector<Document*>::const_iterator it = allImports.begin(); it != allImports.end(); ++it) {
+ Document* import = *it;
+ cachedResource = import->fetcher()->cachedResource(url);
+ if (cachedResource)
+ break;
+ }
+ }
if (!cachedResource)
cachedResource = memoryCache()->resourceForURL(url);
return cachedResource;
@@ -544,7 +557,8 @@ static void cachedResourcesForDocument(Document* document, Vector<Resource*>& re
}
}
-static Vector<Document*> importsForFrame(LocalFrame* frame)
+// static
+Vector<Document*> InspectorPageAgent::importsForFrame(LocalFrame* frame)
{
Vector<Document*> result;
Document* rootDocument = frame->document();
@@ -563,7 +577,7 @@ static Vector<Resource*> cachedResourcesForFrame(LocalFrame* frame)
{
Vector<Resource*> result;
Document* rootDocument = frame->document();
- Vector<Document*> loaders = importsForFrame(frame);
+ Vector<Document*> loaders = InspectorPageAgent::importsForFrame(frame);
cachedResourcesForDocument(rootDocument, result);
for (size_t i = 0; i < loaders.size(); ++i)
@@ -1109,7 +1123,7 @@ PassRefPtr<TypeBuilder::Page::FrameResourceTree> InspectorPageAgent::buildObject
subresources->addItem(resourceObject);
}
- Vector<Document*> allImports = importsForFrame(frame);
+ Vector<Document*> allImports = InspectorPageAgent::importsForFrame(frame);
for (Vector<Document*>::const_iterator it = allImports.begin(); it != allImports.end(); ++it) {
Document* import = *it;
RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject = TypeBuilder::Page::FrameResourceTree::Resources::create()

Powered by Google App Engine
This is Rietveld 408576698