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

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

Issue 2642733002: Prerender: Disable prefetch if there's an appcache. (Closed)
Patch Set: clarifying comment Created 3 years, 11 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/HTMLPreloadScanner.cpp
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
index e224331a875c29409d023e158995ded88b9199b2..0f24e9f5b01ae68be5e0b958d63b2464ce9c14a4 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
@@ -537,6 +537,7 @@ TokenPreloadScanner::TokenPreloadScanner(
m_inStyle(false),
m_inPicture(false),
m_inScript(false),
+ m_isAppCacheEnabled(false),
m_templateCount(0),
m_documentParameters(std::move(documentParameters)),
m_mediaValues(MediaValuesCached::create(mediaValuesCachedData)),
@@ -552,7 +553,8 @@ TokenPreloadScanner::~TokenPreloadScanner() {}
TokenPreloadScannerCheckpoint TokenPreloadScanner::createCheckpoint() {
TokenPreloadScannerCheckpoint checkpoint = m_checkpoints.size();
m_checkpoints.push_back(Checkpoint(m_predictedBaseElementURL, m_inStyle,
- m_inScript, m_templateCount));
+ m_inScript, m_isAppCacheEnabled,
+ m_templateCount));
return checkpoint;
}
@@ -563,6 +565,7 @@ void TokenPreloadScanner::rewindTo(
const Checkpoint& checkpoint = m_checkpoints[checkpointIndex];
m_predictedBaseElementURL = checkpoint.predictedBaseElementURL;
m_inStyle = checkpoint.inStyle;
+ m_isAppCacheEnabled = checkpoint.isAppCacheEnabled;
m_templateCount = checkpoint.templateCount;
m_didRewind = true;
@@ -715,6 +718,13 @@ void TokenPreloadScanner::scanCommon(const Token& token,
if (!m_documentParameters->doHtmlPreloadScanning)
return;
+ // If the document is prefetching, AppCache support has not yet been enabled,
+ // and fetches will go to the network even if there is an AppCache
+ // manifest. Therefore if a manifest is seen prefetching is stopped to avoid
+ // incorrect behavior.
+ if (m_documentParameters->isPrefetchOnly && m_isAppCacheEnabled)
michaeln 2017/03/27 23:27:44 Could this be done more directly and with less cod
+ return;
+
switch (token.type()) {
case HTMLToken::Character: {
if (m_inStyle) {
@@ -776,6 +786,10 @@ void TokenPreloadScanner::scanCommon(const Token& token,
updatePredictedBaseURL(token);
return;
}
+ if (match(tagImpl, htmlTag) && token.getAttributeItem(manifestAttr)) {
+ m_isAppCacheEnabled = true;
+ return;
+ }
if (match(tagImpl, metaTag)) {
const typename Token::Attribute* equivAttribute =
token.getAttributeItem(http_equivAttr);
@@ -896,6 +910,7 @@ CachedDocumentParameters::CachedDocumentParameters(Document* document) {
viewportMetaEnabled =
document->settings() && document->settings()->getViewportMetaEnabled();
referrerPolicy = document->getReferrerPolicy();
+ isPrefetchOnly = document->isPrefetchOnly();
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698