Chromium Code Reviews| 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 9c3f564d0932a2bd7700a03c479c1a80b3f92954..632ad446970f8f49b3d74c888017b36c6d3e5c8d 100644 |
| --- a/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp |
| +++ b/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp |
| @@ -60,7 +60,8 @@ RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, |
| m_histograms(font->url().protocolIsData() |
| ? FontLoadHistograms::FromDataURL |
| : font->isLoaded() ? FontLoadHistograms::FromMemoryCache |
| - : FontLoadHistograms::FromUnknown), |
| + : FontLoadHistograms::FromUnknown, |
| + m_display), |
| m_isInterventionTriggered(false) { |
| ThreadState::current()->registerPreFinalizer(this); |
| m_font->addClient(this); |
| @@ -112,7 +113,9 @@ void RemoteFontFaceSource::notifyFinished(Resource*) { |
| ? FontLoadHistograms::FromDiskCache |
| : FontLoadHistograms::FromNetwork); |
| m_histograms.recordRemoteFont(m_font.get()); |
| - m_histograms.fontLoaded(m_isInterventionTriggered); |
| + m_histograms.fontLoaded(m_font->isCORSFailed(), |
| + m_font->getStatus() == Resource::LoadError, |
| + m_isInterventionTriggered); |
| m_font->ensureCustomFontData(); |
| // FIXME: Provide more useful message such as OTS rejection reason. |
| @@ -151,7 +154,9 @@ void RemoteFontFaceSource::fontLoadLongLimitExceeded(FontResource*) { |
| else if (m_display == FontDisplayFallback) |
| switchToFailurePeriod(); |
| - m_histograms.longLimitExceeded(m_isInterventionTriggered); |
| + m_histograms.longLimitExceeded(m_font->isCORSFailed(), |
| + m_font->getStatus() == Resource::LoadError, |
| + m_isInterventionTriggered); |
| } |
| void RemoteFontFaceSource::switchToSwapPeriod() { |
| @@ -259,16 +264,21 @@ void RemoteFontFaceSource::FontLoadHistograms::fallbackFontPainted( |
| } |
| void RemoteFontFaceSource::FontLoadHistograms::fontLoaded( |
| + bool isCorsFailed, |
|
Takashi Toyoshima
2016/10/20 10:12:44
Probably we can just have one argument to indicate
tbansal1
2016/10/21 06:58:13
I am still using two different errors. It seems mo
|
| + bool loadError, |
| bool isInterventionTriggered) { |
| - if (!m_isLongLimitExceeded) |
| - recordInterventionResult(isInterventionTriggered); |
| + if (!m_isLongLimitExceeded) { |
|
Takashi Toyoshima
2016/10/20 10:12:44
Can we check error here?
if (!m_isLongLimitExceed
tbansal1
2016/10/21 06:58:13
Done.
|
| + recordInterventionResult(isCorsFailed, loadError, isInterventionTriggered); |
| + } |
| } |
| void RemoteFontFaceSource::FontLoadHistograms::longLimitExceeded( |
| + bool isCorsFailed, |
|
Takashi Toyoshima
2016/10/20 10:12:44
These two arguments look curious to me, because th
tbansal1
2016/10/21 06:58:13
Done.
|
| + bool loadError, |
| bool isInterventionTriggered) { |
| m_isLongLimitExceeded = true; |
| maySetDataSource(FromNetwork); |
| - recordInterventionResult(isInterventionTriggered); |
| + recordInterventionResult(isCorsFailed, loadError, isInterventionTriggered); |
| } |
| void RemoteFontFaceSource::FontLoadHistograms::recordFallbackTime( |
| @@ -387,6 +397,8 @@ void RemoteFontFaceSource::FontLoadHistograms::recordLoadTimeHistogram( |
| } |
| void RemoteFontFaceSource::FontLoadHistograms::recordInterventionResult( |
| + bool isCorsFailed, |
| + bool loadError, |
| bool isTriggered) { |
| CHECK_NE(FromUnknown, m_dataSource); |
| @@ -403,8 +415,14 @@ void RemoteFontFaceSource::FontLoadHistograms::recordInterventionResult( |
| DEFINE_STATIC_LOCAL(EnumerationHistogram, missedCacheInterventionHistogram, |
| ("WebFont.InterventionResult.MissedCache", boundary)); |
| interventionHistogram.count(interventionResult); |
| - if (m_dataSource == FromNetwork) |
| + |
|
Takashi Toyoshima
2016/10/20 10:12:44
Do you have any reason why you omit only missedCac
tbansal1
2016/10/21 06:58:13
Done.
|
| + // Do not record the result if the font failed to load since the failure |
| + // could have happened either due to slow connection or unavailability of the |
| + // server. |
| + if (m_dataSource == FromNetwork && !isCorsFailed && |
| + m_fontDisplay == FontDisplayAuto && !loadError) { |
| missedCacheInterventionHistogram.count(interventionResult); |
| + } |
| } |
| RemoteFontFaceSource::FontLoadHistograms::CacheHitMetrics |