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

Side by Side Diff: Source/core/css/CSSFontFaceSource.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSFontFaceSource.h ('k') | Source/core/fetch/FontResource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2010, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 bool CSSFontFaceSource::isLocalFontAvailable(const FontDescription& fontDescript ion) 244 bool CSSFontFaceSource::isLocalFontAvailable(const FontDescription& fontDescript ion)
245 { 245 {
246 if (!isLocal()) 246 if (!isLocal())
247 return false; 247 return false;
248 return fontCache()->isPlatformFontAvailable(fontDescription, m_string, true) ; 248 return fontCache()->isPlatformFontAvailable(fontDescription, m_string, true) ;
249 } 249 }
250 250
251 void CSSFontFaceSource::willUseFontData() 251 void CSSFontFaceSource::willUseFontData()
252 { 252 {
253 if (!isLoaded()) 253 if (m_font)
254 m_histograms.willUseFontData(); 254 m_font->willUseFontData();
255 }
256
257 CSSFontFaceSource::FontLoadHistograms::~FontLoadHistograms()
258 {
259 if (m_styledTime > 0)
260 HistogramSupport::histogramEnumeration("WebFont.UsageType", StyledButNot Used, UsageTypeMax);
261 }
262
263 void CSSFontFaceSource::FontLoadHistograms::willUseFontData()
264 {
265 if (!m_styledTime)
266 m_styledTime = currentTimeMS();
267 } 255 }
268 256
269 void CSSFontFaceSource::FontLoadHistograms::loadStarted() 257 void CSSFontFaceSource::FontLoadHistograms::loadStarted()
270 { 258 {
271 if (!m_loadStartTime) 259 if (!m_loadStartTime)
272 m_loadStartTime = currentTimeMS(); 260 m_loadStartTime = currentTimeMS();
273
274 if (m_styledTime < 0)
275 return;
276 if (!m_styledTime) {
277 HistogramSupport::histogramEnumeration("WebFont.UsageType", NotStyledBut Used, UsageTypeMax);
278 } else {
279 int duration = static_cast<int>(currentTimeMS() - m_styledTime);
280 HistogramSupport::histogramCustomCounts("WebFont.StyleRecalcToDownloadLa tency", duration, 0, 10000, 50);
281 HistogramSupport::histogramEnumeration("WebFont.UsageType", StyledAndUse d, UsageTypeMax);
282 }
283 m_styledTime = -1;
284 } 261 }
285 262
286 void CSSFontFaceSource::FontLoadHistograms::recordLocalFont(bool loadSuccess) 263 void CSSFontFaceSource::FontLoadHistograms::recordLocalFont(bool loadSuccess)
287 { 264 {
288 if (!m_loadStartTime) { 265 if (!m_loadStartTime) {
289 HistogramSupport::histogramEnumeration("WebFont.LocalFontUsed", loadSucc ess ? 1 : 0, 2); 266 HistogramSupport::histogramEnumeration("WebFont.LocalFontUsed", loadSucc ess ? 1 : 0, 2);
290 m_loadStartTime = -1; // Do not count this font again. 267 m_loadStartTime = -1; // Do not count this font again.
291 } 268 }
292 } 269 }
293 270
(...skipping 17 matching lines...) Expand all
311 if (size < 50 * 1024) 288 if (size < 50 * 1024)
312 return "WebFont.DownloadTime.1.10KBTo50KB"; 289 return "WebFont.DownloadTime.1.10KBTo50KB";
313 if (size < 100 * 1024) 290 if (size < 100 * 1024)
314 return "WebFont.DownloadTime.2.50KBTo100KB"; 291 return "WebFont.DownloadTime.2.50KBTo100KB";
315 if (size < 1024 * 1024) 292 if (size < 1024 * 1024)
316 return "WebFont.DownloadTime.3.100KBTo1MB"; 293 return "WebFont.DownloadTime.3.100KBTo1MB";
317 return "WebFont.DownloadTime.4.Over1MB"; 294 return "WebFont.DownloadTime.4.Over1MB";
318 } 295 }
319 296
320 } 297 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSFontFaceSource.h ('k') | Source/core/fetch/FontResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698