Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp

Issue 2359493004: FontLoadHistograms: classify as memory cache hit if FontResource loading not triggered (Closed)
Patch Set: use isLoadStartedCalled() in longLimitExceeded() Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/RemoteFontFaceSource.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return m_font->isLoaded(); 100 return m_font->isLoaded();
101 } 101 }
102 102
103 bool RemoteFontFaceSource::isValid() const 103 bool RemoteFontFaceSource::isValid() const
104 { 104 {
105 return !m_font->errorOccurred(); 105 return !m_font->errorOccurred();
106 } 106 }
107 107
108 void RemoteFontFaceSource::notifyFinished(Resource*) 108 void RemoteFontFaceSource::notifyFinished(Resource*)
109 { 109 {
110 m_histograms.maySetDataSource(m_font->response().wasCached() ? FontLoadHisto grams::FromDiskCache : FontLoadHistograms::FromNetwork); 110 m_histograms.maySetDataSource(!m_histograms.isLoadStartedCalled() ? FontLoad Histograms::FromMemoryCache : m_font->response().wasCached() ? FontLoadHistogram s::FromDiskCache : FontLoadHistograms::FromNetwork);
111 m_histograms.recordRemoteFont(m_font.get()); 111 m_histograms.recordRemoteFont(m_font.get());
112 m_histograms.fontLoaded(m_isInterventionTriggered); 112 m_histograms.fontLoaded(m_isInterventionTriggered);
113 113
114 m_font->ensureCustomFontData(); 114 m_font->ensureCustomFontData();
115 // FIXME: Provide more useful message such as OTS rejection reason. 115 // FIXME: Provide more useful message such as OTS rejection reason.
116 // See crbug.com/97467 116 // See crbug.com/97467
117 if (m_font->getStatus() == Resource::DecodeError && m_fontSelector->document ()) { 117 if (m_font->getStatus() == Resource::DecodeError && m_fontSelector->document ()) {
118 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create(Oth erMessageSource, WarningMessageLevel, "Failed to decode downloaded font: " + m_f ont->url().elidedString())); 118 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create(Oth erMessageSource, WarningMessageLevel, "Failed to decode downloaded font: " + m_f ont->url().elidedString()));
119 if (m_font->otsParsingMessage().length() > 1) 119 if (m_font->otsParsingMessage().length() > 1)
120 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create (OtherMessageSource, WarningMessageLevel, "OTS parsing error: " + m_font->otsPar singMessage())); 120 m_fontSelector->document()->addConsoleMessage(ConsoleMessage::create (OtherMessageSource, WarningMessageLevel, "OTS parsing error: " + m_font->otsPar singMessage()));
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 247
248 void RemoteFontFaceSource::FontLoadHistograms::fontLoaded(bool isInterventionTri ggered) 248 void RemoteFontFaceSource::FontLoadHistograms::fontLoaded(bool isInterventionTri ggered)
249 { 249 {
250 if (!m_isLongLimitExceeded) 250 if (!m_isLongLimitExceeded)
251 recordInterventionResult(isInterventionTriggered); 251 recordInterventionResult(isInterventionTriggered);
252 } 252 }
253 253
254 void RemoteFontFaceSource::FontLoadHistograms::longLimitExceeded(bool isInterven tionTriggered) 254 void RemoteFontFaceSource::FontLoadHistograms::longLimitExceeded(bool isInterven tionTriggered)
255 { 255 {
256 m_isLongLimitExceeded = true; 256 m_isLongLimitExceeded = true;
257 if (m_dataSource == FromUnknown) 257 maySetDataSource(isLoadStartedCalled() ? FromNetwork : FromMemoryCache);
Kunihiko Sakamoto 2016/09/29 09:19:26 Can you put this logic (if m_loadStartTime == 0 th
Shao-Chuan Lee 2016/09/29 09:31:42 Done.
258 m_dataSource = FromNetwork;
259 recordInterventionResult(isInterventionTriggered); 258 recordInterventionResult(isInterventionTriggered);
260 } 259 }
261 260
262 void RemoteFontFaceSource::FontLoadHistograms::recordFallbackTime(const FontReso urce* font) 261 void RemoteFontFaceSource::FontLoadHistograms::recordFallbackTime(const FontReso urce* font)
263 { 262 {
264 if (m_blankPaintTime <= 0) 263 if (m_blankPaintTime <= 0)
265 return; 264 return;
266 int duration = static_cast<int>(currentTimeMS() - m_blankPaintTime); 265 int duration = static_cast<int>(currentTimeMS() - m_blankPaintTime);
267 DEFINE_STATIC_LOCAL(CustomCountHistogram, blankTextShownTimeHistogram, ("Web Font.BlankTextShownTime", 0, 10000, 50)); 266 DEFINE_STATIC_LOCAL(CustomCountHistogram, blankTextShownTimeHistogram, ("Web Font.BlankTextShownTime", 0, 10000, 50));
268 blankTextShownTimeHistogram.count(duration); 267 blankTextShownTimeHistogram.count(duration);
269 m_blankPaintTime = -1; 268 m_blankPaintTime = -1;
270 } 269 }
271 270
272 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour ce* font) 271 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour ce* font)
273 { 272 {
274 DEFINE_STATIC_LOCAL(EnumerationHistogram, cacheHitHistogram, ("WebFont.Cache Hit", CacheHitEnumMax)); 273 DEFINE_STATIC_LOCAL(EnumerationHistogram, cacheHitHistogram, ("WebFont.Cache Hit", CacheHitEnumMax));
275 cacheHitHistogram.count(dataSourceMetricsValue()); 274 cacheHitHistogram.count(dataSourceMetricsValue());
276 275
277 if (m_dataSource == FromDiskCache || m_dataSource == FromNetwork) { 276 if (m_dataSource == FromDiskCache || m_dataSource == FromNetwork) {
277 DCHECK_NE(m_loadStartTime, 0);
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
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return Miss; 370 return Miss;
371 case FromUnknown: 371 case FromUnknown:
372 // Fall through. 372 // Fall through.
373 default: 373 default:
374 NOTREACHED(); 374 NOTREACHED();
375 } 375 }
376 return Miss; 376 return Miss;
377 } 377 }
378 378
379 } // namespace blink 379 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/RemoteFontFaceSource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698