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

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

Issue 230383003: Webfont CORS-enabled fetching with fallback (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase & reverse the enum values Created 6 years, 8 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
« no previous file with comments | « Source/core/css/RemoteFontFaceSource.h ('k') | Source/core/fetch/FontResource.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/RemoteFontFaceSource.cpp
diff --git a/Source/core/css/RemoteFontFaceSource.cpp b/Source/core/css/RemoteFontFaceSource.cpp
index 9b15954c7a9aa06f6e7b13d21cf7c3732c9a05b7..23fdfc5df02217cb6a491077f748d4a818271074 100644
--- a/Source/core/css/RemoteFontFaceSource.cpp
+++ b/Source/core/css/RemoteFontFaceSource.cpp
@@ -5,8 +5,11 @@
#include "config.h"
#include "core/css/RemoteFontFaceSource.h"
+#include "FetchInitiatorTypeNames.h"
#include "core/css/CSSCustomFontData.h"
#include "core/css/CSSFontFace.h"
+#include "core/css/CSSFontSelector.h"
+#include "core/fetch/ResourceFetcher.h"
#include "platform/fonts/FontCache.h"
#include "platform/fonts/FontDescription.h"
#include "platform/fonts/SimpleFontData.h"
@@ -82,6 +85,24 @@ void RemoteFontFaceSource::fontLoadWaitLimitExceeded(FontResource*)
m_histograms.recordFallbackTime(m_font.get());
}
+void RemoteFontFaceSource::corsFailed(FontResource*)
+{
+ pruneTable();
+
+ if (m_face) {
+ Document* document = m_face->fontSelector() ? m_face->fontSelector()->document() : 0;
+ if (document) {
+ FetchRequest request(ResourceRequest(m_font->url()), FetchInitiatorTypeNames::css);
+ m_font->removeClient(this);
+ m_font = document->fetcher()->fetchFont(request);
+ m_font->addClient(this);
+ m_face->fontSelector()->beginLoadingFontSoon(m_font.get());
+ } else {
+ m_face->fontLoaded(this);
+ }
+ }
+}
+
PassRefPtr<SimpleFontData> RemoteFontFaceSource::createFontData(const FontDescription& fontDescription)
{
if (!isLoaded())
@@ -156,6 +177,12 @@ void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour
: font->response().wasCached() ? Hit
: Miss;
blink::Platform::current()->histogramEnumeration("WebFont.CacheHit", histogramValue, CacheHitEnumMax);
+
+ if (!font->errorOccurred()) {
+ enum { CORSFail, CORSSuccess, CORSEnumMax };
+ int corsValue = font->options().corsEnabled == IsCORSEnabled ? CORSSuccess : CORSFail;
+ blink::Platform::current()->histogramEnumeration("WebFont.CORSSuccess", corsValue, CORSEnumMax);
+ }
}
}
« no previous file with comments | « Source/core/css/RemoteFontFaceSource.h ('k') | Source/core/fetch/FontResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698