OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Torch Mobile, Inc. | 3 * Copyright (C) 2009 Torch Mobile, Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 12 matching lines...) Expand all Loading... |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #include "core/fetch/FontResource.h" | 28 #include "core/fetch/FontResource.h" |
29 | 29 |
30 #include "core/fetch/ResourceClient.h" | 30 #include "core/fetch/ResourceClient.h" |
31 #include "core/fetch/ResourceClientWalker.h" | 31 #include "core/fetch/ResourceClientWalker.h" |
32 #include "core/fetch/TextResourceDecoder.h" | 32 #include "core/fetch/TextResourceDecoder.h" |
| 33 #include "core/platform/HistogramSupport.h" |
33 #include "core/platform/SharedBuffer.h" | 34 #include "core/platform/SharedBuffer.h" |
34 #include "core/platform/graphics/FontCustomPlatformData.h" | 35 #include "core/platform/graphics/FontCustomPlatformData.h" |
35 #include "core/platform/graphics/FontPlatformData.h" | 36 #include "core/platform/graphics/FontPlatformData.h" |
| 37 #include "wtf/CurrentTime.h" |
36 | 38 |
37 #if ENABLE(SVG_FONTS) | 39 #if ENABLE(SVG_FONTS) |
38 #include "SVGNames.h" | 40 #include "SVGNames.h" |
39 #include "core/dom/NodeList.h" | 41 #include "core/dom/NodeList.h" |
40 #include "core/svg/SVGDocument.h" | 42 #include "core/svg/SVGDocument.h" |
41 #include "core/svg/SVGFontElement.h" | 43 #include "core/svg/SVGFontElement.h" |
42 #endif | 44 #endif |
43 | 45 |
44 namespace WebCore { | 46 namespace WebCore { |
45 | 47 |
(...skipping 24 matching lines...) Expand all Loading... |
70 | 72 |
71 void FontResource::beginLoadIfNeeded(ResourceFetcher* dl) | 73 void FontResource::beginLoadIfNeeded(ResourceFetcher* dl) |
72 { | 74 { |
73 if (!m_loadInitiated) { | 75 if (!m_loadInitiated) { |
74 m_loadInitiated = true; | 76 m_loadInitiated = true; |
75 Resource::load(dl, m_options); | 77 Resource::load(dl, m_options); |
76 | 78 |
77 ResourceClientWalker<FontResourceClient> walker(m_clients); | 79 ResourceClientWalker<FontResourceClient> walker(m_clients); |
78 while (FontResourceClient* client = walker.next()) | 80 while (FontResourceClient* client = walker.next()) |
79 client->didStartFontLoad(this); | 81 client->didStartFontLoad(this); |
| 82 m_histograms.loadStarted(); |
80 } | 83 } |
81 } | 84 } |
82 | 85 |
83 bool FontResource::ensureCustomFontData() | 86 bool FontResource::ensureCustomFontData() |
84 { | 87 { |
85 if (!m_fontData && !errorOccurred() && !isLoading() && m_data) { | 88 if (!m_fontData && !errorOccurred() && !isLoading() && m_data) { |
86 m_fontData = FontCustomPlatformData::create(m_data.get()); | 89 m_fontData = FontCustomPlatformData::create(m_data.get()); |
87 if (!m_fontData) | 90 if (!m_fontData) |
88 setStatus(DecodeError); | 91 setStatus(DecodeError); |
89 } | 92 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 Resource::allClientsRemoved(); | 158 Resource::allClientsRemoved(); |
156 } | 159 } |
157 | 160 |
158 void FontResource::checkNotify() | 161 void FontResource::checkNotify() |
159 { | 162 { |
160 ResourceClientWalker<FontResourceClient> w(m_clients); | 163 ResourceClientWalker<FontResourceClient> w(m_clients); |
161 while (FontResourceClient* c = w.next()) | 164 while (FontResourceClient* c = w.next()) |
162 c->fontLoaded(this); | 165 c->fontLoaded(this); |
163 } | 166 } |
164 | 167 |
| 168 void FontResource::willUseFontData() |
| 169 { |
| 170 if (!isLoaded()) |
| 171 m_histograms.willUseFontData(); |
165 } | 172 } |
| 173 |
| 174 FontResource::FontResourceHistograms::~FontResourceHistograms() |
| 175 { |
| 176 if (m_styledTime > 0) |
| 177 HistogramSupport::histogramEnumeration("WebFont.Resource.UsageType", Sty
ledButNotUsed, UsageTypeMax); |
| 178 } |
| 179 |
| 180 void FontResource::FontResourceHistograms::willUseFontData() |
| 181 { |
| 182 if (!m_styledTime) |
| 183 m_styledTime = currentTimeMS(); |
| 184 } |
| 185 |
| 186 void FontResource::FontResourceHistograms::loadStarted() |
| 187 { |
| 188 if (m_styledTime < 0) |
| 189 return; |
| 190 if (!m_styledTime) { |
| 191 HistogramSupport::histogramEnumeration("WebFont.Resource.UsageType", Not
StyledButUsed, UsageTypeMax); |
| 192 } else { |
| 193 int duration = static_cast<int>(currentTimeMS() - m_styledTime); |
| 194 HistogramSupport::histogramCustomCounts("WebFont.Resource.StyleRecalcToD
ownloadLatency", duration, 0, 10000, 50); |
| 195 HistogramSupport::histogramEnumeration("WebFont.Resource.UsageType", Sty
ledAndUsed, UsageTypeMax); |
| 196 } |
| 197 m_styledTime = -1; |
| 198 } |
| 199 |
| 200 } |
OLD | NEW |