Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/RemoteFontFaceSource.h" | 5 #include "core/css/RemoteFontFaceSource.h" |
| 6 | 6 |
| 7 #include "core/css/CSSCustomFontData.h" | 7 #include "core/css/CSSCustomFontData.h" |
| 8 #include "core/css/CSSFontFace.h" | 8 #include "core/css/CSSFontFace.h" |
| 9 #include "core/css/CSSFontSelector.h" | 9 #include "core/css/CSSFontSelector.h" |
| 10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool RemoteFontFaceSource::isValid() const { | 107 bool RemoteFontFaceSource::isValid() const { |
| 108 return !m_font->errorOccurred(); | 108 return !m_font->errorOccurred(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void RemoteFontFaceSource::notifyFinished(Resource*) { | 111 void RemoteFontFaceSource::notifyFinished(Resource*) { |
| 112 m_histograms.maySetDataSource(m_font->response().wasCached() | 112 m_histograms.maySetDataSource(m_font->response().wasCached() |
| 113 ? FontLoadHistograms::FromDiskCache | 113 ? FontLoadHistograms::FromDiskCache |
| 114 : FontLoadHistograms::FromNetwork); | 114 : FontLoadHistograms::FromNetwork); |
| 115 m_histograms.recordRemoteFont(m_font.get()); | 115 m_histograms.recordRemoteFont(m_font.get(), m_isInterventionTriggered); |
| 116 m_histograms.fontLoaded(m_font->isCORSFailed(), | 116 m_histograms.fontLoaded(m_font->isCORSFailed(), |
| 117 m_font->getStatus() == Resource::LoadError, | 117 m_font->getStatus() == Resource::LoadError, |
| 118 m_isInterventionTriggered); | 118 m_isInterventionTriggered); |
| 119 | 119 |
| 120 m_font->ensureCustomFontData(); | 120 m_font->ensureCustomFontData(); |
| 121 // FIXME: Provide more useful message such as OTS rejection reason. | 121 // FIXME: Provide more useful message such as OTS rejection reason. |
| 122 // See crbug.com/97467 | 122 // See crbug.com/97467 |
| 123 if (m_font->getStatus() == Resource::DecodeError && | 123 if (m_font->getStatus() == Resource::DecodeError && |
| 124 m_fontSelector->document()) { | 124 m_fontSelector->document()) { |
| 125 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create( | 125 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create( |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 if (m_blankPaintTime <= 0) | 288 if (m_blankPaintTime <= 0) |
| 289 return; | 289 return; |
| 290 int duration = static_cast<int>(currentTimeMS() - m_blankPaintTime); | 290 int duration = static_cast<int>(currentTimeMS() - m_blankPaintTime); |
| 291 DEFINE_STATIC_LOCAL(CustomCountHistogram, blankTextShownTimeHistogram, | 291 DEFINE_STATIC_LOCAL(CustomCountHistogram, blankTextShownTimeHistogram, |
| 292 ("WebFont.BlankTextShownTime", 0, 10000, 50)); | 292 ("WebFont.BlankTextShownTime", 0, 10000, 50)); |
| 293 blankTextShownTimeHistogram.count(duration); | 293 blankTextShownTimeHistogram.count(duration); |
| 294 m_blankPaintTime = -1; | 294 m_blankPaintTime = -1; |
| 295 } | 295 } |
| 296 | 296 |
| 297 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont( | 297 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont( |
| 298 const FontResource* font) { | 298 const FontResource* font, |
| 299 bool isInterventionTriggered) { | |
| 299 DEFINE_STATIC_LOCAL(EnumerationHistogram, cacheHitHistogram, | 300 DEFINE_STATIC_LOCAL(EnumerationHistogram, cacheHitHistogram, |
| 300 ("WebFont.CacheHit", CacheHitEnumMax)); | 301 ("WebFont.CacheHit", CacheHitEnumMax)); |
| 301 cacheHitHistogram.count(dataSourceMetricsValue()); | 302 cacheHitHistogram.count(dataSourceMetricsValue()); |
| 302 | 303 |
| 303 if (m_dataSource == FromDiskCache || m_dataSource == FromNetwork) { | 304 if (m_dataSource == FromDiskCache || m_dataSource == FromNetwork) { |
| 304 DCHECK_NE(m_loadStartTime, 0); | 305 DCHECK_NE(m_loadStartTime, 0); |
| 305 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime); | 306 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime); |
| 306 recordLoadTimeHistogram(font, duration); | 307 recordLoadTimeHistogram(font, duration, isInterventionTriggered); |
| 307 | 308 |
| 308 enum { CORSFail, CORSSuccess, CORSEnumMax }; | 309 enum { CORSFail, CORSSuccess, CORSEnumMax }; |
| 309 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess; | 310 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess; |
| 310 DEFINE_STATIC_LOCAL(EnumerationHistogram, corsHistogram, | 311 DEFINE_STATIC_LOCAL(EnumerationHistogram, corsHistogram, |
| 311 ("WebFont.CORSSuccess", CORSEnumMax)); | 312 ("WebFont.CORSSuccess", CORSEnumMax)); |
| 312 corsHistogram.count(corsValue); | 313 corsHistogram.count(corsValue); |
| 313 } | 314 } |
| 314 } | 315 } |
| 315 | 316 |
| 316 void RemoteFontFaceSource::FontLoadHistograms::maySetDataSource( | 317 void RemoteFontFaceSource::FontLoadHistograms::maySetDataSource( |
| 317 DataSource dataSource) { | 318 DataSource dataSource) { |
| 318 if (m_dataSource != FromUnknown) | 319 if (m_dataSource != FromUnknown) |
| 319 return; | 320 return; |
| 320 // Classify as memory cache hit if |m_loadStartTime| is not set, i.e. | 321 // Classify as memory cache hit if |m_loadStartTime| is not set, i.e. |
| 321 // this RemoteFontFaceSource instance didn't trigger FontResource | 322 // this RemoteFontFaceSource instance didn't trigger FontResource |
| 322 // loading. | 323 // loading. |
| 323 if (m_loadStartTime == 0) | 324 if (m_loadStartTime == 0) |
| 324 m_dataSource = FromMemoryCache; | 325 m_dataSource = FromMemoryCache; |
| 325 else | 326 else |
| 326 m_dataSource = dataSource; | 327 m_dataSource = dataSource; |
| 327 } | 328 } |
| 328 | 329 |
| 329 void RemoteFontFaceSource::FontLoadHistograms::recordLoadTimeHistogram( | 330 void RemoteFontFaceSource::FontLoadHistograms::recordLoadTimeHistogram( |
| 330 const FontResource* font, | 331 const FontResource* font, |
| 331 int duration) { | 332 int duration, |
| 333 bool isInterventionTriggered) { | |
| 332 CHECK_NE(FromUnknown, m_dataSource); | 334 CHECK_NE(FromUnknown, m_dataSource); |
| 333 | 335 |
| 334 if (font->errorOccurred()) { | 336 if (font->errorOccurred()) { |
| 335 DEFINE_STATIC_LOCAL(CustomCountHistogram, loadErrorHistogram, | 337 DEFINE_STATIC_LOCAL(CustomCountHistogram, loadErrorHistogram, |
| 336 ("WebFont.DownloadTime.LoadError", 0, 10000, 50)); | 338 ("WebFont.DownloadTime.LoadError", 0, 10000, 50)); |
| 337 DEFINE_STATIC_LOCAL( | 339 DEFINE_STATIC_LOCAL( |
| 338 CustomCountHistogram, missedCacheLoadErrorHistogram, | 340 CustomCountHistogram, missedCacheLoadErrorHistogram, |
| 339 ("WebFont.MissedCache.DownloadTime.LoadError", 0, 10000, 50)); | 341 ("WebFont.MissedCache.DownloadTime.LoadError", 0, 10000, 50)); |
| 340 loadErrorHistogram.count(duration); | 342 loadErrorHistogram.count(duration); |
| 341 if (m_dataSource == FromNetwork) | 343 if (m_dataSource == FromNetwork) |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 354 if (m_dataSource == FromNetwork) | 356 if (m_dataSource == FromNetwork) |
| 355 missedCacheUnder10kHistogram.count(duration); | 357 missedCacheUnder10kHistogram.count(duration); |
| 356 return; | 358 return; |
| 357 } | 359 } |
| 358 if (size < 50 * 1024) { | 360 if (size < 50 * 1024) { |
| 359 DEFINE_STATIC_LOCAL(CustomCountHistogram, under50kHistogram, | 361 DEFINE_STATIC_LOCAL(CustomCountHistogram, under50kHistogram, |
| 360 ("WebFont.DownloadTime.1.10KBTo50KB", 0, 10000, 50)); | 362 ("WebFont.DownloadTime.1.10KBTo50KB", 0, 10000, 50)); |
| 361 DEFINE_STATIC_LOCAL( | 363 DEFINE_STATIC_LOCAL( |
| 362 CustomCountHistogram, missedCacheUnder50kHistogram, | 364 CustomCountHistogram, missedCacheUnder50kHistogram, |
| 363 ("WebFont.MissedCache.DownloadTime.1.10KBTo50KB", 0, 10000, 50)); | 365 ("WebFont.MissedCache.DownloadTime.1.10KBTo50KB", 0, 10000, 50)); |
| 366 // Breakdowns metrics to understand WebFonts intervention. | |
| 367 // Now we only cover this 10KBto50KB range because 70% of requests are | |
| 368 // covered in this range, and having metrics for all size cases cost. | |
| 369 // TODO(toyoshim): edit histograms.xml. | |
|
kinuko
2016/10/26 02:41:49
do we still need this TODO?
Takashi Toyoshima
2016/10/26 21:35:20
oops, thank you for catching this.
| |
| 370 DEFINE_STATIC_LOCAL(CustomCountHistogram, | |
| 371 missedCacheAndInterventionTriggeredUnder50kHistogram, | |
| 372 ("WebFont.MissedCacheAndInterventionTriggered." | |
| 373 "DownloadTime.1.10KBTo50KB", | |
| 374 0, 10000, 50)); | |
| 375 DEFINE_STATIC_LOCAL(CustomCountHistogram, | |
| 376 missedCacheAndInterventionNotTriggeredUnder50kHistogram, | |
| 377 ("WebFont.MissedCacheAndInterventionNotTriggered." | |
| 378 "DownloadTime.1.10KBTo50KB", | |
| 379 0, 10000, 50)); | |
| 364 under50kHistogram.count(duration); | 380 under50kHistogram.count(duration); |
| 365 if (m_dataSource == FromNetwork) | 381 if (m_dataSource == FromNetwork) { |
| 366 missedCacheUnder50kHistogram.count(duration); | 382 missedCacheUnder50kHistogram.count(duration); |
| 383 if (isInterventionTriggered) | |
| 384 missedCacheAndInterventionTriggeredUnder50kHistogram.count(duration); | |
| 385 else | |
| 386 missedCacheAndInterventionNotTriggeredUnder50kHistogram.count(duration); | |
| 387 } | |
| 367 return; | 388 return; |
| 368 } | 389 } |
| 369 if (size < 100 * 1024) { | 390 if (size < 100 * 1024) { |
| 370 DEFINE_STATIC_LOCAL(CustomCountHistogram, under100kHistogram, | 391 DEFINE_STATIC_LOCAL(CustomCountHistogram, under100kHistogram, |
| 371 ("WebFont.DownloadTime.2.50KBTo100KB", 0, 10000, 50)); | 392 ("WebFont.DownloadTime.2.50KBTo100KB", 0, 10000, 50)); |
| 372 DEFINE_STATIC_LOCAL( | 393 DEFINE_STATIC_LOCAL( |
| 373 CustomCountHistogram, missedCacheUnder100kHistogram, | 394 CustomCountHistogram, missedCacheUnder100kHistogram, |
| 374 ("WebFont.MissedCache.DownloadTime.2.50KBTo100KB", 0, 10000, 50)); | 395 ("WebFont.MissedCache.DownloadTime.2.50KBTo100KB", 0, 10000, 50)); |
| 375 under100kHistogram.count(duration); | 396 under100kHistogram.count(duration); |
| 376 if (m_dataSource == FromNetwork) | 397 if (m_dataSource == FromNetwork) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 return Miss; | 453 return Miss; |
| 433 case FromUnknown: | 454 case FromUnknown: |
| 434 // Fall through. | 455 // Fall through. |
| 435 default: | 456 default: |
| 436 NOTREACHED(); | 457 NOTREACHED(); |
| 437 } | 458 } |
| 438 return Miss; | 459 return Miss; |
| 439 } | 460 } |
| 440 | 461 |
| 441 } // namespace blink | 462 } // namespace blink |
| OLD | NEW |