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 #ifndef RemoteFontFaceSource_h | 5 #ifndef RemoteFontFaceSource_h |
6 #define RemoteFontFaceSource_h | 6 #define RemoteFontFaceSource_h |
7 | 7 |
8 #include "core/css/CSSFontFaceSource.h" | 8 #include "core/css/CSSFontFaceSource.h" |
9 #include "core/loader/resource/FontResource.h" | 9 #include "core/loader/resource/FontResource.h" |
10 #include "wtf/Allocator.h" | 10 #include "wtf/Allocator.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 class CSSFontSelector; | 14 class CSSFontSelector; |
| 15 class FontCustomPlatformData; |
15 | 16 |
16 enum FontDisplay { | 17 enum FontDisplay { |
17 FontDisplayAuto, | 18 FontDisplayAuto, |
18 FontDisplayBlock, | 19 FontDisplayBlock, |
19 FontDisplaySwap, | 20 FontDisplaySwap, |
20 FontDisplayFallback, | 21 FontDisplayFallback, |
21 FontDisplayOptional, | 22 FontDisplayOptional, |
22 FontDisplayEnumMax | 23 FontDisplayEnumMax |
23 }; | 24 }; |
24 | 25 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 m_blankPaintTime(0), | 82 m_blankPaintTime(0), |
82 m_isLongLimitExceeded(false), | 83 m_isLongLimitExceeded(false), |
83 m_dataSource(dataSource), | 84 m_dataSource(dataSource), |
84 m_fontDisplay(fontDisplay) {} | 85 m_fontDisplay(fontDisplay) {} |
85 void loadStarted(); | 86 void loadStarted(); |
86 void fallbackFontPainted(DisplayPeriod); | 87 void fallbackFontPainted(DisplayPeriod); |
87 void fontLoaded(bool isCorsFailed, | 88 void fontLoaded(bool isCorsFailed, |
88 bool loadError, | 89 bool loadError, |
89 bool isInterventionTriggered); | 90 bool isInterventionTriggered); |
90 void longLimitExceeded(bool isInterventionTriggered); | 91 void longLimitExceeded(bool isInterventionTriggered); |
91 void recordFallbackTime(const FontResource*); | 92 void recordFallbackTime(); |
92 void recordRemoteFont(const FontResource*, bool isInterventionTriggered); | 93 void recordRemoteFont(const FontResource*, bool isInterventionTriggered); |
93 bool hadBlankText() { return m_blankPaintTime; } | 94 bool hadBlankText() { return m_blankPaintTime; } |
94 DataSource dataSource() { return m_dataSource; } | 95 DataSource dataSource() { return m_dataSource; } |
95 void maySetDataSource(DataSource); | 96 void maySetDataSource(DataSource); |
96 | 97 |
97 private: | 98 private: |
98 void recordLoadTimeHistogram(const FontResource*, | 99 void recordLoadTimeHistogram(const FontResource*, |
99 int duration, | 100 int duration, |
100 bool isInterventionTriggered); | 101 bool isInterventionTriggered); |
101 void recordInterventionResult(bool isTriggered); | 102 void recordInterventionResult(bool isTriggered); |
102 CacheHitMetrics dataSourceMetricsValue(); | 103 CacheHitMetrics dataSourceMetricsValue(); |
103 double m_loadStartTime; | 104 double m_loadStartTime; |
104 double m_blankPaintTime; | 105 double m_blankPaintTime; |
105 bool m_isLongLimitExceeded; | 106 bool m_isLongLimitExceeded; |
106 DataSource m_dataSource; | 107 DataSource m_dataSource; |
107 FontDisplay m_fontDisplay; | 108 FontDisplay m_fontDisplay; |
108 }; | 109 }; |
109 | 110 |
110 void switchToSwapPeriod(); | 111 void switchToSwapPeriod(); |
111 void switchToFailurePeriod(); | 112 void switchToFailurePeriod(); |
112 bool shouldTriggerWebFontsIntervention(); | 113 bool shouldTriggerWebFontsIntervention(); |
113 bool isLowPriorityLoadingAllowedForRemoteFont() const override; | 114 bool isLowPriorityLoadingAllowedForRemoteFont() const override; |
114 | 115 |
| 116 // Cleared once load is finished. |
115 Member<FontResource> m_font; | 117 Member<FontResource> m_font; |
| 118 |
116 Member<CSSFontSelector> m_fontSelector; | 119 Member<CSSFontSelector> m_fontSelector; |
| 120 |
| 121 // |nullptr| if font is not loaded or failed to decode. |
| 122 RefPtr<FontCustomPlatformData> m_customFontData; |
| 123 |
117 const FontDisplay m_display; | 124 const FontDisplay m_display; |
118 DisplayPeriod m_period; | 125 DisplayPeriod m_period; |
119 FontLoadHistograms m_histograms; | 126 FontLoadHistograms m_histograms; |
120 bool m_isInterventionTriggered; | 127 bool m_isInterventionTriggered; |
121 }; | 128 }; |
122 | 129 |
123 } // namespace blink | 130 } // namespace blink |
124 | 131 |
125 #endif | 132 #endif |
OLD | NEW |