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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 void FontResource::beginLoadIfNeeded(ResourceFetcher* dl) | 73 void FontResource::beginLoadIfNeeded(ResourceFetcher* dl) |
74 { | 74 { |
75 if (!m_loadInitiated) { | 75 if (!m_loadInitiated) { |
76 m_loadInitiated = true; | 76 m_loadInitiated = true; |
77 Resource::load(dl, m_options); | 77 Resource::load(dl, m_options); |
78 | 78 |
79 ResourceClientWalker<FontResourceClient> walker(m_clients); | 79 ResourceClientWalker<FontResourceClient> walker(m_clients); |
80 while (FontResourceClient* client = walker.next()) | 80 while (FontResourceClient* client = walker.next()) |
81 client->didStartFontLoad(this); | 81 client->didStartFontLoad(this); |
82 m_histograms.loadStarted(); | |
83 } | 82 } |
84 } | 83 } |
85 | 84 |
86 bool FontResource::ensureCustomFontData() | 85 bool FontResource::ensureCustomFontData() |
87 { | 86 { |
88 if (!m_fontData && !errorOccurred() && !isLoading() && m_data) { | 87 if (!m_fontData && !errorOccurred() && !isLoading() && m_data) { |
89 m_fontData = FontCustomPlatformData::create(m_data.get()); | 88 m_fontData = FontCustomPlatformData::create(m_data.get()); |
90 if (!m_fontData) | 89 if (!m_fontData) |
91 setStatus(DecodeError); | 90 setStatus(DecodeError); |
92 } | 91 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 Resource::allClientsRemoved(); | 157 Resource::allClientsRemoved(); |
159 } | 158 } |
160 | 159 |
161 void FontResource::checkNotify() | 160 void FontResource::checkNotify() |
162 { | 161 { |
163 ResourceClientWalker<FontResourceClient> w(m_clients); | 162 ResourceClientWalker<FontResourceClient> w(m_clients); |
164 while (FontResourceClient* c = w.next()) | 163 while (FontResourceClient* c = w.next()) |
165 c->fontLoaded(this); | 164 c->fontLoaded(this); |
166 } | 165 } |
167 | 166 |
168 void FontResource::willUseFontData() | |
169 { | |
170 if (!isLoaded()) | |
171 m_histograms.willUseFontData(); | |
172 } | 167 } |
173 | |
174 FontResource::FontResourceHistograms::~FontResourceHistograms() | |
175 { | |
176 if (m_styledTime > 0) | |
177 blink::Platform::current()->histogramEnumeration("WebFont.Resource.Usage
Type", StyledButNotUsed, 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 blink::Platform::current()->histogramEnumeration("WebFont.Resource.Usage
Type", NotStyledButUsed, UsageTypeMax); | |
192 } else { | |
193 int duration = static_cast<int>(currentTimeMS() - m_styledTime); | |
194 blink::Platform::current()->histogramCustomCounts("WebFont.Resource.Styl
eRecalcToDownloadLatency", duration, 0, 10000, 50); | |
195 blink::Platform::current()->histogramEnumeration("WebFont.Resource.Usage
Type", StyledAndUsed, UsageTypeMax); | |
196 } | |
197 m_styledTime = -1; | |
198 } | |
199 | |
200 } | |
OLD | NEW |