OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |