| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime); | 278 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime); |
| 279 recordLoadTimeHistogram(font, duration); | 279 recordLoadTimeHistogram(font, duration); |
| 280 | 280 |
| 281 enum { CORSFail, CORSSuccess, CORSEnumMax }; | 281 enum { CORSFail, CORSSuccess, CORSEnumMax }; |
| 282 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess; | 282 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess; |
| 283 DEFINE_STATIC_LOCAL(EnumerationHistogram, corsHistogram, ("WebFont.CORSS
uccess", CORSEnumMax)); | 283 DEFINE_STATIC_LOCAL(EnumerationHistogram, corsHistogram, ("WebFont.CORSS
uccess", CORSEnumMax)); |
| 284 corsHistogram.count(corsValue); | 284 corsHistogram.count(corsValue); |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 | 287 |
| 288 void RemoteFontFaceSource::FontLoadHistograms::maySetDataSource(DataSource dataS
ource) |
| 289 { |
| 290 if (m_dataSource != FromUnknown) |
| 291 return; |
| 292 // Classify as memory cache hit if |m_loadStartTime| is not set, i.e. |
| 293 // this RemoteFontFaceSource instance didn't trigger FontResource |
| 294 // loading. |
| 295 if (m_loadStartTime == 0) |
| 296 m_dataSource = FromMemoryCache; |
| 297 else |
| 298 m_dataSource = dataSource; |
| 299 } |
| 300 |
| 288 void RemoteFontFaceSource::FontLoadHistograms::recordLoadTimeHistogram(const Fon
tResource* font, int duration) | 301 void RemoteFontFaceSource::FontLoadHistograms::recordLoadTimeHistogram(const Fon
tResource* font, int duration) |
| 289 { | 302 { |
| 290 CHECK_NE(FromUnknown, m_dataSource); | 303 CHECK_NE(FromUnknown, m_dataSource); |
| 291 | 304 |
| 292 if (font->errorOccurred()) { | 305 if (font->errorOccurred()) { |
| 293 DEFINE_STATIC_LOCAL(CustomCountHistogram, loadErrorHistogram, ("WebFont.
DownloadTime.LoadError", 0, 10000, 50)); | 306 DEFINE_STATIC_LOCAL(CustomCountHistogram, loadErrorHistogram, ("WebFont.
DownloadTime.LoadError", 0, 10000, 50)); |
| 294 DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheLoadErrorHistogram,
("WebFont.MissedCache.DownloadTime.LoadError", 0, 10000, 50)); | 307 DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheLoadErrorHistogram,
("WebFont.MissedCache.DownloadTime.LoadError", 0, 10000, 50)); |
| 295 loadErrorHistogram.count(duration); | 308 loadErrorHistogram.count(duration); |
| 296 if (m_dataSource == FromNetwork) | 309 if (m_dataSource == FromNetwork) |
| 297 missedCacheLoadErrorHistogram.count(duration); | 310 missedCacheLoadErrorHistogram.count(duration); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 return Miss; | 383 return Miss; |
| 371 case FromUnknown: | 384 case FromUnknown: |
| 372 // Fall through. | 385 // Fall through. |
| 373 default: | 386 default: |
| 374 NOTREACHED(); | 387 NOTREACHED(); |
| 375 } | 388 } |
| 376 return Miss; | 389 return Miss; |
| 377 } | 390 } |
| 378 | 391 |
| 379 } // namespace blink | 392 } // namespace blink |
| OLD | NEW |