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 ed5d3592f20c47ae3ecd43aa377039fe2f1c5f45..c3a43482156044b1a4ed3e0aac801089c6d843b0 100644 |
--- a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp |
+++ b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp |
@@ -129,6 +129,9 @@ HTMLDocumentParser::HTMLDocumentParser(Document& document, ParserContentPolicy c |
, m_triedLoadingLinkHeaders(false) |
{ |
ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); |
+ // Threading is not allowed in prefetch mode. |
+ DCHECK(!document.isPrefetchOnly() || !shouldUseThreading()); |
+ |
ThreadState::current()->registerPreFinalizer(this); |
} |
@@ -794,6 +797,18 @@ void HTMLDocumentParser::append(const String& inputSource) |
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "HTMLDocumentParser::append", "size", inputSource.length()); |
const SegmentedString source(inputSource); |
+ if (document()->isPrefetchOnly()) { |
+ if (!m_preloadScanner) |
+ m_preloadScanner = createPreloadScanner(); |
+ |
+ m_preloadScanner->appendToEnd(source); |
+ // TODO(droger): Set the LOAD_PREFETCH flags on the requests. |
+ m_preloadScanner->scanAndPreload(m_preloader.get(), document()->validBaseElementURL(), nullptr); |
+ |
+ // Return after the preload scanner, do not actually parse the document. |
+ return; |
+ } |
+ |
if (m_preloadScanner) { |
if (m_input.current().isEmpty() && !isWaitingForScripts()) { |
// We have parsed until the end of the current input and so are now moving ahead of the preload scanner. |