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

Unified Diff: third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp

Issue 2390583002: [WIP] WebFonts cache-aware timeout adaption (Closed)
Patch Set: check ERR_CACHE_MISS directly in ResourceError Created 4 years, 2 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/css/RemoteFontFaceSource.cpp
diff --git a/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp b/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp
index 45ce1f6e3951a4b4a73d4f48ebc429d701ad063e..768a16b38d2ec048068a422b2a4296c64ec960bb 100644
--- a/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp
+++ b/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp
@@ -56,7 +56,7 @@ RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font,
: m_font(font),
m_fontSelector(fontSelector),
m_display(display),
- m_period(display == FontDisplaySwap ? SwapPeriod : BlockPeriod),
+ m_period(BlockPeriod),
m_histograms(font->url().protocolIsData()
? FontLoadHistograms::FromDataURL
: font->isLoaded() ? FontLoadHistograms::FromMemoryCache
@@ -74,6 +74,10 @@ RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font,
"Slow network is detected. Fallback font will be used while loading: " +
m_font->url().elidedString()));
}
+
+ if (m_display == FontDisplaySwap &&
+ !m_font->resourceRequest().isCacheAwareLoadingActivated())
+ m_period = SwapPeriod;
}
RemoteFontFaceSource::~RemoteFontFaceSource() {}
@@ -161,6 +165,11 @@ void RemoteFontFaceSource::fontLoadLongLimitExceeded(FontResource*) {
m_histograms.longLimitExceeded(m_isInterventionTriggered);
}
+void RemoteFontFaceSource::willReloadAfterDiskCacheMiss(const FontResource*) {
+ if (m_display == FontDisplaySwap)
+ switchToSwapPeriod();
+}
+
void RemoteFontFaceSource::switchToSwapPeriod() {
ASSERT(m_period == BlockPeriod);
m_period = SwapPeriod;
@@ -237,7 +246,15 @@ PassRefPtr<SimpleFontData> RemoteFontFaceSource::createLoadingFallbackFontData(
void RemoteFontFaceSource::beginLoadIfNeeded() {
if (m_fontSelector->document() && m_font->stillNeedsLoad()) {
+ // TODO(shaochuan): Cache-aware loading may be deactivated in startLoad(),
+ // set |m_period| to correct value if deactivated. crbug.com/632580
+ bool wasCacheAwareLoadingActivated =
+ m_font->resourceRequest().isCacheAwareLoadingActivated();
m_fontSelector->document()->fetcher()->startLoad(m_font);
+ if (m_display == FontDisplaySwap && wasCacheAwareLoadingActivated &&
+ !m_font->resourceRequest().isCacheAwareLoadingActivated())
+ switchToSwapPeriod();
+
if (!m_font->isLoaded())
m_font->startLoadLimitTimers();
m_histograms.loadStarted();

Powered by Google App Engine
This is Rietveld 408576698