| 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& font_description) { | 15 const FontDescription& font_description) { |
| 16 return FontCache::GetFontCache()->IsPlatformFontUniqueNameMatchAvailable( | 16 return FontCache::GetFontCache()->IsPlatformFontUniqueNameMatchAvailable( |
| 17 font_description, font_name_); | 17 font_description, font_name_); |
| 18 } | 18 } |
| 19 | 19 |
| 20 PassRefPtr<SimpleFontData> LocalFontFaceSource::CreateFontData( | 20 PassRefPtr<SimpleFontData> LocalFontFaceSource::CreateFontData( |
| 21 const FontDescription& font_description) { | 21 const FontDescription& font_description) { |
| 22 RefPtr<SimpleFontData> font_data = FontCache::GetFontCache()->GetFontData( | 22 RefPtr<SimpleFontData> font_data = FontCache::GetFontCache()->GetFontData( |
| 23 font_description, font_name_, AlternateFontName::kLocalUniqueFace); | 23 font_description, font_name_, AlternateFontName::kLocalUniqueFace); |
| 24 histograms_.Record(font_data.Get()); | 24 histograms_.Record(font_data.Get()); |
| 25 return font_data.Release(); | 25 return font_data; |
| 26 } | 26 } |
| 27 | 27 |
| 28 void LocalFontFaceSource::LocalFontHistograms::Record(bool load_success) { | 28 void LocalFontFaceSource::LocalFontHistograms::Record(bool load_success) { |
| 29 if (reported_) | 29 if (reported_) |
| 30 return; | 30 return; |
| 31 reported_ = true; | 31 reported_ = true; |
| 32 DEFINE_STATIC_LOCAL(EnumerationHistogram, local_font_used_histogram, | 32 DEFINE_STATIC_LOCAL(EnumerationHistogram, local_font_used_histogram, |
| 33 ("WebFont.LocalFontUsed", 2)); | 33 ("WebFont.LocalFontUsed", 2)); |
| 34 local_font_used_histogram.Count(load_success ? 1 : 0); | 34 local_font_used_histogram.Count(load_success ? 1 : 0); |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // namespace blink | 37 } // namespace blink |
| OLD | NEW |