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

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: Prefetch @import files from CSS files. Scans until state finished in preload scanner. 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..c969af88ebf487e64fae3156fd78d13b739d075a 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_input(adoptPtr(new SegmentedString))
eseidel 2014/05/20 07:10:37 You might want to name this m_preloaderInput? Sin
, m_disabledState(Unset)
, m_pendingSheetType(None)
, m_loading(false)
@@ -502,6 +504,21 @@ 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.get()) {
eseidel 2014/05/20 06:27:04 Normally these are written as early returns. if (
+ PreloadRequestStream pendingPreloads;
+ m_input->append(SegmentedString(data));
+ m_preloadScanner->scan(data, *m_input, pendingPreloads);
+ HTMLResourcePreloader m_preloader(&document());
+ m_preloader.takeAndPreload(pendingPreloads);
+ if (m_preloadScanner->isDoneParsing()) {
eseidel 2014/05/20 06:27:04 I'm not familiar with this method. How does the p
+ m_preloadScanner.clear();
+ m_input.clear();
+ }
+ }
+}
+
bool LinkStyle::sheetLoaded()
{
if (!styleSheetIsLoading()) {

Powered by Google App Engine
This is Rietveld 408576698