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 9d68955d6f41f6bcbe4c4fcf795227fe9eb59362..6ef6ac6cc1837f66d1dae841e11646a3886c024a 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 |
@@ -37,28 +37,21 @@ void MarkProxiesAsBadUntil( |
net::URLRequest* request, |
const base::TimeDelta& bypass_duration, |
bool bypass_all, |
- 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()); |
+ const std::vector<net::ProxyServer>& data_reduction_proxies) { |
+ DCHECK(!data_reduction_proxies.empty()); |
// Synthesize a suitable |ProxyInfo| to add the proxies to the |
// |ProxyRetryInfoMap| of the proxy service. |
net::ProxyList proxy_list; |
std::vector<net::ProxyServer> additional_bad_proxies; |
- 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_valid() && |
- !data_reduction_proxies.second.host_port_pair().IsEmpty()) |
- fallback = data_reduction_proxies.second; |
- if (fallback.is_valid()) { |
- proxy_list.AddProxyServer(fallback); |
- additional_bad_proxies.push_back(fallback); |
- } |
- proxy_list.AddProxyServer(net::ProxyServer::Direct()); |
+ for (const net::ProxyServer& proxy_server : data_reduction_proxies) { |
+ DCHECK(proxy_server.is_valid()); |
+ proxy_list.AddProxyServer(proxy_server); |
+ if (!bypass_all) |
+ break; |
+ additional_bad_proxies.push_back(proxy_server); |
} |
+ proxy_list.AddProxyServer(net::ProxyServer::Direct()); |
+ |
net::ProxyInfo proxy_info; |
proxy_info.UseProxyList(proxy_list); |
DCHECK(request->context()); |
@@ -123,10 +116,10 @@ bool DataReductionProxyBypassProtocol::MaybeBypassProxyAndPrepareToRetry( |
// then apply the bypass logic regardless. |
// TODO(sclittle): Remove this workaround once http://crbug.com/476610 is |
// fixed. |
- data_reduction_proxy_type_info.proxy_servers.first = net::ProxyServer( |
- net::ProxyServer::SCHEME_HTTPS, request->proxy_server()); |
- data_reduction_proxy_type_info.proxy_servers.second = net::ProxyServer( |
- net::ProxyServer::SCHEME_HTTP, request->proxy_server()); |
+ data_reduction_proxy_type_info.proxy_servers.push_back(net::ProxyServer( |
+ net::ProxyServer::SCHEME_HTTPS, request->proxy_server())); |
+ data_reduction_proxy_type_info.proxy_servers.push_back(net::ProxyServer( |
+ net::ProxyServer::SCHEME_HTTP, request->proxy_server())); |
data_reduction_proxy_type_info.is_alternative = false; |
data_reduction_proxy_type_info.is_fallback = false; |
data_reduction_proxy_type_info.is_ssl = |
@@ -139,18 +132,13 @@ bool DataReductionProxyBypassProtocol::MaybeBypassProxyAndPrepareToRetry( |
if (data_reduction_proxy_type_info.is_ssl) |
return false; |
- const net::ProxyServer& first = |
- data_reduction_proxy_type_info.proxy_servers.first; |
- if (!first.is_valid() || first.host_port_pair().IsEmpty()) |
+ if (data_reduction_proxy_type_info.proxy_servers.empty()) |
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. |
- const net::ProxyServer& second = |
- data_reduction_proxy_type_info.proxy_servers.second; |
DataReductionProxyBypassStats::DetectAndRecordMissingViaHeaderResponseCode( |
- second.is_valid() && !second.host_port_pair().IsEmpty(), |
- response_headers); |
+ !data_reduction_proxy_type_info.is_fallback, response_headers); |
if (DataReductionProxyParams:: |
IsIncludedInRelaxMissingViaHeaderOtherBypassFieldTrial() && |
@@ -188,14 +176,14 @@ bool DataReductionProxyBypassProtocol::MaybeBypassProxyAndPrepareToRetry( |
DCHECK(request->context()); |
DCHECK(request->context()->proxy_service()); |
net::ProxyServer proxy_server = |
- data_reduction_proxy_type_info.proxy_servers.first; |
+ data_reduction_proxy_type_info.proxy_servers.front(); |
// Only record UMA if the proxy isn't already on the retry list. |
if (!config_->IsProxyBypassed( |
request->context()->proxy_service()->proxy_retry_info(), proxy_server, |
NULL)) { |
DataReductionProxyBypassStats::RecordDataReductionProxyBypassInfo( |
- second.is_valid() && !second.host_port_pair().IsEmpty(), |
+ !data_reduction_proxy_type_info.is_fallback, |
data_reduction_proxy_info->bypass_all, proxy_server, bypass_type); |
} |
@@ -210,8 +198,8 @@ bool DataReductionProxyBypassProtocol::MaybeBypassProxyAndPrepareToRetry( |
} |
// Retry if block-once was specified or if method is idempotent. |
- return bypass_type == BYPASS_EVENT_TYPE_CURRENT || |
- IsRequestIdempotent(request); |
+ return bypass_type == BYPASS_EVENT_TYPE_CURRENT || |
+ IsRequestIdempotent(request); |
} |
// static |