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

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

Issue 1819593002: Preload scan external css for @import (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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/CSSPreloadScanner.cpp
diff --git a/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp b/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp
index 15a5aaf1d36714052c7ccaf8db2548737a75454c..78d76e8b88219bc5fe685357144cbcb61f38ac99 100644
--- a/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp
+++ b/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp
@@ -27,8 +27,10 @@
#include "core/html/parser/CSSPreloadScanner.h"
+#include "core/fetch/CSSStyleSheetResource.h"
#include "core/fetch/FetchInitiatorTypeNames.h"
#include "core/html/parser/HTMLParserIdioms.h"
+#include "core/html/parser/HTMLResourcePreloader.h"
#include "platform/text/SegmentedString.h"
namespace blink {
@@ -233,4 +235,25 @@ void CSSPreloadScanner::emitRule(const SegmentedString& source)
m_ruleValue.clear();
}
+CSSPreloaderResourceClient::CSSPreloaderResourceClient(HTMLResourcePreloader* preloader)
+ : m_preloader(preloader)
+ , m_streamPosition(0)
+{
+}
+
+void CSSPreloaderResourceClient::didAppendData(const CSSStyleSheetResource* resource)
+{
+ preloadChunk(resource->streamDecodedText(&m_streamPosition), resource);
+}
+
+void CSSPreloaderResourceClient::preloadChunk(const String& chunk, const CSSStyleSheetResource* resource)
+{
+ if (chunk.isNull())
+ return;
+ PreloadRequestStream preloads;
+ // TODO(csharrison): Should SegmentedString be populated?
+ m_cssPreloadScanner.scan(chunk, SegmentedString(), preloads, resource->response().url());
+ m_preloader->takeAndPreload(preloads);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698