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

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: 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::TypeS low2G;
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 {
37 NOTREACHED();
Takashi Toyoshima 2016/09/16 05:57:16 This line seems to be reached when slow-2g is spec
tbansal1 2016/09/16 06:45:27 Done.
38 }
34 39
35 return WebEffectiveConnectionType::TypeOffline <= type && type <= thresholdT ype; 40 return WebEffectiveConnectionType::TypeOffline <= type && type <= thresholdT ype;
36 } 41 }
37 42
38 bool isConnectionTypeSlow() 43 bool isConnectionTypeSlow()
39 { 44 {
40 return networkStateNotifier().connectionType() == WebConnectionTypeCellular2 G; 45 return networkStateNotifier().connectionType() == WebConnectionTypeCellular2 G;
41 } 46 }
42 47
43 } // namespace 48 } // namespace
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 m_period = FailurePeriod; 168 m_period = FailurePeriod;
164 } 169 }
165 170
166 bool RemoteFontFaceSource::shouldTriggerWebFontsIntervention() 171 bool RemoteFontFaceSource::shouldTriggerWebFontsIntervention()
167 { 172 {
168 if (RuntimeEnabledFeatures::webFontsInterventionTriggerEnabled()) 173 if (RuntimeEnabledFeatures::webFontsInterventionTriggerEnabled())
169 return true; 174 return true;
170 if (m_histograms.dataSource() == FontLoadHistograms::FromMemoryCache || m_hi stograms.dataSource() == FontLoadHistograms::FromDataURL) 175 if (m_histograms.dataSource() == FontLoadHistograms::FromMemoryCache || m_hi stograms.dataSource() == FontLoadHistograms::FromDataURL)
171 return false; 176 return false;
172 177
173 bool isV2Enabled = RuntimeEnabledFeatures::webFontsInterventionV2With2GEnabl ed() || RuntimeEnabledFeatures::webFontsInterventionV2WithSlow2GEnabled(); 178 bool isV2Enabled = RuntimeEnabledFeatures::webFontsInterventionV2With3GEnabl ed() || RuntimeEnabledFeatures::webFontsInterventionV2With2GEnabled() || Runtime EnabledFeatures::webFontsInterventionV2WithSlow2GEnabled();
174 179
175 bool networkIsSlow = isV2Enabled ? isEffectiveConnectionTypeSlowFor(m_fontSe lector->document()) : isConnectionTypeSlow(); 180 bool networkIsSlow = isV2Enabled ? isEffectiveConnectionTypeSlowFor(m_fontSe lector->document()) : isConnectionTypeSlow();
176 181
177 return networkIsSlow && m_display == FontDisplayAuto; 182 return networkIsSlow && m_display == FontDisplayAuto;
178 } 183 }
179 184
180 185
181 PassRefPtr<SimpleFontData> RemoteFontFaceSource::createFontData(const FontDescri ption& fontDescription) 186 PassRefPtr<SimpleFontData> RemoteFontFaceSource::createFontData(const FontDescri ption& fontDescription)
182 { 187 {
183 if (!isLoaded()) 188 if (!isLoaded())
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return Miss; 371 return Miss;
367 case FromUnknown: 372 case FromUnknown:
368 // Fall through. 373 // Fall through.
369 default: 374 default:
370 NOTREACHED(); 375 NOTREACHED();
371 } 376 }
372 return Miss; 377 return Miss;
373 } 378 }
374 379
375 } // namespace blink 380 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698