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 "core/css/LocalFontFaceSource.h" | 5 #include "core/css/LocalFontFaceSource.h" |
6 | 6 |
7 #include "platform/Histogram.h" | 7 #include "platform/Histogram.h" |
8 #include "platform/fonts/FontCache.h" | 8 #include "platform/fonts/FontCache.h" |
9 #include "platform/fonts/FontDescription.h" | 9 #include "platform/fonts/FontDescription.h" |
10 #include "platform/fonts/SimpleFontData.h" | 10 #include "platform/fonts/SimpleFontData.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 bool LocalFontFaceSource::isLocalFontAvailable( | 14 bool LocalFontFaceSource::isLocalFontAvailable( |
15 const FontDescription& fontDescription) { | 15 const FontDescription& fontDescription) { |
16 return FontCache::fontCache()->isPlatformFontAvailable(fontDescription, | 16 return FontCache::fontCache()->isPlatformFontAvailable(fontDescription, |
17 m_fontName); | 17 m_fontName); |
18 } | 18 } |
19 | 19 |
20 PassRefPtr<SimpleFontData> LocalFontFaceSource::createFontData( | 20 PassRefPtr<SimpleFontData> LocalFontFaceSource::createFontData( |
21 const FontDescription& fontDescription) { | 21 const FontDescription& fontDescription) { |
22 // We don't want to check alternate font family names here, so pass true as th
e checkingAlternateName parameter. | 22 // We don't want to check alternate font family names here, so pass true as |
| 23 // the checkingAlternateName parameter. |
23 RefPtr<SimpleFontData> fontData = | 24 RefPtr<SimpleFontData> fontData = |
24 FontCache::fontCache()->getFontData(fontDescription, m_fontName, true); | 25 FontCache::fontCache()->getFontData(fontDescription, m_fontName, true); |
25 m_histograms.record(fontData.get()); | 26 m_histograms.record(fontData.get()); |
26 return fontData.release(); | 27 return fontData.release(); |
27 } | 28 } |
28 | 29 |
29 void LocalFontFaceSource::LocalFontHistograms::record(bool loadSuccess) { | 30 void LocalFontFaceSource::LocalFontHistograms::record(bool loadSuccess) { |
30 if (m_reported) | 31 if (m_reported) |
31 return; | 32 return; |
32 m_reported = true; | 33 m_reported = true; |
33 DEFINE_STATIC_LOCAL(EnumerationHistogram, localFontUsedHistogram, | 34 DEFINE_STATIC_LOCAL(EnumerationHistogram, localFontUsedHistogram, |
34 ("WebFont.LocalFontUsed", 2)); | 35 ("WebFont.LocalFontUsed", 2)); |
35 localFontUsedHistogram.count(loadSuccess ? 1 : 0); | 36 localFontUsedHistogram.count(loadSuccess ? 1 : 0); |
36 } | 37 } |
37 | 38 |
38 } // namespace blink | 39 } // namespace blink |
OLD | NEW |