OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_conf
ig_service_client.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_service_client.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 void DataReductionProxyConfigServiceClient::SetEnabled(bool enabled) { | 211 void DataReductionProxyConfigServiceClient::SetEnabled(bool enabled) { |
212 DCHECK(thread_checker_.CalledOnValidThread()); | 212 DCHECK(thread_checker_.CalledOnValidThread()); |
213 enabled_ = enabled; | 213 enabled_ = enabled; |
214 } | 214 } |
215 | 215 |
216 void DataReductionProxyConfigServiceClient::RetrieveConfig() { | 216 void DataReductionProxyConfigServiceClient::RetrieveConfig() { |
217 DCHECK(thread_checker_.CalledOnValidThread()); | 217 DCHECK(thread_checker_.CalledOnValidThread()); |
218 if (!enabled_) | 218 if (!enabled_) |
219 return; | 219 return; |
220 | 220 |
221 bound_net_log_ = net::BoundNetLog::Make( | 221 net_log_with_source_ = net::NetLogWithSource::Make( |
222 net_log_, net::NetLogSourceType::DATA_REDUCTION_PROXY); | 222 net_log_, net::NetLogSourceType::DATA_REDUCTION_PROXY); |
223 // Strip off query string parameters | 223 // Strip off query string parameters |
224 GURL::Replacements replacements; | 224 GURL::Replacements replacements; |
225 replacements.ClearQuery(); | 225 replacements.ClearQuery(); |
226 GURL base_config_service_url = | 226 GURL base_config_service_url = |
227 config_service_url_.ReplaceComponents(replacements); | 227 config_service_url_.ReplaceComponents(replacements); |
228 event_creator_->BeginConfigRequest(bound_net_log_, base_config_service_url); | 228 event_creator_->BeginConfigRequest(net_log_with_source_, |
| 229 base_config_service_url); |
229 config_fetch_start_time_ = base::TimeTicks::Now(); | 230 config_fetch_start_time_ = base::TimeTicks::Now(); |
230 | 231 |
231 RetrieveRemoteConfig(); | 232 RetrieveRemoteConfig(); |
232 } | 233 } |
233 | 234 |
234 void DataReductionProxyConfigServiceClient::ApplySerializedConfig( | 235 void DataReductionProxyConfigServiceClient::ApplySerializedConfig( |
235 const std::string& config_value) { | 236 const std::string& config_value) { |
236 DCHECK(thread_checker_.CalledOnValidThread()); | 237 DCHECK(thread_checker_.CalledOnValidThread()); |
237 if (remote_config_applied_) | 238 if (remote_config_applied_) |
238 return; | 239 return; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 config_storer_.Run(encoded_config); | 446 config_storer_.Run(encoded_config); |
446 } else { | 447 } else { |
447 ++failed_attempts_before_success_; | 448 ++failed_attempts_before_success_; |
448 } | 449 } |
449 | 450 |
450 GetBackoffEntry()->InformOfRequest(succeeded); | 451 GetBackoffEntry()->InformOfRequest(succeeded); |
451 base::TimeDelta next_config_refresh_time = CalculateNextConfigRefreshTime( | 452 base::TimeDelta next_config_refresh_time = CalculateNextConfigRefreshTime( |
452 succeeded, refresh_duration, GetBackoffEntry()->GetTimeUntilRelease()); | 453 succeeded, refresh_duration, GetBackoffEntry()->GetTimeUntilRelease()); |
453 | 454 |
454 SetConfigRefreshTimer(next_config_refresh_time); | 455 SetConfigRefreshTimer(next_config_refresh_time); |
455 event_creator_->EndConfigRequest(bound_net_log_, status.error(), | 456 event_creator_->EndConfigRequest(net_log_with_source_, status.error(), |
456 response_code, | 457 response_code, |
457 GetBackoffEntry()->failure_count(), proxies, | 458 GetBackoffEntry()->failure_count(), proxies, |
458 refresh_duration, next_config_refresh_time); | 459 refresh_duration, next_config_refresh_time); |
459 } | 460 } |
460 | 461 |
461 bool DataReductionProxyConfigServiceClient::ParseAndApplyProxyConfig( | 462 bool DataReductionProxyConfigServiceClient::ParseAndApplyProxyConfig( |
462 const ClientConfig& config) { | 463 const ClientConfig& config) { |
463 DCHECK(thread_checker_.CalledOnValidThread()); | 464 DCHECK(thread_checker_.CalledOnValidThread()); |
464 float reporting_fraction = 0.0f; | 465 float reporting_fraction = 0.0f; |
465 if (config.has_pageload_metrics_config() && | 466 if (config.has_pageload_metrics_config() && |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 DCHECK(thread_checker_.CalledOnValidThread()); | 499 DCHECK(thread_checker_.CalledOnValidThread()); |
499 if (new_state == base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES && | 500 if (new_state == base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES && |
500 foreground_fetch_pending_) { | 501 foreground_fetch_pending_) { |
501 foreground_fetch_pending_ = false; | 502 foreground_fetch_pending_ = false; |
502 RetrieveConfig(); | 503 RetrieveConfig(); |
503 } | 504 } |
504 } | 505 } |
505 #endif | 506 #endif |
506 | 507 |
507 } // namespace data_reduction_proxy | 508 } // namespace data_reduction_proxy |
OLD | NEW |