Chromium Code Reviews| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol.cc |
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol.cc |
| index 81aeceae0b07f7cb25d62e20eef72448d7001a62..244af14fed19d3ee031b765ee138f377105a6be4 100644 |
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol.cc |
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol.cc |
| @@ -24,18 +24,6 @@ |
| namespace { |
| -bool SetProxyServerFromGURL(const GURL& gurl, |
| - net::ProxyServer* proxy_server) { |
| - DCHECK(proxy_server); |
| - if (!gurl.SchemeIsHTTPOrHTTPS()) |
| - return false; |
| - *proxy_server = net::ProxyServer(gurl.SchemeIs(url::kHttpScheme) ? |
| - net::ProxyServer::SCHEME_HTTP : |
| - net::ProxyServer::SCHEME_HTTPS, |
| - net::HostPortPair::FromURL(gurl)); |
| - return true; |
| -} |
| - |
| // Adds non-empty entries in |data_reduction_proxies| to the retry map |
| // maintained by the proxy service of the request. Adds |
| // |data_reduction_proxies.second| to the retry list only if |bypass_all| is |
| @@ -44,19 +32,20 @@ void MarkProxiesAsBadUntil( |
| net::URLRequest* request, |
| const base::TimeDelta& bypass_duration, |
| bool bypass_all, |
| - const std::pair<GURL, GURL>& data_reduction_proxies) { |
| - DCHECK(!data_reduction_proxies.first.is_empty()); |
| + const std::pair<net::ProxyServer, net::ProxyServer>& data_reduction_proxies) { |
| + DCHECK(data_reduction_proxies.first.is_valid()); |
| + DCHECK(!data_reduction_proxies.first.host_port_pair().IsEmpty()); |
| // Synthesize a suitable |ProxyInfo| to add the proxies to the |
| // |ProxyRetryInfoMap| of the proxy service. |
| net::ProxyList proxy_list; |
| - net::ProxyServer primary; |
| - SetProxyServerFromGURL(data_reduction_proxies.first, &primary); |
| + net::ProxyServer primary = data_reduction_proxies.first; |
| if (primary.is_valid()) |
| proxy_list.AddProxyServer(primary); |
| net::ProxyServer fallback; |
| if (bypass_all) { |
| - if (!data_reduction_proxies.second.is_empty()) |
| - SetProxyServerFromGURL(data_reduction_proxies.second, &fallback); |
| + if (data_reduction_proxies.second.is_valid() && |
| + !data_reduction_proxies.second.host_port_pair().IsEmpty()) |
| + fallback = data_reduction_proxies.second; |
| if (fallback.is_valid()) |
| proxy_list.AddProxyServer(fallback); |
| proxy_list.AddProxyServer(net::ProxyServer::Direct()); |
| @@ -112,13 +101,15 @@ bool DataReductionProxyBypassProtocol::MaybeBypassProxyAndPrepareToRetry( |
| if (data_reduction_proxy_type_info.is_ssl) |
| return false; |
| - if (data_reduction_proxy_type_info.proxy_servers.first.is_empty()) |
| - return false; |
| + if (!data_reduction_proxy_type_info.proxy_servers.first.is_valid() || |
| + data_reduction_proxy_type_info.proxy_servers.first.host_port_pair().IsEmpty()) |
|
bengr
2015/02/04 00:49:25
indentation
tbansal1
2015/02/04 22:49:10
Done.
|
| + return false; |
| // At this point, the response is expected to have the data reduction proxy |
| // via header, so detect and report cases where the via header is missing. |
| DataReductionProxyUsageStats::DetectAndRecordMissingViaHeaderResponseCode( |
| - !data_reduction_proxy_type_info.proxy_servers.second.is_empty(), |
| + data_reduction_proxy_type_info.proxy_servers.second.is_valid() && |
| + !data_reduction_proxy_type_info.proxy_servers.second.host_port_pair().IsEmpty(), |
|
bengr
2015/02/04 00:49:25
indent two more and limit to 80 chars.
tbansal1
2015/02/04 22:49:10
Done.
|
| response_headers); |
| if (DataReductionProxyParams:: |
| @@ -166,9 +157,8 @@ bool DataReductionProxyBypassProtocol::MaybeBypassProxyAndPrepareToRetry( |
| DCHECK(request->context()); |
| DCHECK(request->context()->proxy_service()); |
| - net::ProxyServer proxy_server; |
| - SetProxyServerFromGURL( |
| - data_reduction_proxy_type_info.proxy_servers.first, &proxy_server); |
| + net::ProxyServer proxy_server = |
| + data_reduction_proxy_type_info.proxy_servers.first; |
| // Only record UMA if the proxy isn't already on the retry list. |
| if (!params_->IsProxyBypassed( |
| @@ -176,7 +166,8 @@ bool DataReductionProxyBypassProtocol::MaybeBypassProxyAndPrepareToRetry( |
| proxy_server, |
| NULL)) { |
| DataReductionProxyUsageStats::RecordDataReductionProxyBypassInfo( |
| - !data_reduction_proxy_type_info.proxy_servers.second.is_empty(), |
| + data_reduction_proxy_type_info.proxy_servers.second.is_valid() && |
| + !data_reduction_proxy_type_info.proxy_servers.second.host_port_pair().IsEmpty(), |
|
bengr
2015/02/04 00:49:25
indent two more.
tbansal1
2015/02/04 22:49:10
Done.
|
| data_reduction_proxy_info.bypass_all, |
| proxy_server, |
| bypass_type); |