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

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

Issue 2763523002: 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 m_period = FailurePeriod; 190 m_period = FailurePeriod;
191 } 191 }
192 192
193 bool RemoteFontFaceSource::shouldTriggerWebFontsIntervention() { 193 bool RemoteFontFaceSource::shouldTriggerWebFontsIntervention() {
194 if (RuntimeEnabledFeatures::webFontsInterventionTriggerEnabled()) 194 if (RuntimeEnabledFeatures::webFontsInterventionTriggerEnabled())
195 return true; 195 return true;
196 if (m_histograms.dataSource() == FontLoadHistograms::FromMemoryCache || 196 if (m_histograms.dataSource() == FontLoadHistograms::FromMemoryCache ||
197 m_histograms.dataSource() == FontLoadHistograms::FromDataURL) 197 m_histograms.dataSource() == FontLoadHistograms::FromDataURL)
198 return false; 198 return false;
199 199
200 bool isV2Enabled = 200 bool isV2Enabled =
Takashi Toyoshima 2017/03/21 08:46:58 We have same code here. Can you factor out these c
tbansal1 2017/03/21 16:47:16 Done.
201 RuntimeEnabledFeatures::webFontsInterventionV2With2GEnabled() || 201 RuntimeEnabledFeatures::webFontsInterventionV2With2GEnabled() ||
202 RuntimeEnabledFeatures::webFontsInterventionV2With3GEnabled() || 202 RuntimeEnabledFeatures::webFontsInterventionV2With3GEnabled() ||
203 RuntimeEnabledFeatures::webFontsInterventionV2WithSlow2GEnabled(); 203 RuntimeEnabledFeatures::webFontsInterventionV2WithSlow2GEnabled();
204 204
205 bool networkIsSlow = 205 bool networkIsSlow =
206 isV2Enabled ? isEffectiveConnectionTypeSlowFor(m_fontSelector->document()) 206 isV2Enabled ? isEffectiveConnectionTypeSlowFor(m_fontSelector->document())
207 : isConnectionTypeSlow(); 207 : isConnectionTypeSlow();
208 208
209 return networkIsSlow && m_display == FontDisplayAuto; 209 return networkIsSlow && m_display == FontDisplayAuto;
210 } 210 }
211 211
212 bool RemoteFontFaceSource::isLowPriorityLoadingAllowedForRemoteFont() const { 212 bool RemoteFontFaceSource::isLowPriorityLoadingAllowedForRemoteFont() const {
213 return m_isInterventionTriggered; 213 bool isV2Enabled =
214 RuntimeEnabledFeatures::webFontsInterventionV2With2GEnabled() ||
215 RuntimeEnabledFeatures::webFontsInterventionV2With3GEnabled() ||
216 RuntimeEnabledFeatures::webFontsInterventionV2WithSlow2GEnabled();
217
218 return m_isInterventionTriggered && isV2Enabled;
214 } 219 }
215 220
216 PassRefPtr<SimpleFontData> RemoteFontFaceSource::createFontData( 221 PassRefPtr<SimpleFontData> RemoteFontFaceSource::createFontData(
217 const FontDescription& fontDescription) { 222 const FontDescription& fontDescription) {
218 if (m_period == FailurePeriod || !isValid()) 223 if (m_period == FailurePeriod || !isValid())
219 return nullptr; 224 return nullptr;
220 if (!isLoaded()) 225 if (!isLoaded())
221 return createLoadingFallbackFontData(fontDescription); 226 return createLoadingFallbackFontData(fontDescription);
222 DCHECK(m_customFontData); 227 DCHECK(m_customFontData);
223 228
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 return Miss; 483 return Miss;
479 case FromUnknown: 484 case FromUnknown:
480 // Fall through. 485 // Fall through.
481 default: 486 default:
482 NOTREACHED(); 487 NOTREACHED();
483 } 488 }
484 return Miss; 489 return Miss;
485 } 490 }
486 491
487 } // namespace blink 492 } // 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