| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.cc
|
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.cc
|
| index a9edb9a3cba6fa310b29e819e6cc0be794d4cdff..e652b5ce47f83840bdfc2e7ba8f688783b0e72b8 100644
|
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.cc
|
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.cc
|
| @@ -12,20 +12,21 @@
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| #include "base/json/json_writer.h"
|
| #include "base/location.h"
|
| #include "base/logging.h"
|
| #include "base/metrics/histogram_macros.h"
|
| #include "base/metrics/sparse_histogram.h"
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/values.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h"
|
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_util.h"
|
| #include "components/data_reduction_proxy/proto/client_config.pb.h"
|
| #include "net/base/host_port_pair.h"
|
| #include "net/base/load_flags.h"
|
| #include "net/base/load_timing_info.h"
|
| #include "net/base/net_errors.h"
|
| @@ -136,44 +137,47 @@ const net::BackoffEntry::Policy& GetBackoffPolicy() {
|
| return kDefaultBackoffPolicy;
|
| }
|
|
|
| DataReductionProxyConfigServiceClient::DataReductionProxyConfigServiceClient(
|
| std::unique_ptr<DataReductionProxyParams> params,
|
| const net::BackoffEntry::Policy& backoff_policy,
|
| DataReductionProxyRequestOptions* request_options,
|
| DataReductionProxyMutableConfigValues* config_values,
|
| DataReductionProxyConfig* config,
|
| DataReductionProxyEventCreator* event_creator,
|
| + DataReductionProxyIOData* io_data,
|
| net::NetLog* net_log,
|
| ConfigStorer config_storer)
|
| : params_(std::move(params)),
|
| request_options_(request_options),
|
| config_values_(config_values),
|
| config_(config),
|
| event_creator_(event_creator),
|
| + io_data_(io_data),
|
| net_log_(net_log),
|
| config_storer_(config_storer),
|
| backoff_entry_(&backoff_policy),
|
| config_service_url_(util::AddApiKeyToUrl(params::GetConfigServiceURL())),
|
| enabled_(false),
|
| remote_config_applied_(false),
|
| url_request_context_getter_(nullptr),
|
| #if defined(OS_ANDROID)
|
| foreground_fetch_pending_(false),
|
| #endif
|
| previous_request_failed_authentication_(false),
|
| failed_attempts_before_success_(0),
|
| quic_enabled_(false) {
|
| DCHECK(request_options);
|
| DCHECK(config_values);
|
| DCHECK(config);
|
| DCHECK(event_creator);
|
| + DCHECK(io_data);
|
| DCHECK(net_log);
|
| DCHECK(config_service_url_.is_valid());
|
| // Constructed on the UI thread, but should be checked on the IO thread.
|
| thread_checker_.DetachFromThread();
|
| }
|
|
|
| DataReductionProxyConfigServiceClient::
|
| ~DataReductionProxyConfigServiceClient() {
|
| net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
|
| }
|
| @@ -379,20 +383,21 @@ void DataReductionProxyConfigServiceClient::RetrieveRemoteConfig() {
|
| fetcher_ = std::move(fetcher);
|
| fetcher_->Start();
|
| }
|
|
|
| void DataReductionProxyConfigServiceClient::InvalidateConfig() {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| GetBackoffEntry()->InformOfRequest(false);
|
| config_storer_.Run(std::string());
|
| request_options_->Invalidate();
|
| config_values_->Invalidate();
|
| + io_data_->SetPingbackReportingFraction(0.0f);
|
| config_->ReloadConfig();
|
| }
|
|
|
| std::unique_ptr<net::URLFetcher>
|
| DataReductionProxyConfigServiceClient::GetURLFetcherForConfig(
|
| const GURL& secure_proxy_check_url,
|
| const std::string& request_body) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| std::unique_ptr<net::URLFetcher> fetcher(net::URLFetcher::Create(
|
| secure_proxy_check_url, net::URLFetcher::POST, this));
|
| @@ -458,20 +463,29 @@ void DataReductionProxyConfigServiceClient::HandleResponse(
|
| SetConfigRefreshTimer(next_config_refresh_time);
|
| event_creator_->EndConfigRequest(bound_net_log_, status.error(),
|
| response_code,
|
| GetBackoffEntry()->failure_count(), proxies,
|
| refresh_duration, next_config_refresh_time);
|
| }
|
|
|
| bool DataReductionProxyConfigServiceClient::ParseAndApplyProxyConfig(
|
| const ClientConfig& config) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| + float reporting_fraction = 0.0f;
|
| + if (config.has_pageload_metrics_config() &&
|
| + config.pageload_metrics_config().has_reporting_fraction()) {
|
| + reporting_fraction = config.pageload_metrics_config().reporting_fraction();
|
| + }
|
| + DCHECK_LE(0.0f, reporting_fraction);
|
| + DCHECK_GE(1.0f, reporting_fraction);
|
| + io_data_->SetPingbackReportingFraction(reporting_fraction);
|
| +
|
| if (!config.has_proxy_config())
|
| return false;
|
|
|
| std::vector<net::ProxyServer> proxies =
|
| GetProxiesForHTTP(config.proxy_config());
|
|
|
| if (proxies.empty())
|
| return false;
|
|
|
| request_options_->SetSecureSession(config.session_key());
|
|
|