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" |
11 #include "core/fetch/ResourceFetcher.h" | 11 #include "core/fetch/ResourceFetcher.h" |
12 #include "core/inspector/ConsoleMessage.h" | 12 #include "core/inspector/ConsoleMessage.h" |
13 #include "core/loader/FrameLoaderClient.h" | 13 #include "core/loader/FrameLoaderClient.h" |
14 #include "core/page/NetworkStateNotifier.h" | 14 #include "core/page/NetworkStateNotifier.h" |
15 #include "platform/Histogram.h" | 15 #include "platform/Histogram.h" |
16 #include "platform/RuntimeEnabledFeatures.h" | 16 #include "platform/RuntimeEnabledFeatures.h" |
17 #include "platform/fonts/FontCache.h" | 17 #include "platform/fonts/FontCache.h" |
18 #include "platform/fonts/FontDescription.h" | 18 #include "platform/fonts/FontDescription.h" |
19 #include "platform/fonts/SimpleFontData.h" | 19 #include "platform/fonts/SimpleFontData.h" |
20 #include "public/platform/WebEffectiveConnectionType.h" | 20 #include "public/platform/WebEffectiveConnectionType.h" |
21 #include "wtf/CurrentTime.h" | 21 #include "wtf/CurrentTime.h" |
22 | 22 |
23 namespace blink { | 23 namespace blink { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // Should not change following enum order to be used for metrics values. | |
28 enum CacheHitMetrics { | |
29 Miss, | |
30 DiskHit, | |
31 DataUrl, | |
32 MemoryHit, | |
33 CacheHitEnumMax | |
34 }; | |
35 | |
36 CacheHitMetrics getMetricsValue(RemoteFontFaceSource::DataSource dataSource) | |
37 { | |
38 switch (dataSource) { | |
39 case RemoteFontFaceSource::FromDataURL: | |
40 return DataUrl; | |
41 case RemoteFontFaceSource::FromMemoryCache: | |
42 return MemoryHit; | |
43 case RemoteFontFaceSource::FromDiskCache: | |
44 return DiskHit; | |
45 case RemoteFontFaceSource::FromNetwork: | |
46 return Miss; | |
47 case RemoteFontFaceSource::FromUnknown: | |
48 // Still loading implies coming from network. | |
Kunihiko Sakamoto
2016/09/06 18:04:53
Having this logic in this conversion function feel
Takashi Toyoshima
2016/09/07 08:49:08
Done.
| |
49 return Miss; | |
50 default: | |
51 NOTREACHED(); | |
52 } | |
53 return Miss; | |
54 } | |
55 | |
27 bool isEffectiveConnectionTypeSlowFor(Document* document) | 56 bool isEffectiveConnectionTypeSlowFor(Document* document) |
28 { | 57 { |
29 WebEffectiveConnectionType type = document->frame()->loader().client()->getE ffectiveConnectionType(); | 58 WebEffectiveConnectionType type = document->frame()->loader().client()->getE ffectiveConnectionType(); |
30 | 59 |
31 WebEffectiveConnectionType thresholdType = RuntimeEnabledFeatures::webFontsI nterventionV2With2GEnabled() | 60 WebEffectiveConnectionType thresholdType = RuntimeEnabledFeatures::webFontsI nterventionV2With2GEnabled() |
32 ? WebEffectiveConnectionType::Type2G | 61 ? WebEffectiveConnectionType::Type2G |
33 : WebEffectiveConnectionType::TypeSlow2G; | 62 : WebEffectiveConnectionType::TypeSlow2G; |
34 | 63 |
35 return WebEffectiveConnectionType::TypeOffline <= type && type <= thresholdT ype; | 64 return WebEffectiveConnectionType::TypeOffline <= type && type <= thresholdT ype; |
36 } | 65 } |
37 | 66 |
38 bool isConnectionTypeSlow() | 67 bool isConnectionTypeSlow() |
39 { | 68 { |
40 return networkStateNotifier().connectionType() == WebConnectionTypeCellular2 G; | 69 return networkStateNotifier().connectionType() == WebConnectionTypeCellular2 G; |
41 } | 70 } |
42 | 71 |
43 bool shouldTriggerWebFontsIntervention(Document* document, FontDisplay display, bool isLoadedFromMemoryCache, bool isLoadedFromDataURL) | 72 bool shouldTriggerWebFontsIntervention(Document* document, FontDisplay display, RemoteFontFaceSource::DataSource dataSource) |
Kunihiko Sakamoto
2016/09/06 18:04:53
Maybe make this a private member function of Remot
Takashi Toyoshima
2016/09/07 08:49:08
Hum... I'm neutral on this, but I'd rather conside
Kunihiko Sakamoto
2016/09/07 16:25:42
ok, sgtm.
| |
44 { | 73 { |
45 if (RuntimeEnabledFeatures::webFontsInterventionTriggerEnabled()) | 74 if (RuntimeEnabledFeatures::webFontsInterventionTriggerEnabled()) |
46 return true; | 75 return true; |
47 if (isLoadedFromMemoryCache || isLoadedFromDataURL) | 76 if (dataSource == RemoteFontFaceSource::FromMemoryCache || dataSource == Rem oteFontFaceSource::FromDataURL) |
48 return false; | 77 return false; |
49 | 78 |
50 bool isV2Enabled = RuntimeEnabledFeatures::webFontsInterventionV2With2GEnabl ed() || RuntimeEnabledFeatures::webFontsInterventionV2WithSlow2GEnabled(); | 79 bool isV2Enabled = RuntimeEnabledFeatures::webFontsInterventionV2With2GEnabl ed() || RuntimeEnabledFeatures::webFontsInterventionV2WithSlow2GEnabled(); |
51 | 80 |
52 bool networkIsSlow = isV2Enabled ? isEffectiveConnectionTypeSlowFor(document ) : isConnectionTypeSlow(); | 81 bool networkIsSlow = isV2Enabled ? isEffectiveConnectionTypeSlowFor(document ) : isConnectionTypeSlow(); |
53 | 82 |
54 return networkIsSlow && display == FontDisplayAuto; | 83 return networkIsSlow && display == FontDisplayAuto; |
55 } | 84 } |
56 | 85 |
57 } // namespace | 86 } // namespace |
58 | 87 |
59 RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, CSSFontSelector* fontSelector, FontDisplay display) | 88 RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, CSSFontSelector* fontSelector, FontDisplay display) |
60 : m_font(font) | 89 : m_font(font) |
61 , m_fontSelector(fontSelector) | 90 , m_fontSelector(fontSelector) |
62 , m_display(display) | 91 , m_display(display) |
63 , m_period(display == FontDisplaySwap ? SwapPeriod : BlockPeriod) | 92 , m_period(display == FontDisplaySwap ? SwapPeriod : BlockPeriod) |
64 , m_isInterventionTriggered(false) | 93 , m_isInterventionTriggered(false) |
65 , m_isLoadedFromMemoryCache(font->isLoaded()) | 94 , m_dataSource(font->url().protocolIsData() ? FromDataURL : font->isLoaded() ? FromMemoryCache : FromUnknown) |
66 { | 95 { |
67 ThreadState::current()->registerPreFinalizer(this); | 96 ThreadState::current()->registerPreFinalizer(this); |
68 m_font->addClient(this); | 97 m_font->addClient(this); |
69 | 98 |
70 if (shouldTriggerWebFontsIntervention(m_fontSelector->document(), display, m _isLoadedFromMemoryCache, m_font->url().protocolIsData())) { | 99 if (shouldTriggerWebFontsIntervention(m_fontSelector->document(), display, m _dataSource)) { |
71 | |
72 m_isInterventionTriggered = true; | 100 m_isInterventionTriggered = true; |
73 m_period = SwapPeriod; | 101 m_period = SwapPeriod; |
74 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create(Oth erMessageSource, InfoMessageLevel, "Slow network is detected. Fallback font will be used while loading: " + m_font->url().elidedString())); | 102 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create(Oth erMessageSource, InfoMessageLevel, "Slow network is detected. Fallback font will be used while loading: " + m_font->url().elidedString())); |
75 } | 103 } |
76 } | 104 } |
77 | 105 |
78 RemoteFontFaceSource::~RemoteFontFaceSource() | 106 RemoteFontFaceSource::~RemoteFontFaceSource() |
79 { | 107 { |
80 } | 108 } |
81 | 109 |
(...skipping 27 matching lines...) Expand all Loading... | |
109 return m_font->isLoaded(); | 137 return m_font->isLoaded(); |
110 } | 138 } |
111 | 139 |
112 bool RemoteFontFaceSource::isValid() const | 140 bool RemoteFontFaceSource::isValid() const |
113 { | 141 { |
114 return !m_font->errorOccurred(); | 142 return !m_font->errorOccurred(); |
115 } | 143 } |
116 | 144 |
117 void RemoteFontFaceSource::notifyFinished(Resource*) | 145 void RemoteFontFaceSource::notifyFinished(Resource*) |
118 { | 146 { |
119 m_histograms.recordRemoteFont(m_font.get(), m_isLoadedFromMemoryCache); | 147 if (m_dataSource == FromUnknown) |
120 m_histograms.fontLoaded(m_isInterventionTriggered, !m_isLoadedFromMemoryCach e && !m_font->url().protocolIsData() && !m_font->response().wasCached()); | 148 m_dataSource = m_font->response().wasCached() ? FromDiskCache : FromNetw ork; |
149 m_histograms.recordRemoteFont(m_font.get(), m_dataSource); | |
150 m_histograms.fontLoaded(m_isInterventionTriggered, m_dataSource); | |
121 | 151 |
122 m_font->ensureCustomFontData(); | 152 m_font->ensureCustomFontData(); |
123 // FIXME: Provide more useful message such as OTS rejection reason. | 153 // FIXME: Provide more useful message such as OTS rejection reason. |
124 // See crbug.com/97467 | 154 // See crbug.com/97467 |
125 if (m_font->getStatus() == Resource::DecodeError && m_fontSelector->document ()) { | 155 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())); | 156 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) | 157 if (m_font->otsParsingMessage().length() > 1) |
128 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create (OtherMessageSource, WarningMessageLevel, "OTS parsing error: " + m_font->otsPar singMessage())); | 158 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create (OtherMessageSource, WarningMessageLevel, "OTS parsing error: " + m_font->otsPar singMessage())); |
129 } | 159 } |
130 | 160 |
131 pruneTable(); | 161 pruneTable(); |
132 if (m_face) { | 162 if (m_face) { |
133 m_fontSelector->fontFaceInvalidated(); | 163 m_fontSelector->fontFaceInvalidated(); |
134 m_face->fontLoaded(this); | 164 m_face->fontLoaded(this); |
135 } | 165 } |
136 // Should not do anything after this line since the m_face->fontLoaded() | 166 // Should not do anything after this line since the m_face->fontLoaded() |
137 // above may trigger deleting this object. | 167 // above may trigger deleting this object. |
138 } | 168 } |
139 | 169 |
140 void RemoteFontFaceSource::fontLoadShortLimitExceeded(FontResource*) | 170 void RemoteFontFaceSource::fontLoadShortLimitExceeded(FontResource*) |
141 { | 171 { |
142 if (m_display == FontDisplayFallback) | 172 if (m_display == FontDisplayFallback) |
143 switchToSwapPeriod(); | 173 switchToSwapPeriod(); |
144 else if (m_display == FontDisplayOptional) | 174 else if (m_display == FontDisplayOptional) |
145 switchToFailurePeriod(); | 175 switchToFailurePeriod(); |
146 } | 176 } |
147 | 177 |
148 void RemoteFontFaceSource::fontLoadLongLimitExceeded(FontResource*) | 178 void RemoteFontFaceSource::fontLoadLongLimitExceeded(FontResource*) |
149 { | 179 { |
Kunihiko Sakamoto
2016/09/06 18:04:53
How about having
if (m_dataSource == FromUnknown)
Takashi Toyoshima
2016/09/07 08:49:08
Move it inside longLimigExceeded() to have the mem
| |
150 if (m_display == FontDisplayBlock || (!m_isInterventionTriggered && m_displa y == FontDisplayAuto)) | 180 if (m_display == FontDisplayBlock || (!m_isInterventionTriggered && m_displa y == FontDisplayAuto)) |
151 switchToSwapPeriod(); | 181 switchToSwapPeriod(); |
152 else if (m_display == FontDisplayFallback) | 182 else if (m_display == FontDisplayFallback) |
153 switchToFailurePeriod(); | 183 switchToFailurePeriod(); |
154 | 184 |
155 m_histograms.longLimitExceeded(m_isInterventionTriggered); | 185 m_histograms.longLimitExceeded(m_isInterventionTriggered, m_dataSource); |
156 } | 186 } |
157 | 187 |
158 void RemoteFontFaceSource::switchToSwapPeriod() | 188 void RemoteFontFaceSource::switchToSwapPeriod() |
159 { | 189 { |
160 ASSERT(m_period == BlockPeriod); | 190 ASSERT(m_period == BlockPeriod); |
161 m_period = SwapPeriod; | 191 m_period = SwapPeriod; |
162 | 192 |
163 pruneTable(); | 193 pruneTable(); |
164 if (m_face) { | 194 if (m_face) { |
165 m_fontSelector->fontFaceInvalidated(); | 195 m_fontSelector->fontFaceInvalidated(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 if (!m_loadStartTime) | 261 if (!m_loadStartTime) |
232 m_loadStartTime = currentTimeMS(); | 262 m_loadStartTime = currentTimeMS(); |
233 } | 263 } |
234 | 264 |
235 void RemoteFontFaceSource::FontLoadHistograms::fallbackFontPainted(DisplayPeriod period) | 265 void RemoteFontFaceSource::FontLoadHistograms::fallbackFontPainted(DisplayPeriod period) |
236 { | 266 { |
237 if (period == BlockPeriod && !m_blankPaintTime) | 267 if (period == BlockPeriod && !m_blankPaintTime) |
238 m_blankPaintTime = currentTimeMS(); | 268 m_blankPaintTime = currentTimeMS(); |
239 } | 269 } |
240 | 270 |
241 void RemoteFontFaceSource::FontLoadHistograms::fontLoaded(bool isInterventionTri ggered, bool isLoadedFromNetwork) | 271 void RemoteFontFaceSource::FontLoadHistograms::fontLoaded(bool isInterventionTri ggered, DataSource dataSource) |
242 { | 272 { |
243 if (!m_isLongLimitExceeded) | 273 if (!m_isLongLimitExceeded) |
244 recordInterventionResult(isInterventionTriggered, isLoadedFromNetwork); | 274 recordInterventionResult(isInterventionTriggered, dataSource); |
245 } | 275 } |
246 | 276 |
247 void RemoteFontFaceSource::FontLoadHistograms::longLimitExceeded(bool isInterven tionTriggered) | 277 void RemoteFontFaceSource::FontLoadHistograms::longLimitExceeded(bool isInterven tionTriggered, DataSource dataSource) |
248 { | 278 { |
249 m_isLongLimitExceeded = true; | 279 m_isLongLimitExceeded = true; |
250 recordInterventionResult(isInterventionTriggered, true); | 280 recordInterventionResult(isInterventionTriggered, dataSource); |
251 } | 281 } |
252 | 282 |
253 void RemoteFontFaceSource::FontLoadHistograms::recordFallbackTime(const FontReso urce* font) | 283 void RemoteFontFaceSource::FontLoadHistograms::recordFallbackTime(const FontReso urce* font) |
254 { | 284 { |
255 if (m_blankPaintTime <= 0) | 285 if (m_blankPaintTime <= 0) |
256 return; | 286 return; |
257 int duration = static_cast<int>(currentTimeMS() - m_blankPaintTime); | 287 int duration = static_cast<int>(currentTimeMS() - m_blankPaintTime); |
258 DEFINE_STATIC_LOCAL(CustomCountHistogram, blankTextShownTimeHistogram, ("Web Font.BlankTextShownTime", 0, 10000, 50)); | 288 DEFINE_STATIC_LOCAL(CustomCountHistogram, blankTextShownTimeHistogram, ("Web Font.BlankTextShownTime", 0, 10000, 50)); |
259 blankTextShownTimeHistogram.count(duration); | 289 blankTextShownTimeHistogram.count(duration); |
260 m_blankPaintTime = -1; | 290 m_blankPaintTime = -1; |
261 } | 291 } |
262 | 292 |
263 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour ce* font, bool isLoadedFromMemoryCache) | 293 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour ce* font, DataSource dataSource) |
264 { | 294 { |
265 if (m_loadStartTime > 0 && font && !font->isLoading()) { | 295 if (m_loadStartTime > 0 && font && !font->isLoading()) { |
296 enum { Miss, DiskHit, DataUrl, MemoryHit, CacheHitEnumMax }; | |
297 int cacheHitValue = getMetricsValue(dataSource); | |
298 DEFINE_STATIC_LOCAL(EnumerationHistogram, cacheHitHistogram, ("WebFont.C acheHit", CacheHitEnumMax)); | |
299 cacheHitHistogram.count(cacheHitValue); | |
Kunihiko Sakamoto
2016/09/06 18:04:53
Call getMetricsValue() here and remove cacheHitVal
Takashi Toyoshima
2016/09/07 08:49:09
Done.
| |
300 | |
266 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime); | 301 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime); |
267 recordLoadTimeHistogram(font, duration); | 302 recordLoadTimeHistogram(font, duration, dataSource); |
268 m_loadStartTime = -1; | 303 m_loadStartTime = -1; |
269 | 304 |
270 enum { Miss, DiskHit, DataUrl, MemoryHit, CacheHitEnumMax }; | |
271 int histogramValue = font->url().protocolIsData() ? DataUrl | |
272 : isLoadedFromMemoryCache ? MemoryHit | |
273 : font->response().wasCached() ? DiskHit | |
274 : Miss; | |
275 DEFINE_STATIC_LOCAL(EnumerationHistogram, cacheHitHistogram, ("WebFont.C acheHit", CacheHitEnumMax)); | |
276 cacheHitHistogram.count(histogramValue); | |
277 | |
278 enum { CORSFail, CORSSuccess, CORSEnumMax }; | 305 enum { CORSFail, CORSSuccess, CORSEnumMax }; |
279 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess; | 306 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess; |
280 DEFINE_STATIC_LOCAL(EnumerationHistogram, corsHistogram, ("WebFont.CORSS uccess", CORSEnumMax)); | 307 DEFINE_STATIC_LOCAL(EnumerationHistogram, corsHistogram, ("WebFont.CORSS uccess", CORSEnumMax)); |
281 corsHistogram.count(corsValue); | 308 corsHistogram.count(corsValue); |
282 } | 309 } |
283 } | 310 } |
284 | 311 |
285 void RemoteFontFaceSource::FontLoadHistograms::recordLoadTimeHistogram(const Fon tResource* font, int duration) | 312 void RemoteFontFaceSource::FontLoadHistograms::recordLoadTimeHistogram(const Fon tResource* font, int duration, DataSource dataSource) |
286 { | 313 { |
287 if (font->errorOccurred()) { | 314 if (font->errorOccurred()) { |
288 DEFINE_STATIC_LOCAL(CustomCountHistogram, loadErrorHistogram, ("WebFont. DownloadTime.LoadError", 0, 10000, 50)); | 315 DEFINE_STATIC_LOCAL(CustomCountHistogram, loadErrorHistogram, ("WebFont. DownloadTime.LoadError", 0, 10000, 50)); |
316 DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheLoadErrorHistogram, ("WebFont.MissedCache.DownloadTime.LoadError", 0, 10000, 50)); | |
Takashi Toyoshima
2016/09/07 08:49:08
Also, I'd say there is another requirement to have
Kunihiko Sakamoto
2016/09/07 16:25:42
Yeah I'm following the thread, and I agree we need
Takashi Toyoshima
2016/09/09 06:25:24
Good point.
| |
289 loadErrorHistogram.count(duration); | 317 loadErrorHistogram.count(duration); |
318 if (dataSource == FromNetwork) | |
319 missedCacheLoadErrorHistogram.count(duration); | |
290 return; | 320 return; |
291 } | 321 } |
292 | 322 |
293 unsigned size = font->encodedSize(); | 323 unsigned size = font->encodedSize(); |
294 if (size < 10 * 1024) { | 324 if (size < 10 * 1024) { |
295 DEFINE_STATIC_LOCAL(CustomCountHistogram, under10kHistogram, ("WebFont.D ownloadTime.0.Under10KB", 0, 10000, 50)); | 325 DEFINE_STATIC_LOCAL(CustomCountHistogram, under10kHistogram, ("WebFont.D ownloadTime.0.Under10KB", 0, 10000, 50)); |
326 DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheUnder10kHistogram, ("WebFont.MissedCache.DownloadTime.0.Under10KB", 0, 10000, 50)); | |
296 under10kHistogram.count(duration); | 327 under10kHistogram.count(duration); |
328 if (dataSource == FromNetwork) | |
329 missedCacheUnder10kHistogram.count(duration); | |
297 return; | 330 return; |
298 } | 331 } |
299 if (size < 50 * 1024) { | 332 if (size < 50 * 1024) { |
300 DEFINE_STATIC_LOCAL(CustomCountHistogram, under50kHistogram, ("WebFont.D ownloadTime.1.10KBTo50KB", 0, 10000, 50)); | 333 DEFINE_STATIC_LOCAL(CustomCountHistogram, under50kHistogram, ("WebFont.D ownloadTime.1.10KBTo50KB", 0, 10000, 50)); |
334 DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheUnder50kHistogram, ("WebFont.MissedCache.DownloadTime.1.10KBTo50KB", 0, 10000, 50)); | |
301 under50kHistogram.count(duration); | 335 under50kHistogram.count(duration); |
336 if (dataSource == FromNetwork) | |
337 missedCacheUnder50kHistogram.count(duration); | |
302 return; | 338 return; |
303 } | 339 } |
304 if (size < 100 * 1024) { | 340 if (size < 100 * 1024) { |
305 DEFINE_STATIC_LOCAL(CustomCountHistogram, under100kHistogram, ("WebFont. DownloadTime.2.50KBTo100KB", 0, 10000, 50)); | 341 DEFINE_STATIC_LOCAL(CustomCountHistogram, under100kHistogram, ("WebFont. DownloadTime.2.50KBTo100KB", 0, 10000, 50)); |
342 DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheUnder100kHistogram, ("WebFont.MissedCache.DownloadTime.2.50KBTo100KB", 0, 10000, 50)); | |
306 under100kHistogram.count(duration); | 343 under100kHistogram.count(duration); |
344 if (dataSource == FromNetwork) | |
345 missedCacheUnder100kHistogram.count(duration); | |
307 return; | 346 return; |
308 } | 347 } |
309 if (size < 1024 * 1024) { | 348 if (size < 1024 * 1024) { |
310 DEFINE_STATIC_LOCAL(CustomCountHistogram, under1mbHistogram, ("WebFont.D ownloadTime.3.100KBTo1MB", 0, 10000, 50)); | 349 DEFINE_STATIC_LOCAL(CustomCountHistogram, under1mbHistogram, ("WebFont.D ownloadTime.3.100KBTo1MB", 0, 10000, 50)); |
350 DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheUnder1mbHistogram, ("WebFont.MissedCache.DownloadTime.3.100KBTo1MB", 0, 10000, 50)); | |
311 under1mbHistogram.count(duration); | 351 under1mbHistogram.count(duration); |
352 if (dataSource == FromNetwork) | |
353 missedCacheUnder1mbHistogram.count(duration); | |
312 return; | 354 return; |
313 } | 355 } |
314 DEFINE_STATIC_LOCAL(CustomCountHistogram, over1mbHistogram, ("WebFont.Downlo adTime.4.Over1MB", 0, 10000, 50)); | 356 DEFINE_STATIC_LOCAL(CustomCountHistogram, over1mbHistogram, ("WebFont.Downlo adTime.4.Over1MB", 0, 10000, 50)); |
357 DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheOver1mbHistogram, ("Web Font.MissedCache.DownloadTime.4.Over1MB", 0, 10000, 50)); | |
315 over1mbHistogram.count(duration); | 358 over1mbHistogram.count(duration); |
359 if (dataSource == FromNetwork) | |
360 missedCacheOver1mbHistogram.count(duration); | |
316 } | 361 } |
317 | 362 |
318 void RemoteFontFaceSource::FontLoadHistograms::recordInterventionResult(bool isT riggered, bool isLoadedFromNetwork) | 363 void RemoteFontFaceSource::FontLoadHistograms::recordInterventionResult(bool isT riggered, DataSource dataSource) |
319 { | 364 { |
320 // interventionResult takes 0-3 values. | 365 // interventionResult takes 0-3 values. |
321 int interventionResult = 0; | 366 int interventionResult = 0; |
322 if (m_isLongLimitExceeded) | 367 if (m_isLongLimitExceeded) |
323 interventionResult |= 1 << 0; | 368 interventionResult |= 1 << 0; |
324 if (isTriggered) | 369 if (isTriggered) |
325 interventionResult |= 1 << 1; | 370 interventionResult |= 1 << 1; |
326 const int boundary = 1 << 2; | 371 const int boundary = 1 << 2; |
327 | 372 |
328 DEFINE_STATIC_LOCAL(EnumerationHistogram, interventionHistogram, ("WebFont.I nterventionResult", boundary)); | 373 DEFINE_STATIC_LOCAL(EnumerationHistogram, interventionHistogram, ("WebFont.I nterventionResult", boundary)); |
329 DEFINE_STATIC_LOCAL(EnumerationHistogram, missedCacheInterventionHistogram, ("WebFont.InterventionResult.MissedCache", boundary)); | 374 DEFINE_STATIC_LOCAL(EnumerationHistogram, missedCacheInterventionHistogram, ("WebFont.InterventionResult.MissedCache", boundary)); |
330 interventionHistogram.count(interventionResult); | 375 interventionHistogram.count(interventionResult); |
331 if (isLoadedFromNetwork) | 376 if (dataSource == FromNetwork || dataSource == FromUnknown) |
332 missedCacheInterventionHistogram.count(interventionResult); | 377 missedCacheInterventionHistogram.count(interventionResult); |
333 } | 378 } |
334 | 379 |
335 } // namespace blink | 380 } // namespace blink |
OLD | NEW |