Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Side by Side Diff: third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp

Issue 2769183003: Lower the webfont loading priority only if the user is in V2 field trial (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/RemoteFontFaceSource.h" 5 #include "core/css/RemoteFontFaceSource.h"
6 6
7 #include "core/css/CSSCustomFontData.h" 7 #include "core/css/CSSCustomFontData.h"
8 #include "core/css/CSSFontFace.h" 8 #include "core/css/CSSFontFace.h"
9 #include "core/css/CSSFontSelector.h" 9 #include "core/css/CSSFontSelector.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 DCHECK_NE(WebEffectiveConnectionType::TypeUnknown, thresholdType); 42 DCHECK_NE(WebEffectiveConnectionType::TypeUnknown, thresholdType);
43 43
44 return WebEffectiveConnectionType::TypeOffline <= type && 44 return WebEffectiveConnectionType::TypeOffline <= type &&
45 type <= thresholdType; 45 type <= thresholdType;
46 } 46 }
47 47
48 bool isConnectionTypeSlow() { 48 bool isConnectionTypeSlow() {
49 return networkStateNotifier().connectionType() == WebConnectionTypeCellular2G; 49 return networkStateNotifier().connectionType() == WebConnectionTypeCellular2G;
50 } 50 }
51 51
52 bool isInterventionV2Enabled() {
53 return RuntimeEnabledFeatures::webFontsInterventionV2With2GEnabled() ||
54 RuntimeEnabledFeatures::webFontsInterventionV2With3GEnabled() ||
55 RuntimeEnabledFeatures::webFontsInterventionV2WithSlow2GEnabled();
56 }
57
52 } // namespace 58 } // namespace
53 59
54 RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font, 60 RemoteFontFaceSource::RemoteFontFaceSource(FontResource* font,
55 CSSFontSelector* fontSelector, 61 CSSFontSelector* fontSelector,
56 FontDisplay display) 62 FontDisplay display)
57 : m_font(font), 63 : m_font(font),
58 m_fontSelector(fontSelector), 64 m_fontSelector(fontSelector),
59 m_display(display), 65 m_display(display),
60 m_period(display == FontDisplaySwap ? SwapPeriod : BlockPeriod), 66 m_period(display == FontDisplaySwap ? SwapPeriod : BlockPeriod),
61 m_histograms(font->url().protocolIsData() 67 m_histograms(font->url().protocolIsData()
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 m_period = FailurePeriod; 187 m_period = FailurePeriod;
182 } 188 }
183 189
184 bool RemoteFontFaceSource::shouldTriggerWebFontsIntervention() { 190 bool RemoteFontFaceSource::shouldTriggerWebFontsIntervention() {
185 if (RuntimeEnabledFeatures::webFontsInterventionTriggerEnabled()) 191 if (RuntimeEnabledFeatures::webFontsInterventionTriggerEnabled())
186 return true; 192 return true;
187 if (m_histograms.dataSource() == FontLoadHistograms::FromMemoryCache || 193 if (m_histograms.dataSource() == FontLoadHistograms::FromMemoryCache ||
188 m_histograms.dataSource() == FontLoadHistograms::FromDataURL) 194 m_histograms.dataSource() == FontLoadHistograms::FromDataURL)
189 return false; 195 return false;
190 196
191 bool isV2Enabled =
192 RuntimeEnabledFeatures::webFontsInterventionV2With2GEnabled() ||
193 RuntimeEnabledFeatures::webFontsInterventionV2With3GEnabled() ||
194 RuntimeEnabledFeatures::webFontsInterventionV2WithSlow2GEnabled();
195
196 bool networkIsSlow = 197 bool networkIsSlow =
197 isV2Enabled ? isEffectiveConnectionTypeSlowFor(m_fontSelector->document()) 198 isInterventionV2Enabled()
198 : isConnectionTypeSlow(); 199 ? isEffectiveConnectionTypeSlowFor(m_fontSelector->document())
200 : isConnectionTypeSlow();
199 201
200 return networkIsSlow && m_display == FontDisplayAuto; 202 return networkIsSlow && m_display == FontDisplayAuto;
201 } 203 }
202 204
203 bool RemoteFontFaceSource::isLowPriorityLoadingAllowedForRemoteFont() const { 205 bool RemoteFontFaceSource::isLowPriorityLoadingAllowedForRemoteFont() const {
204 return m_isInterventionTriggered; 206 return m_isInterventionTriggered && isInterventionV2Enabled();
205 } 207 }
206 208
207 PassRefPtr<SimpleFontData> RemoteFontFaceSource::createFontData( 209 PassRefPtr<SimpleFontData> RemoteFontFaceSource::createFontData(
208 const FontDescription& fontDescription) { 210 const FontDescription& fontDescription) {
209 if (!isLoaded()) 211 if (!isLoaded())
210 return createLoadingFallbackFontData(fontDescription); 212 return createLoadingFallbackFontData(fontDescription);
211 213
212 if (!m_font->ensureCustomFontData() || m_period == FailurePeriod) 214 if (!m_font->ensureCustomFontData() || m_period == FailurePeriod)
213 return nullptr; 215 return nullptr;
214 216
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 return Miss; 468 return Miss;
467 case FromUnknown: 469 case FromUnknown:
468 // Fall through. 470 // Fall through.
469 default: 471 default:
470 NOTREACHED(); 472 NOTREACHED();
471 } 473 }
472 return Miss; 474 return Miss;
473 } 475 }
474 476
475 } // namespace blink 477 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698