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

Unified Diff: Source/core/html/parser/HTMLResourcePreloader.cpp

Issue 1170503003: Remove resource type-specific fetching logic from ResourceFetcher (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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/html/parser/HTMLResourcePreloader.cpp
diff --git a/Source/core/html/parser/HTMLResourcePreloader.cpp b/Source/core/html/parser/HTMLResourcePreloader.cpp
index cc3dbcd75366c34545a48a7ff6df8331e135db44..b5d36a5a3ad025341eb3c590f4ec654816afca55 100644
--- a/Source/core/html/parser/HTMLResourcePreloader.cpp
+++ b/Source/core/html/parser/HTMLResourcePreloader.cpp
@@ -27,8 +27,11 @@
#include "core/html/parser/HTMLResourcePreloader.h"
#include "core/dom/Document.h"
+#include "core/fetch/CSSStyleSheetResource.h"
#include "core/fetch/FetchInitiatorInfo.h"
+#include "core/fetch/ImageResource.h"
#include "core/fetch/ResourceFetcher.h"
+#include "core/fetch/ScriptResource.h"
#include "platform/network/NetworkHints.h"
#include "public/platform/Platform.h"
@@ -72,9 +75,28 @@ void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload)
preconnectHost(preload.get());
return;
}
+
Yoav Weiss 2015/06/08 06:44:18 Can't say that I like adding all that resource typ
Nate Chapin 2015/06/08 19:01:22 For this patch by itself, yes. However, for the pr
+ // Ensure main resources aren't preloaded, since the cache can't actually reuse the preload.
+ if (preload->resourceType() == Resource::MainResource)
Yoav Weiss 2015/06/08 06:44:17 Is there a scenario where we preload a main resour
Nate Chapin 2015/06/08 19:01:22 I think there was hope a year or two ago that we w
+ return;
+ ASSERT(preload->resourceType() == Resource::Script || preload->resourceType() == Resource::CSSStyleSheet || preload->resourceType() == Resource::Image);
+
FetchRequest request = preload->resourceRequest(m_document);
+ if (preload->resourceType() == Resource::Script || preload->resourceType() == Resource::CSSStyleSheet)
+ request.setCharset(preload->charset().isEmpty() ? m_document->charset().string() : preload->charset());
+ request.setForPreload(true);
Platform::current()->histogramCustomCounts("WebCore.PreloadDelayMs", static_cast<int>(1000 * (monotonicallyIncreasingTime() - preload->discoveryTime())), 0, 2000, 20);
- m_document->fetcher()->preload(preload->resourceType(), request, preload->charset());
+
+ ResourcePtr<Resource> resource;
+ if (preload->resourceType() == Resource::Image)
+ resource = ImageResource::fetch(request, m_document->fetcher());
+ else if (preload->resourceType() == Resource::Script)
+ resource = ScriptResource::fetch(request, m_document->fetcher());
+ else
+ resource = CSSStyleSheetResource::fetch(request, m_document->fetcher());
+
+ if (resource)
+ m_document->fetcher()->preloadStarted(resource.get());
}
} // namespace blink
« no previous file with comments | « Source/core/html/imports/HTMLImportsController.cpp ('k') | Source/core/inspector/InspectorResourceContentLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698