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

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

Issue 2289303004: WebFonts: measure network loading time (Closed)
Patch Set: use histogram_suffixes Created 4 years, 4 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 bd49325ebda38e603bd5f7ffd78f72c79f1429b2..34b0479e81ac130d75cd7dc72a327bd5c1c10f59 100644
--- a/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp
+++ b/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp
@@ -263,17 +263,17 @@ void RemoteFontFaceSource::FontLoadHistograms::recordFallbackTime(const FontReso
void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResource* font, bool isLoadedFromMemoryCache)
{
if (m_loadStartTime > 0 && font && !font->isLoading()) {
- int duration = static_cast<int>(currentTimeMS() - m_loadStartTime);
- recordLoadTimeHistogram(font, duration);
- m_loadStartTime = -1;
-
enum { Miss, DiskHit, DataUrl, MemoryHit, CacheHitEnumMax };
- int histogramValue = font->url().protocolIsData() ? DataUrl
+ int cacheHitValue = font->url().protocolIsData() ? DataUrl
: isLoadedFromMemoryCache ? MemoryHit
: font->response().wasCached() ? DiskHit
: Miss;
DEFINE_STATIC_LOCAL(EnumerationHistogram, cacheHitHistogram, ("WebFont.CacheHit", CacheHitEnumMax));
- cacheHitHistogram.count(histogramValue);
+ cacheHitHistogram.count(cacheHitValue);
+
+ int duration = static_cast<int>(currentTimeMS() - m_loadStartTime);
+ recordLoadTimeHistogram(font, duration, cacheHitValue == Miss);
+ m_loadStartTime = -1;
enum { CORSFail, CORSSuccess, CORSEnumMax };
int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess;
@@ -282,37 +282,55 @@ void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour
}
}
-void RemoteFontFaceSource::FontLoadHistograms::recordLoadTimeHistogram(const FontResource* font, int duration)
+void RemoteFontFaceSource::FontLoadHistograms::recordLoadTimeHistogram(const FontResource* font, int duration, bool isLoadedFromNetwork)
{
if (font->errorOccurred()) {
DEFINE_STATIC_LOCAL(CustomCountHistogram, loadErrorHistogram, ("WebFont.DownloadTime.LoadError", 0, 10000, 50));
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheLoadErrorHistogram, ("WebFont.MissedCache.DownloadTime.LoadError", 0, 10000, 50));
loadErrorHistogram.count(duration);
+ if (isLoadedFromNetwork)
+ missedCacheLoadErrorHistogram.count(duration);
return;
}
unsigned size = font->encodedSize();
if (size < 10 * 1024) {
DEFINE_STATIC_LOCAL(CustomCountHistogram, under10kHistogram, ("WebFont.DownloadTime.0.Under10KB", 0, 10000, 50));
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheUnder10kHistogram, ("WebFont.MissedCache.DownloadTime.0.Under10KB", 0, 10000, 50));
under10kHistogram.count(duration);
+ if (isLoadedFromNetwork)
+ missedCacheUnder10kHistogram.count(duration);
return;
}
if (size < 50 * 1024) {
DEFINE_STATIC_LOCAL(CustomCountHistogram, under50kHistogram, ("WebFont.DownloadTime.1.10KBTo50KB", 0, 10000, 50));
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheUnder50kHistogram, ("WebFont.MissedCache.DownloadTime.1.10KBTo50KB", 0, 10000, 50));
under50kHistogram.count(duration);
+ if (isLoadedFromNetwork)
+ missedCacheUnder50kHistogram.count(duration);
return;
}
if (size < 100 * 1024) {
DEFINE_STATIC_LOCAL(CustomCountHistogram, under100kHistogram, ("WebFont.DownloadTime.2.50KBTo100KB", 0, 10000, 50));
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheUnder100kHistogram, ("WebFont.MissedCache.DownloadTime.2.50KBTo100KB", 0, 10000, 50));
under100kHistogram.count(duration);
+ if (isLoadedFromNetwork)
+ missedCacheUnder100kHistogram.count(duration);
return;
}
if (size < 1024 * 1024) {
DEFINE_STATIC_LOCAL(CustomCountHistogram, under1mbHistogram, ("WebFont.DownloadTime.3.100KBTo1MB", 0, 10000, 50));
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheUnder1mbHistogram, ("WebFont.MissedCache.DownloadTime.3.100KBTo1MB", 0, 10000, 50));
under1mbHistogram.count(duration);
+ if (isLoadedFromNetwork)
+ missedCacheUnder1mbHistogram.count(duration);
return;
}
DEFINE_STATIC_LOCAL(CustomCountHistogram, over1mbHistogram, ("WebFont.DownloadTime.4.Over1MB", 0, 10000, 50));
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheOver1mbHistogram, ("WebFont.MissedCache.DownloadTime.4.Over1MB", 0, 10000, 50));
over1mbHistogram.count(duration);
+ if (isLoadedFromNetwork)
+ missedCacheOver1mbHistogram.count(duration);
}
void RemoteFontFaceSource::FontLoadHistograms::recordInterventionResult(bool isTriggered, bool isLoadedFromNetwork)

Powered by Google App Engine
This is Rietveld 408576698