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

Unified Diff: third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp

Issue 2165653004: Don't wait for AppCache for link rel preloads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't wait for appcache for link rel preloads Created 4 years, 5 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: third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
index 22a7b2c3460f4f538969c9386f73956e55e41959..4958ff44bf5ec9a106c9da7283184fc267b12d13 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
@@ -298,17 +298,25 @@ void HTMLDocumentParser::notifyPendingParsedChunks()
// ApplicationCache needs to be initialized before issuing preloads.
// We suspend preload until HTMLHTMLElement is inserted and
- // ApplicationCache is initialized.
+ // ApplicationCache is initialized. Note: link rel preloads don't follow
+ // this policy per the spec. These directives should initiate a fetch as
+ // fast as possible.
if (!document()->documentElement()) {
+ PreloadRequestStream linkRelPreloads;
for (auto& chunk : pendingChunks) {
- for (auto& request : chunk->preloads)
- m_queuedPreloads.append(std::move(request));
+ for (auto& request : chunk->preloads) {
Yoav Weiss 2016/07/22 08:43:28 I don't understand why this waiting is necessary f
Charlie Harrison 2016/07/22 14:03:22 My understanding is that the preload scanner just
+ if (request->isLinkRelPreload())
+ linkRelPreloads.append(std::move(request));
+ else
+ m_queuedPreloads.append(std::move(request));
+ }
for (auto& index : chunk->likelyDocumentWriteScriptIndices) {
const CompactHTMLToken& token = chunk->tokens->at(index);
ASSERT(token.type() == HTMLToken::TokenType::Character);
m_queuedDocumentWriteScripts.append(token.data());
}
}
+ m_preloader->takeAndPreload(linkRelPreloads);
} else {
// We can safely assume that there are no queued preloads request after
// the document element is available, as we empty the queue immediately
@@ -469,13 +477,11 @@ size_t HTMLDocumentParser::processParsedChunkFromBackgroundParser(std::unique_pt
break;
if (!m_triedLoadingLinkHeaders && document()->loader()) {
- String linkHeader = document()->loader()->response().httpHeaderField(HTTPNames::Link);
- if (!linkHeader.isEmpty()) {
- ASSERT(chunk);
- LinkLoader::loadLinksFromHeader(linkHeader, document()->loader()->response().url(),
- document(), NetworkHintsInterfaceImpl(), LinkLoader::OnlyLoadResources, &(chunk->viewport));
- m_triedLoadingLinkHeaders = true;
- }
+ DCHECK(chunk);
+ // Note that on commit, the loader dispatched preloads for all the
+ // non-media links.
+ document()->loader()->dispatchLinkHeaderPreloads(&chunk->viewport, LinkLoader::OnlyLoadMedia);
+ m_triedLoadingLinkHeaders = true;
}
if (isWaitingForScripts()) {

Powered by Google App Engine
This is Rietveld 408576698