| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 return m_font->isLoaded(); | 109 return m_font->isLoaded(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool RemoteFontFaceSource::isValid() const | 112 bool RemoteFontFaceSource::isValid() const |
| 113 { | 113 { |
| 114 return !m_font->errorOccurred(); | 114 return !m_font->errorOccurred(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void RemoteFontFaceSource::notifyFinished(Resource*) | 117 void RemoteFontFaceSource::notifyFinished(Resource*) |
| 118 { | 118 { |
| 119 m_histograms.recordRemoteFont(m_font.get()); | 119 m_histograms.recordRemoteFont(m_font.get(), m_isLoadedFromMemoryCache); |
| 120 m_histograms.fontLoaded(m_isInterventionTriggered, !m_isLoadedFromMemoryCach
e && !m_font->url().protocolIsData() && !m_font->response().wasCached()); | 120 m_histograms.fontLoaded(m_isInterventionTriggered, !m_isLoadedFromMemoryCach
e && !m_font->url().protocolIsData() && !m_font->response().wasCached()); |
| 121 | 121 |
| 122 m_font->ensureCustomFontData(); | 122 m_font->ensureCustomFontData(); |
| 123 // FIXME: Provide more useful message such as OTS rejection reason. | 123 // FIXME: Provide more useful message such as OTS rejection reason. |
| 124 // See crbug.com/97467 | 124 // See crbug.com/97467 |
| 125 if (m_font->getStatus() == Resource::DecodeError && m_fontSelector->document
()) { | 125 if (m_font->getStatus() == Resource::DecodeError && m_fontSelector->document
()) { |
| 126 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create(Oth
erMessageSource, WarningMessageLevel, "Failed to decode downloaded font: " + m_f
ont->url().elidedString())); | 126 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create(Oth
erMessageSource, WarningMessageLevel, "Failed to decode downloaded font: " + m_f
ont->url().elidedString())); |
| 127 if (m_font->otsParsingMessage().length() > 1) | 127 if (m_font->otsParsingMessage().length() > 1) |
| 128 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create
(OtherMessageSource, WarningMessageLevel, "OTS parsing error: " + m_font->otsPar
singMessage())); | 128 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create
(OtherMessageSource, WarningMessageLevel, "OTS parsing error: " + m_font->otsPar
singMessage())); |
| 129 } | 129 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 void RemoteFontFaceSource::FontLoadHistograms::recordFallbackTime(const FontReso
urce* font) | 253 void RemoteFontFaceSource::FontLoadHistograms::recordFallbackTime(const FontReso
urce* font) |
| 254 { | 254 { |
| 255 if (m_blankPaintTime <= 0) | 255 if (m_blankPaintTime <= 0) |
| 256 return; | 256 return; |
| 257 int duration = static_cast<int>(currentTimeMS() - m_blankPaintTime); | 257 int duration = static_cast<int>(currentTimeMS() - m_blankPaintTime); |
| 258 DEFINE_STATIC_LOCAL(CustomCountHistogram, blankTextShownTimeHistogram, ("Web
Font.BlankTextShownTime", 0, 10000, 50)); | 258 DEFINE_STATIC_LOCAL(CustomCountHistogram, blankTextShownTimeHistogram, ("Web
Font.BlankTextShownTime", 0, 10000, 50)); |
| 259 blankTextShownTimeHistogram.count(duration); | 259 blankTextShownTimeHistogram.count(duration); |
| 260 m_blankPaintTime = -1; | 260 m_blankPaintTime = -1; |
| 261 } | 261 } |
| 262 | 262 |
| 263 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour
ce* font) | 263 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour
ce* font, bool isLoadedFromMemoryCache) |
| 264 { | 264 { |
| 265 if (m_loadStartTime > 0 && font && !font->isLoading()) { | 265 if (m_loadStartTime > 0 && font && !font->isLoading()) { |
| 266 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime); | 266 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime); |
| 267 recordLoadTimeHistogram(font, duration); | 267 recordLoadTimeHistogram(font, duration); |
| 268 m_loadStartTime = -1; | 268 m_loadStartTime = -1; |
| 269 | 269 |
| 270 enum { Miss, Hit, DataUrl, CacheHitEnumMax }; | 270 enum { Miss, DiskHit, DataUrl, MemoryHit, CacheHitEnumMax }; |
| 271 int histogramValue = font->url().protocolIsData() ? DataUrl | 271 int histogramValue = font->url().protocolIsData() ? DataUrl |
| 272 : font->response().wasCached() ? Hit | 272 : isLoadedFromMemoryCache ? MemoryHit |
| 273 : font->response().wasCached() ? DiskHit |
| 273 : Miss; | 274 : Miss; |
| 274 DEFINE_STATIC_LOCAL(EnumerationHistogram, cacheHitHistogram, ("WebFont.C
acheHit", CacheHitEnumMax)); | 275 DEFINE_STATIC_LOCAL(EnumerationHistogram, cacheHitHistogram, ("WebFont.C
acheHit", CacheHitEnumMax)); |
| 275 cacheHitHistogram.count(histogramValue); | 276 cacheHitHistogram.count(histogramValue); |
| 276 | 277 |
| 277 enum { CORSFail, CORSSuccess, CORSEnumMax }; | 278 enum { CORSFail, CORSSuccess, CORSEnumMax }; |
| 278 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess; | 279 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess; |
| 279 DEFINE_STATIC_LOCAL(EnumerationHistogram, corsHistogram, ("WebFont.CORSS
uccess", CORSEnumMax)); | 280 DEFINE_STATIC_LOCAL(EnumerationHistogram, corsHistogram, ("WebFont.CORSS
uccess", CORSEnumMax)); |
| 280 corsHistogram.count(corsValue); | 281 corsHistogram.count(corsValue); |
| 281 } | 282 } |
| 282 } | 283 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 const int boundary = 1 << 2; | 326 const int boundary = 1 << 2; |
| 326 | 327 |
| 327 DEFINE_STATIC_LOCAL(EnumerationHistogram, interventionHistogram, ("WebFont.I
nterventionResult", boundary)); | 328 DEFINE_STATIC_LOCAL(EnumerationHistogram, interventionHistogram, ("WebFont.I
nterventionResult", boundary)); |
| 328 DEFINE_STATIC_LOCAL(EnumerationHistogram, missedCacheInterventionHistogram,
("WebFont.InterventionResult.MissedCache", boundary)); | 329 DEFINE_STATIC_LOCAL(EnumerationHistogram, missedCacheInterventionHistogram,
("WebFont.InterventionResult.MissedCache", boundary)); |
| 329 interventionHistogram.count(interventionResult); | 330 interventionHistogram.count(interventionResult); |
| 330 if (isLoadedFromNetwork) | 331 if (isLoadedFromNetwork) |
| 331 missedCacheInterventionHistogram.count(interventionResult); | 332 missedCacheInterventionHistogram.count(interventionResult); |
| 332 } | 333 } |
| 333 | 334 |
| 334 } // namespace blink | 335 } // namespace blink |
| OLD | NEW |