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

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

Issue 23720005: Move webfont usage metrics reporting to FontResource (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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/fetch/FontResource.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/FontResource.cpp
diff --git a/Source/core/fetch/FontResource.cpp b/Source/core/fetch/FontResource.cpp
index 72142e39b31d75f11a1c717901b1ec16daf983f9..d4db35a664630577eb44ac3d9850636c65bd5655 100644
--- a/Source/core/fetch/FontResource.cpp
+++ b/Source/core/fetch/FontResource.cpp
@@ -30,9 +30,11 @@
#include "core/fetch/ResourceClient.h"
#include "core/fetch/ResourceClientWalker.h"
#include "core/fetch/TextResourceDecoder.h"
+#include "core/platform/HistogramSupport.h"
#include "core/platform/SharedBuffer.h"
#include "core/platform/graphics/FontCustomPlatformData.h"
#include "core/platform/graphics/FontPlatformData.h"
+#include "wtf/CurrentTime.h"
#if ENABLE(SVG_FONTS)
#include "SVGNames.h"
@@ -77,6 +79,7 @@ void FontResource::beginLoadIfNeeded(ResourceFetcher* dl)
ResourceClientWalker<FontResourceClient> walker(m_clients);
while (FontResourceClient* client = walker.next())
client->didStartFontLoad(this);
+ m_histograms.loadStarted();
}
}
@@ -162,4 +165,36 @@ void FontResource::checkNotify()
c->fontLoaded(this);
}
+void FontResource::willUseFontData()
+{
+ if (!isLoaded())
+ m_histograms.willUseFontData();
+}
+
+FontResource::FontResourceHistograms::~FontResourceHistograms()
+{
+ if (m_styledTime > 0)
+ HistogramSupport::histogramEnumeration("WebFont.Resource.UsageType", StyledButNotUsed, UsageTypeMax);
+}
+
+void FontResource::FontResourceHistograms::willUseFontData()
+{
+ if (!m_styledTime)
+ m_styledTime = currentTimeMS();
+}
+
+void FontResource::FontResourceHistograms::loadStarted()
+{
+ if (m_styledTime < 0)
+ return;
+ if (!m_styledTime) {
+ HistogramSupport::histogramEnumeration("WebFont.Resource.UsageType", NotStyledButUsed, UsageTypeMax);
+ } else {
+ int duration = static_cast<int>(currentTimeMS() - m_styledTime);
+ HistogramSupport::histogramCustomCounts("WebFont.Resource.StyleRecalcToDownloadLatency", duration, 0, 10000, 50);
+ HistogramSupport::histogramEnumeration("WebFont.Resource.UsageType", StyledAndUsed, UsageTypeMax);
+ }
+ m_styledTime = -1;
+}
+
}
« no previous file with comments | « Source/core/fetch/FontResource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698