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

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: Created 4 years, 3 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 | « no previous file | 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(this, m_pe riod == BlockPeriod ? CSSCustomFontData::InvisibleFallback : CSSCustomFontData:: VisibleFallback); 212 RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(this, m_pe riod == BlockPeriod ? CSSCustomFontData::InvisibleFallback : CSSCustomFontData:: VisibleFallback);
213 return SimpleFontData::create(temporaryFont->platformData(), cssFontData); 213 return SimpleFontData::create(temporaryFont->platformData(), cssFontData);
214 } 214 }
215 215
216 void RemoteFontFaceSource::beginLoadIfNeeded() 216 void RemoteFontFaceSource::beginLoadIfNeeded()
217 { 217 {
218 if (m_fontSelector->document() && m_font->stillNeedsLoad()) { 218 if (m_fontSelector->document() && m_font->stillNeedsLoad()) {
219 m_fontSelector->document()->fetcher()->startLoad(m_font); 219 m_fontSelector->document()->fetcher()->startLoad(m_font);
220 m_histograms.loadStarted(); 220 m_histograms.loadStarted();
221 } else {
222 // In this case the |m_font| loading is already started by another
223 // RemoteFontFaceSource instance, classify as memory cache hit.
224 m_histograms.maySetDataSource(FontLoadHistograms::FromMemoryCache);
221 } 225 }
222 m_font->startLoadLimitTimersIfNeeded(); 226 m_font->startLoadLimitTimersIfNeeded();
223 227
224 if (m_face) 228 if (m_face)
225 m_face->didBeginLoad(); 229 m_face->didBeginLoad();
226 } 230 }
227 231
228 DEFINE_TRACE(RemoteFontFaceSource) 232 DEFINE_TRACE(RemoteFontFaceSource)
229 { 233 {
230 visitor->trace(m_font); 234 visitor->trace(m_font);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 blankTextShownTimeHistogram.count(duration); 272 blankTextShownTimeHistogram.count(duration);
269 m_blankPaintTime = -1; 273 m_blankPaintTime = -1;
270 } 274 }
271 275
272 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour ce* font) 276 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour ce* font)
273 { 277 {
274 DEFINE_STATIC_LOCAL(EnumerationHistogram, cacheHitHistogram, ("WebFont.Cache Hit", CacheHitEnumMax)); 278 DEFINE_STATIC_LOCAL(EnumerationHistogram, cacheHitHistogram, ("WebFont.Cache Hit", CacheHitEnumMax));
275 cacheHitHistogram.count(dataSourceMetricsValue()); 279 cacheHitHistogram.count(dataSourceMetricsValue());
276 280
277 if (m_dataSource == FromDiskCache || m_dataSource == FromNetwork) { 281 if (m_dataSource == FromDiskCache || m_dataSource == FromNetwork) {
282 DCHECK(m_loadStartTime);
kouhei (in TOK) 2016/09/23 01:33:59 using DCHECK on double scares me a bit. DCHECK_LT(
Shao-Chuan Lee 2016/09/23 01:47:19 Checking if non-zero should suffice here, maybe I
kouhei (in TOK) 2016/09/30 01:18:35 DCHECK_NE(m_loadStartTime, 0.0) is also OK.
278 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime); 283 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime);
279 recordLoadTimeHistogram(font, duration); 284 recordLoadTimeHistogram(font, duration);
280 285
281 enum { CORSFail, CORSSuccess, CORSEnumMax }; 286 enum { CORSFail, CORSSuccess, CORSEnumMax };
282 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess; 287 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess;
283 DEFINE_STATIC_LOCAL(EnumerationHistogram, corsHistogram, ("WebFont.CORSS uccess", CORSEnumMax)); 288 DEFINE_STATIC_LOCAL(EnumerationHistogram, corsHistogram, ("WebFont.CORSS uccess", CORSEnumMax));
284 corsHistogram.count(corsValue); 289 corsHistogram.count(corsValue);
285 } 290 }
286 } 291 }
287 292
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return Miss; 375 return Miss;
371 case FromUnknown: 376 case FromUnknown:
372 // Fall through. 377 // Fall through.
373 default: 378 default:
374 NOTREACHED(); 379 NOTREACHED();
375 } 380 }
376 return Miss; 381 return Miss;
377 } 382 }
378 383
379 } // namespace blink 384 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698