| 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 332679067f5fadb8fb37fb125f9c835dd158a9a8..e72d249aa3e6a73af14d6fc71c3909d8c39f94e3 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
|
| @@ -14,43 +14,38 @@
|
| #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_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_client_config_parser.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"
|
| -#include "net/base/url_util.h"
|
| #include "net/http/http_network_session.h"
|
| #include "net/http/http_request_headers.h"
|
| #include "net/http/http_response_headers.h"
|
| #include "net/http/http_status_code.h"
|
| #include "net/proxy/proxy_server.h"
|
| #include "net/url_request/url_fetcher.h"
|
| #include "net/url_request/url_request_context.h"
|
| #include "net/url_request/url_request_context_getter.h"
|
| #include "net/url_request/url_request_status.h"
|
|
|
| -#if defined(USE_GOOGLE_API_KEYS)
|
| -#include "google_apis/google_api_keys.h"
|
| -#endif
|
| -
|
| namespace data_reduction_proxy {
|
|
|
| namespace {
|
|
|
| // Key of the UMA DataReductionProxy.ConfigService.FetchResponseCode histogram.
|
| const char kUMAConfigServiceFetchResponseCode[] =
|
| "DataReductionProxy.ConfigService.FetchResponseCode";
|
|
|
| // Key of the UMA
|
| // DataReductionProxy.ConfigService.FetchFailedAttemptsBeforeSuccess histogram.
|
| @@ -64,63 +59,47 @@ const char kUMAConfigServiceFetchLatency[] =
|
| // Key of the UMA DataReductionProxy.ConfigService.AuthExpired histogram.
|
| const char kUMAConfigServiceAuthExpired[] =
|
| "DataReductionProxy.ConfigService.AuthExpired";
|
|
|
| #if defined(OS_ANDROID)
|
| // Maximum duration to wait before fetching the config, while the application
|
| // is in background.
|
| const uint32_t kMaxBackgroundFetchIntervalSeconds = 6 * 60 * 60; // 6 hours.
|
| #endif
|
|
|
| -#if defined(USE_GOOGLE_API_KEYS)
|
| -// Used in all Data Reduction Proxy URLs to specify API Key.
|
| -const char kApiKeyName[] = "key";
|
| -#endif
|
| -
|
| // This is the default backoff policy used to communicate with the Data
|
| // Reduction Proxy configuration service.
|
| const net::BackoffEntry::Policy kDefaultBackoffPolicy = {
|
| 0, // num_errors_to_ignore
|
| 1 * 1000, // initial_delay_ms
|
| 4, // multiply_factor
|
| 0.10, // jitter_factor,
|
| 30 * 60 * 1000, // maximum_backoff_ms
|
| -1, // entry_lifetime_ms
|
| true, // always_use_initial_delay
|
| };
|
|
|
| // Extracts the list of Data Reduction Proxy servers to use for HTTP requests.
|
| std::vector<net::ProxyServer> GetProxiesForHTTP(
|
| const data_reduction_proxy::ProxyConfig& proxy_config) {
|
| std::vector<net::ProxyServer> proxies;
|
| for (const auto& server : proxy_config.http_proxy_servers()) {
|
| if (server.scheme() != ProxyServer_ProxyScheme_UNSPECIFIED) {
|
| proxies.push_back(net::ProxyServer(
|
| - config_parser::SchemeFromProxyScheme(server.scheme()),
|
| + protobuf_parser::SchemeFromProxyScheme(server.scheme()),
|
| net::HostPortPair(server.host(), server.port())));
|
| }
|
| }
|
|
|
| return proxies;
|
| }
|
|
|
| -GURL AddApiKeyToUrl(const GURL& url) {
|
| - GURL new_url = url;
|
| -#if defined(USE_GOOGLE_API_KEYS)
|
| - std::string api_key = google_apis::GetAPIKey();
|
| - if (google_apis::HasKeysConfigured() && !api_key.empty()) {
|
| - new_url = net::AppendOrReplaceQueryParameter(url, kApiKeyName, api_key);
|
| - }
|
| -#endif
|
| - return net::AppendOrReplaceQueryParameter(new_url, "alt", "proto");
|
| -}
|
| -
|
| void RecordAuthExpiredHistogram(bool auth_expired) {
|
| UMA_HISTOGRAM_BOOLEAN(kUMAConfigServiceAuthExpired, auth_expired);
|
| }
|
|
|
| // Records whether the session key used in the request matches the current
|
| // sesssion key.
|
| void RecordAuthExpiredSessionKey(bool matches) {
|
| // This enum must remain synchronized with the
|
| // DataReductionProxyConfigServiceAuthExpiredSessionKey enum in
|
| // metrics/histograms/histograms.xml.
|
| @@ -447,21 +426,21 @@ void DataReductionProxyConfigServiceClient::HandleResponse(
|
| succeeded = ParseAndApplyProxyConfig(config);
|
| }
|
|
|
| // These are proxies listed in the config. The proxies that client eventually
|
| // ends up using depend on the field trials.
|
| std::vector<net::ProxyServer> proxies;
|
| base::TimeDelta refresh_duration;
|
| if (succeeded) {
|
| proxies = GetProxiesForHTTP(config.proxy_config());
|
| refresh_duration =
|
| - config_parser::DurationToTimeDelta(config.refresh_duration());
|
| + protobuf_parser::DurationToTimeDelta(config.refresh_duration());
|
|
|
| DCHECK(!config_fetch_start_time_.is_null());
|
| base::TimeDelta configuration_fetch_latency =
|
| base::TimeTicks::Now() - config_fetch_start_time_;
|
| RecordAuthExpiredHistogram(false);
|
| UMA_HISTOGRAM_MEDIUM_TIMES(kUMAConfigServiceFetchLatency,
|
| configuration_fetch_latency);
|
| UMA_HISTOGRAM_COUNTS_100(kUMAConfigServiceFetchFailedAttemptsBeforeSuccess,
|
| failed_attempts_before_success_);
|
| failed_attempts_before_success_ = 0;
|
|
|