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

Unified Diff: Source/core/fetch/CSSStyleSheetResource.cpp

Issue 166633002: Prefetch @import files from CSS files. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Simplified and with selftests. Created 6 years, 10 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/fetch/CSSStyleSheetResource.cpp
diff --git a/Source/core/fetch/CSSStyleSheetResource.cpp b/Source/core/fetch/CSSStyleSheetResource.cpp
index 1370b3bcb575081c6f1010f5c8ca43daac71b92b..62ca20f392603f71c859026240fc9a12bf009a50 100644
--- a/Source/core/fetch/CSSStyleSheetResource.cpp
+++ b/Source/core/fetch/CSSStyleSheetResource.cpp
@@ -33,14 +33,18 @@
#include "core/html/parser/TextResourceDecoder.h"
#include "platform/SharedBuffer.h"
#include "platform/network/HTTPParsers.h"
+#include "platform/text/SegmentedString.h"
#include "wtf/CurrentTime.h"
#include "wtf/Vector.h"
namespace WebCore {
-CSSStyleSheetResource::CSSStyleSheetResource(const ResourceRequest& resourceRequest, const String& charset)
+CSSStyleSheetResource::CSSStyleSheetResource(const ResourceRequest& resourceRequest, const String& charset, Document* document)
: StyleSheetResource(resourceRequest, CSSStyleSheet)
, m_decoder(TextResourceDecoder::create("text/css", charset))
+ , m_preloadScanner(adoptPtr(new CSSPreloadScanner))
+ , m_preloader(adoptPtr(new HTMLResourcePreloader(document)))
abarth-chromium 2014/02/26 19:13:36 Why do we create these objects in the case where w
+ , m_prescan(document ? true : false)
abarth-chromium 2014/02/26 19:13:36 There's no reason to write foo ? true : false. If
{
DEFINE_STATIC_LOCAL(const AtomicString, acceptCSS, ("text/css,*/*;q=0.1", AtomicString::ConstructFromLiteral));
@@ -124,6 +128,17 @@ void CSSStyleSheetResource::destroyDecodedDataIfPossible()
setDecodedSize(0);
}
+void CSSStyleSheetResource::appendData(const char* data, int length)
+{
+ Resource::appendData(data, length);
+ if (m_prescan) {
+ m_prescan = false;
+ PreloadRequestStream pendingPreloads;
+ m_preloadScanner->scan(data, SegmentedString(data), pendingPreloads);
+ m_preloader->takeAndPreload(pendingPreloads);
abarth-chromium 2014/02/26 19:13:36 Whey don't we destroy these objects when we're don
+ }
+}
+
bool CSSStyleSheetResource::canUseSheet(bool enforceMIMEType, bool* hasValidMIMEType) const
{
if (errorOccurred())

Powered by Google App Engine
This is Rietveld 408576698