| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/previews/core/previews_io_data.h" | 5 #include "components/previews/core/previews_io_data.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 net::NetworkQualityEstimator* network_quality_estimator = | 106 net::NetworkQualityEstimator* network_quality_estimator = |
| 107 request.context()->network_quality_estimator(); | 107 request.context()->network_quality_estimator(); |
| 108 if (!network_quality_estimator || | 108 if (!network_quality_estimator || |
| 109 network_quality_estimator->GetEffectiveConnectionType() < | 109 network_quality_estimator->GetEffectiveConnectionType() < |
| 110 net::EFFECTIVE_CONNECTION_TYPE_OFFLINE) { | 110 net::EFFECTIVE_CONNECTION_TYPE_OFFLINE) { |
| 111 LogPreviewsEligibilityReason( | 111 LogPreviewsEligibilityReason( |
| 112 PreviewsEligibilityReason::NETWORK_QUALITY_UNAVAILABLE, type); | 112 PreviewsEligibilityReason::NETWORK_QUALITY_UNAVAILABLE, type); |
| 113 return false; | 113 return false; |
| 114 } | 114 } |
| 115 if (network_quality_estimator->GetEffectiveConnectionType() > | 115 if (network_quality_estimator->GetEffectiveConnectionType() > |
| 116 net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G) { | 116 params::EffectiveConnectionTypeThreshold()) { |
| 117 LogPreviewsEligibilityReason(PreviewsEligibilityReason::NETWORK_NOT_SLOW, | 117 LogPreviewsEligibilityReason(PreviewsEligibilityReason::NETWORK_NOT_SLOW, |
| 118 type); | 118 type); |
| 119 return false; | 119 return false; |
| 120 } | 120 } |
| 121 // LOAD_VALIDATE_CACHE or LOAD_BYPASS_CACHE mean the user reloaded the page. | 121 // LOAD_VALIDATE_CACHE or LOAD_BYPASS_CACHE mean the user reloaded the page. |
| 122 // If this is a query for offline previews, reloads should be disallowed. | 122 // If this is a query for offline previews, reloads should be disallowed. |
| 123 if (type == PreviewsType::OFFLINE && | 123 if (type == PreviewsType::OFFLINE && |
| 124 request.load_flags() & | 124 request.load_flags() & |
| 125 (net::LOAD_VALIDATE_CACHE | net::LOAD_BYPASS_CACHE)) { | 125 (net::LOAD_VALIDATE_CACHE | net::LOAD_BYPASS_CACHE)) { |
| 126 LogPreviewsEligibilityReason( | 126 LogPreviewsEligibilityReason( |
| 127 PreviewsEligibilityReason::RELOAD_DISALLOWED_FOR_OFFLINE, type); | 127 PreviewsEligibilityReason::RELOAD_DISALLOWED_FOR_OFFLINE, type); |
| 128 return false; | 128 return false; |
| 129 } | 129 } |
| 130 LogPreviewsEligibilityReason(PreviewsEligibilityReason::ALLOWED, type); | 130 LogPreviewsEligibilityReason(PreviewsEligibilityReason::ALLOWED, type); |
| 131 return true; | 131 return true; |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace previews | 134 } // namespace previews |
| OLD | NEW |