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

Unified Diff: Source/core/html/HTMLLinkElement.cpp

Issue 166633002: Prefetch @import files from CSS files. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Renamed according to comments. Created 6 years, 7 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/HTMLLinkElement.cpp
diff --git a/Source/core/html/HTMLLinkElement.cpp b/Source/core/html/HTMLLinkElement.cpp
index 3ee6600b7302235de6b0ff3d4cefcf801407c2f1..dfdd1bd416601b9bb0dbed3839d415652f090659 100644
--- a/Source/core/html/HTMLLinkElement.cpp
+++ b/Source/core/html/HTMLLinkElement.cpp
@@ -436,6 +436,8 @@ PassOwnPtrWillBeRawPtr<LinkStyle> LinkStyle::create(HTMLLinkElement* owner)
LinkStyle::LinkStyle(HTMLLinkElement* owner)
: LinkResource(owner)
+ , m_preloadScanner(adoptPtr(new CSSPreloadScanner))
+ , m_preloadInput(adoptPtr(new SegmentedString))
, m_disabledState(Unset)
, m_pendingSheetType(None)
, m_loading(false)
@@ -502,6 +504,23 @@ void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const
const_cast<CSSStyleSheetResource*>(cachedStyleSheet)->saveParsedStyleSheet(styleSheet);
}
+void LinkStyle::dataReceived(const CSSStyleSheetResource* cachedStyleSheet, const char* data, int length)
+{
+ if (!m_preloadScanner)
+ return;
+
+ PreloadRequestStream pendingPreloads;
+ m_preloadInput->append(SegmentedString(data));
abarth-chromium 2014/06/26 16:37:59 Why don't we need to use |length| on this line?
+ m_preloadScanner->scan(data, *m_preloadInput, pendingPreloads);
+ HTMLResourcePreloader m_preloader(&document());
+ m_preloader.takeAndPreload(pendingPreloads);
+
+ if (m_preloadScanner->isDoneParsingImports()) {
eseidel 2014/05/28 23:52:52 Could you explain the magic here a bit more? // N
+ m_preloadScanner.clear();
+ m_preloadInput.clear();
+ }
+}
+
bool LinkStyle::sheetLoaded()
{
if (!styleSheetIsLoading()) {

Powered by Google App Engine
This is Rietveld 408576698