| 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()->isPlatformFontUniqueNameMatchAvailable( |
| 17 m_fontName); | 17 fontDescription, 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 | |
| 23 // the checkingAlternateName parameter. | |
| 24 RefPtr<SimpleFontData> fontData = FontCache::fontCache()->getFontData( | 22 RefPtr<SimpleFontData> fontData = FontCache::fontCache()->getFontData( |
| 25 fontDescription, m_fontName, AlternateFontName::NoAlternate); | 23 fontDescription, m_fontName, AlternateFontName::LocalUniqueFace); |
| 26 m_histograms.record(fontData.get()); | 24 m_histograms.record(fontData.get()); |
| 27 return fontData.release(); | 25 return fontData.release(); |
| 28 } | 26 } |
| 29 | 27 |
| 30 void LocalFontFaceSource::LocalFontHistograms::record(bool loadSuccess) { | 28 void LocalFontFaceSource::LocalFontHistograms::record(bool loadSuccess) { |
| 31 if (m_reported) | 29 if (m_reported) |
| 32 return; | 30 return; |
| 33 m_reported = true; | 31 m_reported = true; |
| 34 DEFINE_STATIC_LOCAL(EnumerationHistogram, localFontUsedHistogram, | 32 DEFINE_STATIC_LOCAL(EnumerationHistogram, localFontUsedHistogram, |
| 35 ("WebFont.LocalFontUsed", 2)); | 33 ("WebFont.LocalFontUsed", 2)); |
| 36 localFontUsedHistogram.count(loadSuccess ? 1 : 0); | 34 localFontUsedHistogram.count(loadSuccess ? 1 : 0); |
| 37 } | 35 } |
| 38 | 36 |
| 39 } // namespace blink | 37 } // namespace blink |
| OLD | NEW |