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

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

Issue 2349593002: Wire WebFonts intervention v2 for ECT of 3G (Closed)
Patch Set: rebased Created 4 years, 3 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
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 10 matching lines...) Expand all
21 #include "wtf/CurrentTime.h" 21 #include "wtf/CurrentTime.h"
22 22
23 namespace blink { 23 namespace blink {
24 24
25 namespace { 25 namespace {
26 26
27 bool isEffectiveConnectionTypeSlowFor(Document* document) 27 bool isEffectiveConnectionTypeSlowFor(Document* document)
28 { 28 {
29 WebEffectiveConnectionType type = document->frame()->loader().client()->getE ffectiveConnectionType(); 29 WebEffectiveConnectionType type = document->frame()->loader().client()->getE ffectiveConnectionType();
30 30
31 WebEffectiveConnectionType thresholdType = RuntimeEnabledFeatures::webFontsI nterventionV2With2GEnabled() 31 WebEffectiveConnectionType thresholdType = WebEffectiveConnectionType::TypeU nknown;
32 ? WebEffectiveConnectionType::Type2G 32 if (RuntimeEnabledFeatures::webFontsInterventionV2With2GEnabled()) {
33 : WebEffectiveConnectionType::TypeSlow2G; 33 thresholdType = WebEffectiveConnectionType::Type2G;
34 } else if (RuntimeEnabledFeatures::webFontsInterventionV2With3GEnabled()) {
35 thresholdType = WebEffectiveConnectionType::Type3G;
36 } else if (RuntimeEnabledFeatures::webFontsInterventionV2WithSlow2GEnabled() ) {
37 thresholdType = WebEffectiveConnectionType::TypeSlow2G;
38 }
39 DCHECK_NE(WebEffectiveConnectionType::TypeUnknown, thresholdType);
34 40
35 return WebEffectiveConnectionType::TypeOffline <= type && type <= thresholdT ype; 41 return WebEffectiveConnectionType::TypeOffline <= type && type <= thresholdT ype;
36 } 42 }
37 43
38 bool isConnectionTypeSlow() 44 bool isConnectionTypeSlow()
39 { 45 {
40 return networkStateNotifier().connectionType() == WebConnectionTypeCellular2 G; 46 return networkStateNotifier().connectionType() == WebConnectionTypeCellular2 G;
41 } 47 }
42 48
43 } // namespace 49 } // namespace
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 m_period = FailurePeriod; 169 m_period = FailurePeriod;
164 } 170 }
165 171
166 bool RemoteFontFaceSource::shouldTriggerWebFontsIntervention() 172 bool RemoteFontFaceSource::shouldTriggerWebFontsIntervention()
167 { 173 {
168 if (RuntimeEnabledFeatures::webFontsInterventionTriggerEnabled()) 174 if (RuntimeEnabledFeatures::webFontsInterventionTriggerEnabled())
169 return true; 175 return true;
170 if (m_histograms.dataSource() == FontLoadHistograms::FromMemoryCache || m_hi stograms.dataSource() == FontLoadHistograms::FromDataURL) 176 if (m_histograms.dataSource() == FontLoadHistograms::FromMemoryCache || m_hi stograms.dataSource() == FontLoadHistograms::FromDataURL)
171 return false; 177 return false;
172 178
173 bool isV2Enabled = RuntimeEnabledFeatures::webFontsInterventionV2With2GEnabl ed() || RuntimeEnabledFeatures::webFontsInterventionV2WithSlow2GEnabled(); 179 bool isV2Enabled = RuntimeEnabledFeatures::webFontsInterventionV2With2GEnabl ed() || RuntimeEnabledFeatures::webFontsInterventionV2With3GEnabled() || Runtime EnabledFeatures::webFontsInterventionV2WithSlow2GEnabled();
174 180
175 bool networkIsSlow = isV2Enabled ? isEffectiveConnectionTypeSlowFor(m_fontSe lector->document()) : isConnectionTypeSlow(); 181 bool networkIsSlow = isV2Enabled ? isEffectiveConnectionTypeSlowFor(m_fontSe lector->document()) : isConnectionTypeSlow();
176 182
177 return networkIsSlow && m_display == FontDisplayAuto; 183 return networkIsSlow && m_display == FontDisplayAuto;
178 } 184 }
179 185
180 186
181 PassRefPtr<SimpleFontData> RemoteFontFaceSource::createFontData(const FontDescri ption& fontDescription) 187 PassRefPtr<SimpleFontData> RemoteFontFaceSource::createFontData(const FontDescri ption& fontDescription)
182 { 188 {
183 if (!isLoaded()) 189 if (!isLoaded())
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 return Miss; 370 return Miss;
365 case FromUnknown: 371 case FromUnknown:
366 // Fall through. 372 // Fall through.
367 default: 373 default:
368 NOTREACHED(); 374 NOTREACHED();
369 } 375 }
370 return Miss; 376 return Miss;
371 } 377 }
372 378
373 } // namespace blink 379 } // namespace blink
OLDNEW
« no previous file with comments | « content/public/common/content_switches.cc ('k') | third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698