OLD | NEW |
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 "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // Technically, this is not "at startup", but this is the first chance that | 108 // Technically, this is not "at startup", but this is the first chance that |
109 // IO data objects can be called. | 109 // IO data objects can be called. |
110 UpdateIOData(true); | 110 UpdateIOData(true); |
111 } | 111 } |
112 | 112 |
113 void DataReductionProxySettings::SetCallbackToRegisterSyntheticFieldTrial( | 113 void DataReductionProxySettings::SetCallbackToRegisterSyntheticFieldTrial( |
114 const SyntheticFieldTrialRegistrationCallback& | 114 const SyntheticFieldTrialRegistrationCallback& |
115 on_data_reduction_proxy_enabled) { | 115 on_data_reduction_proxy_enabled) { |
116 register_synthetic_field_trial_ = on_data_reduction_proxy_enabled; | 116 register_synthetic_field_trial_ = on_data_reduction_proxy_enabled; |
117 RegisterDataReductionProxyFieldTrial(); | 117 RegisterDataReductionProxyFieldTrial(); |
118 RegisterLoFiFieldTrial(); | |
119 } | 118 } |
120 | 119 |
121 bool DataReductionProxySettings::IsDataReductionProxyEnabled() const { | 120 bool DataReductionProxySettings::IsDataReductionProxyEnabled() const { |
122 return spdy_proxy_auth_enabled_.GetValue() || | 121 return spdy_proxy_auth_enabled_.GetValue() || |
123 params::ShouldForceEnableDataReductionProxy(); | 122 params::ShouldForceEnableDataReductionProxy(); |
124 } | 123 } |
125 | 124 |
126 bool DataReductionProxySettings::CanUseDataReductionProxy( | 125 bool DataReductionProxySettings::CanUseDataReductionProxy( |
127 const GURL& url) const { | 126 const GURL& url) const { |
128 return url.is_valid() && url.scheme() == url::kHttpScheme && | 127 return url.is_valid() && url.scheme() == url::kHttpScheme && |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 DCHECK(thread_checker_.CalledOnValidThread()); | 164 DCHECK(thread_checker_.CalledOnValidThread()); |
166 return prefs_; | 165 return prefs_; |
167 } | 166 } |
168 | 167 |
169 void DataReductionProxySettings::SetLoFiModeActiveOnMainFrame( | 168 void DataReductionProxySettings::SetLoFiModeActiveOnMainFrame( |
170 bool lo_fi_mode_active) { | 169 bool lo_fi_mode_active) { |
171 if (prefs_ && lo_fi_mode_active) | 170 if (prefs_ && lo_fi_mode_active) |
172 prefs_->SetBoolean(prefs::kLoFiWasUsedThisSession, true); | 171 prefs_->SetBoolean(prefs::kLoFiWasUsedThisSession, true); |
173 lo_fi_load_image_requested_ = false; | 172 lo_fi_load_image_requested_ = false; |
174 lo_fi_mode_active_ = lo_fi_mode_active; | 173 lo_fi_mode_active_ = lo_fi_mode_active; |
175 if (!register_synthetic_field_trial_.is_null()) { | |
176 RegisterLoFiFieldTrial(); | |
177 } | |
178 } | 174 } |
179 | 175 |
180 bool DataReductionProxySettings::WasLoFiModeActiveOnMainFrame() const { | 176 bool DataReductionProxySettings::WasLoFiModeActiveOnMainFrame() const { |
181 return lo_fi_mode_active_; | 177 return lo_fi_mode_active_; |
182 } | 178 } |
183 | 179 |
184 bool DataReductionProxySettings::WasLoFiLoadImageRequestedBefore() { | 180 bool DataReductionProxySettings::WasLoFiLoadImageRequestedBefore() { |
185 return lo_fi_load_image_requested_; | 181 return lo_fi_load_image_requested_; |
186 } | 182 } |
187 | 183 |
(...skipping 26 matching lines...) Expand all Loading... |
214 } | 210 } |
215 } | 211 } |
216 } | 212 } |
217 | 213 |
218 void DataReductionProxySettings::RegisterDataReductionProxyFieldTrial() { | 214 void DataReductionProxySettings::RegisterDataReductionProxyFieldTrial() { |
219 register_synthetic_field_trial_.Run( | 215 register_synthetic_field_trial_.Run( |
220 "SyntheticDataReductionProxySetting", | 216 "SyntheticDataReductionProxySetting", |
221 IsDataReductionProxyEnabled() ? "Enabled" : "Disabled"); | 217 IsDataReductionProxyEnabled() ? "Enabled" : "Disabled"); |
222 } | 218 } |
223 | 219 |
224 void DataReductionProxySettings::RegisterLoFiFieldTrial() { | |
225 register_synthetic_field_trial_.Run( | |
226 "SyntheticDataReductionProxyLoFiSetting", | |
227 IsDataReductionProxyEnabled() && WasLoFiModeActiveOnMainFrame() | |
228 ? "Enabled" | |
229 : "Disabled"); | |
230 } | |
231 | |
232 void DataReductionProxySettings::OnProxyEnabledPrefChange() { | 220 void DataReductionProxySettings::OnProxyEnabledPrefChange() { |
233 DCHECK(thread_checker_.CalledOnValidThread()); | 221 DCHECK(thread_checker_.CalledOnValidThread()); |
234 if (!register_synthetic_field_trial_.is_null()) { | 222 if (!register_synthetic_field_trial_.is_null()) { |
235 RegisterDataReductionProxyFieldTrial(); | 223 RegisterDataReductionProxyFieldTrial(); |
236 RegisterLoFiFieldTrial(); | |
237 } | 224 } |
238 if (!allowed_) | 225 if (!allowed_) |
239 return; | 226 return; |
240 MaybeActivateDataReductionProxy(false); | 227 MaybeActivateDataReductionProxy(false); |
241 } | 228 } |
242 | 229 |
243 void DataReductionProxySettings::ResetDataReductionStatistics() { | 230 void DataReductionProxySettings::ResetDataReductionStatistics() { |
244 DCHECK(thread_checker_.CalledOnValidThread()); | 231 DCHECK(thread_checker_.CalledOnValidThread()); |
245 DCHECK(data_reduction_proxy_service_->compression_stats()); | 232 DCHECK(data_reduction_proxy_service_->compression_stats()); |
246 data_reduction_proxy_service_->compression_stats()->ResetStatistics(); | 233 data_reduction_proxy_service_->compression_stats()->ResetStatistics(); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 int64_t* received_content_length, | 359 int64_t* received_content_length, |
373 int64_t* last_update_time) { | 360 int64_t* last_update_time) { |
374 DCHECK(thread_checker_.CalledOnValidThread()); | 361 DCHECK(thread_checker_.CalledOnValidThread()); |
375 DCHECK(data_reduction_proxy_service_->compression_stats()); | 362 DCHECK(data_reduction_proxy_service_->compression_stats()); |
376 | 363 |
377 data_reduction_proxy_service_->compression_stats()->GetContentLengths( | 364 data_reduction_proxy_service_->compression_stats()->GetContentLengths( |
378 days, original_content_length, received_content_length, last_update_time); | 365 days, original_content_length, received_content_length, last_update_time); |
379 } | 366 } |
380 | 367 |
381 } // namespace data_reduction_proxy | 368 } // namespace data_reduction_proxy |
OLD | NEW |