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 "config.h" | 5 #include "config.h" |
6 #include "core/css/RemoteFontFaceSource.h" | 6 #include "core/css/RemoteFontFaceSource.h" |
7 | 7 |
8 #include "core/css/CSSCustomFontData.h" | 8 #include "core/css/CSSCustomFontData.h" |
9 #include "core/css/CSSFontFace.h" | 9 #include "core/css/CSSFontFace.h" |
10 #include "core/css/FontLoader.h" | 10 #include "core/css/FontLoader.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 { | 146 { |
147 if (!m_fallbackPaintTime) | 147 if (!m_fallbackPaintTime) |
148 m_fallbackPaintTime = currentTimeMS(); | 148 m_fallbackPaintTime = currentTimeMS(); |
149 } | 149 } |
150 | 150 |
151 void RemoteFontFaceSource::FontLoadHistograms::recordFallbackTime(const FontReso
urce* font) | 151 void RemoteFontFaceSource::FontLoadHistograms::recordFallbackTime(const FontReso
urce* font) |
152 { | 152 { |
153 if (m_fallbackPaintTime <= 0) | 153 if (m_fallbackPaintTime <= 0) |
154 return; | 154 return; |
155 int duration = static_cast<int>(currentTimeMS() - m_fallbackPaintTime); | 155 int duration = static_cast<int>(currentTimeMS() - m_fallbackPaintTime); |
156 blink::Platform::current()->histogramCustomCounts("WebFont.BlankTextShownTim
e", duration, 0, 10000, 50); | 156 Platform::current()->histogramCustomCounts("WebFont.BlankTextShownTime", dur
ation, 0, 10000, 50); |
157 m_fallbackPaintTime = -1; | 157 m_fallbackPaintTime = -1; |
158 } | 158 } |
159 | 159 |
160 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour
ce* font) | 160 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour
ce* font) |
161 { | 161 { |
162 if (m_loadStartTime > 0 && font && !font->isLoading()) { | 162 if (m_loadStartTime > 0 && font && !font->isLoading()) { |
163 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime); | 163 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime); |
164 blink::Platform::current()->histogramCustomCounts(histogramName(font), d
uration, 0, 10000, 50); | 164 Platform::current()->histogramCustomCounts(histogramName(font), duration
, 0, 10000, 50); |
165 m_loadStartTime = -1; | 165 m_loadStartTime = -1; |
166 | 166 |
167 enum { Miss, Hit, DataUrl, CacheHitEnumMax }; | 167 enum { Miss, Hit, DataUrl, CacheHitEnumMax }; |
168 int histogramValue = font->url().protocolIsData() ? DataUrl | 168 int histogramValue = font->url().protocolIsData() ? DataUrl |
169 : font->response().wasCached() ? Hit | 169 : font->response().wasCached() ? Hit |
170 : Miss; | 170 : Miss; |
171 blink::Platform::current()->histogramEnumeration("WebFont.CacheHit", his
togramValue, CacheHitEnumMax); | 171 Platform::current()->histogramEnumeration("WebFont.CacheHit", histogramV
alue, CacheHitEnumMax); |
172 | 172 |
173 enum { CORSFail, CORSSuccess, CORSEnumMax }; | 173 enum { CORSFail, CORSSuccess, CORSEnumMax }; |
174 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess; | 174 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess; |
175 blink::Platform::current()->histogramEnumeration("WebFont.CORSSuccess",
corsValue, CORSEnumMax); | 175 Platform::current()->histogramEnumeration("WebFont.CORSSuccess", corsVal
ue, CORSEnumMax); |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 const char* RemoteFontFaceSource::FontLoadHistograms::histogramName(const FontRe
source* font) | 179 const char* RemoteFontFaceSource::FontLoadHistograms::histogramName(const FontRe
source* font) |
180 { | 180 { |
181 if (font->errorOccurred()) | 181 if (font->errorOccurred()) |
182 return "WebFont.DownloadTime.LoadError"; | 182 return "WebFont.DownloadTime.LoadError"; |
183 | 183 |
184 unsigned size = font->encodedSize(); | 184 unsigned size = font->encodedSize(); |
185 if (size < 10 * 1024) | 185 if (size < 10 * 1024) |
186 return "WebFont.DownloadTime.0.Under10KB"; | 186 return "WebFont.DownloadTime.0.Under10KB"; |
187 if (size < 50 * 1024) | 187 if (size < 50 * 1024) |
188 return "WebFont.DownloadTime.1.10KBTo50KB"; | 188 return "WebFont.DownloadTime.1.10KBTo50KB"; |
189 if (size < 100 * 1024) | 189 if (size < 100 * 1024) |
190 return "WebFont.DownloadTime.2.50KBTo100KB"; | 190 return "WebFont.DownloadTime.2.50KBTo100KB"; |
191 if (size < 1024 * 1024) | 191 if (size < 1024 * 1024) |
192 return "WebFont.DownloadTime.3.100KBTo1MB"; | 192 return "WebFont.DownloadTime.3.100KBTo1MB"; |
193 return "WebFont.DownloadTime.4.Over1MB"; | 193 return "WebFont.DownloadTime.4.Over1MB"; |
194 } | 194 } |
195 | 195 |
196 } // namespace blink | 196 } // namespace blink |
OLD | NEW |