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

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

Issue 1659053002: Remove custom counts histogram from the blink API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a few thread_safe_static_local -> static_local as per feedback in reviews Created 4 years, 10 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
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/FontLoader.h" 9 #include "core/css/FontLoader.h"
10 #include "core/page/NetworkStateNotifier.h" 10 #include "core/page/NetworkStateNotifier.h"
11 #include "platform/Histogram.h"
11 #include "platform/RuntimeEnabledFeatures.h" 12 #include "platform/RuntimeEnabledFeatures.h"
12 #include "platform/fonts/FontCache.h" 13 #include "platform/fonts/FontCache.h"
13 #include "platform/fonts/FontDescription.h" 14 #include "platform/fonts/FontDescription.h"
14 #include "platform/fonts/SimpleFontData.h" 15 #include "platform/fonts/SimpleFontData.h"
15 #include "public/platform/Platform.h" 16 #include "public/platform/Platform.h"
16 #include "wtf/CurrentTime.h" 17 #include "wtf/CurrentTime.h"
17 18
18 namespace blink { 19 namespace blink {
19 20
20 RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, PassRefPtrWillBeR awPtr<FontLoader> fontLoader, FontDisplay display) 21 RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, PassRefPtrWillBeR awPtr<FontLoader> fontLoader, FontDisplay display)
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 { 213 {
213 m_isLongLimitExceeded = true; 214 m_isLongLimitExceeded = true;
214 recordInterventionResult(isInterventionTriggered); 215 recordInterventionResult(isInterventionTriggered);
215 } 216 }
216 217
217 void RemoteFontFaceSource::FontLoadHistograms::recordFallbackTime(const FontReso urce* font) 218 void RemoteFontFaceSource::FontLoadHistograms::recordFallbackTime(const FontReso urce* font)
218 { 219 {
219 if (m_fallbackPaintTime <= 0) 220 if (m_fallbackPaintTime <= 0)
220 return; 221 return;
221 int duration = static_cast<int>(currentTimeMS() - m_fallbackPaintTime); 222 int duration = static_cast<int>(currentTimeMS() - m_fallbackPaintTime);
222 Platform::current()->histogramCustomCounts("WebFont.BlankTextShownTime", dur ation, 0, 10000, 50); 223 DEFINE_STATIC_LOCAL(CustomCountHistogram, blankTextShownTimeHistogram, ("Web Font.BlankTextShownTime", 0, 10000, 50));
224 blankTextShownTimeHistogram.count(duration);
223 m_fallbackPaintTime = -1; 225 m_fallbackPaintTime = -1;
224 } 226 }
225 227
226 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour ce* font) 228 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour ce* font)
227 { 229 {
228 if (m_loadStartTime > 0 && font && !font->isLoading()) { 230 if (m_loadStartTime > 0 && font && !font->isLoading()) {
229 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime); 231 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime);
230 Platform::current()->histogramCustomCounts(histogramName(font), duration , 0, 10000, 50); 232 recordLoadTimeHistogram(font, duration);
231 m_loadStartTime = -1; 233 m_loadStartTime = -1;
232 234
233 enum { Miss, Hit, DataUrl, CacheHitEnumMax }; 235 enum { Miss, Hit, DataUrl, CacheHitEnumMax };
234 int histogramValue = font->url().protocolIsData() ? DataUrl 236 int histogramValue = font->url().protocolIsData() ? DataUrl
235 : font->response().wasCached() ? Hit 237 : font->response().wasCached() ? Hit
236 : Miss; 238 : Miss;
237 Platform::current()->histogramEnumeration("WebFont.CacheHit", histogramV alue, CacheHitEnumMax); 239 Platform::current()->histogramEnumeration("WebFont.CacheHit", histogramV alue, CacheHitEnumMax);
238 240
239 enum { CORSFail, CORSSuccess, CORSEnumMax }; 241 enum { CORSFail, CORSSuccess, CORSEnumMax };
240 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess; 242 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess;
241 Platform::current()->histogramEnumeration("WebFont.CORSSuccess", corsVal ue, CORSEnumMax); 243 Platform::current()->histogramEnumeration("WebFont.CORSSuccess", corsVal ue, CORSEnumMax);
242 } 244 }
243 } 245 }
244 246
245 const char* RemoteFontFaceSource::FontLoadHistograms::histogramName(const FontRe source* font) 247 void RemoteFontFaceSource::FontLoadHistograms::recordLoadTimeHistogram(const Fon tResource* font, int duration)
246 { 248 {
247 if (font->errorOccurred()) 249 if (font->errorOccurred()) {
248 return "WebFont.DownloadTime.LoadError"; 250 DEFINE_STATIC_LOCAL(CustomCountHistogram, loadErrorHistogram, ("WebFont. DownloadTime.LoadError", 0, 10000, 50));
251 loadErrorHistogram.count(duration);
252 return;
253 }
249 254
250 unsigned size = font->encodedSize(); 255 unsigned size = font->encodedSize();
251 if (size < 10 * 1024) 256 if (size < 10 * 1024) {
252 return "WebFont.DownloadTime.0.Under10KB"; 257 DEFINE_STATIC_LOCAL(CustomCountHistogram, under10kHistogram, ("WebFont.D ownloadTime.0.Under10KB", 0, 10000, 50));
253 if (size < 50 * 1024) 258 under10kHistogram.count(duration);
254 return "WebFont.DownloadTime.1.10KBTo50KB"; 259 return;
255 if (size < 100 * 1024) 260 }
256 return "WebFont.DownloadTime.2.50KBTo100KB"; 261 if (size < 50 * 1024) {
257 if (size < 1024 * 1024) 262 DEFINE_STATIC_LOCAL(CustomCountHistogram, under50kHistogram, ("WebFont.D ownloadTime.1.10KBTo50KB", 0, 10000, 50));
258 return "WebFont.DownloadTime.3.100KBTo1MB"; 263 under50kHistogram.count(duration);
259 return "WebFont.DownloadTime.4.Over1MB"; 264 return;
265 }
266 if (size < 100 * 1024) {
267 DEFINE_STATIC_LOCAL(CustomCountHistogram, under100kHistogram, ("WebFont. DownloadTime.2.50KBTo100KB", 0, 10000, 50));
268 under100kHistogram.count(duration);
269 return;
270 }
271 if (size < 1024 * 1024) {
272 DEFINE_STATIC_LOCAL(CustomCountHistogram, under1mbHistogram, ("WebFont.D ownloadTime.3.100KBTo1MB", 0, 10000, 50));
273 under1mbHistogram.count(duration);
274 return;
275 }
276 DEFINE_STATIC_LOCAL(CustomCountHistogram, over1mbHistogram, ("WebFont.Downlo adTime.4.Over1MB", 0, 10000, 50));
277 over1mbHistogram.count(duration);
260 } 278 }
261 279
262 void RemoteFontFaceSource::FontLoadHistograms::recordInterventionResult(bool tri ggered) 280 void RemoteFontFaceSource::FontLoadHistograms::recordInterventionResult(bool tri ggered)
263 { 281 {
264 if (!RuntimeEnabledFeatures::webFontsInterventionEnabled()) 282 if (!RuntimeEnabledFeatures::webFontsInterventionEnabled())
265 return; 283 return;
266 // interventionResult takes 0-3 values. 284 // interventionResult takes 0-3 values.
267 int interventionResult = 0; 285 int interventionResult = 0;
268 if (m_isLongLimitExceeded) 286 if (m_isLongLimitExceeded)
269 interventionResult |= 1 << 0; 287 interventionResult |= 1 << 0;
270 if (triggered) 288 if (triggered)
271 interventionResult |= 1 << 1; 289 interventionResult |= 1 << 1;
272 const int boundary = 1 << 2; 290 const int boundary = 1 << 2;
273 Platform::current()->histogramEnumeration("WebFont.InterventionResult", inte rventionResult, boundary); 291 Platform::current()->histogramEnumeration("WebFont.InterventionResult", inte rventionResult, boundary);
274 } 292 }
275 293
276 } // namespace blink 294 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698