Index: components/data_reduction_proxy/browser/data_reduction_proxy_params.cc |
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_params.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_params.cc |
index 64b2ec1040c4cc533310f3826651f2c22525cdbd..49596e190453ce8f22e90b4fbb101db8c19ebfa5 100644 |
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_params.cc |
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_params.cc |
@@ -6,11 +6,16 @@ |
#include "base/command_line.h" |
#include "base/metrics/field_trial.h" |
+#include "base/time/time.h" |
#include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h" |
+#include "net/base/host_port_pair.h" |
#include "net/proxy/proxy_info.h" |
+#include "net/proxy/proxy_retry_info.h" |
+#include "net/proxy/proxy_server.h" |
#include "net/proxy/proxy_service.h" |
#include "net/url_request/url_request.h" |
#include "net/url_request/url_request_context.h" |
+#include "url/url_constants.h" |
using base::FieldTrialList; |
@@ -161,7 +166,6 @@ bool DataReductionProxyParams::Init( |
} |
- |
void DataReductionProxyParams::InitWithoutChecks() { |
const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
std::string origin; |
@@ -329,6 +333,83 @@ std::string DataReductionProxyParams::GetDefaultDevOrigin() const { |
return std::string(); |
} |
+bool DataReductionProxyParams::AreDataReductionProxiesBypassed( |
+ const net::URLRequest& request, base::TimeDelta* min_retry_delay) const { |
+ if (request.context() != NULL && |
+ request.context()->proxy_service() != NULL) { |
+ return AreProxiesBypassed( |
+ request.context()->proxy_service()->proxy_retry_info(), |
+ request.url().SchemeIs(url::kHttpsScheme), |
+ min_retry_delay); |
+ } |
+ |
+ return false; |
+} |
+ |
+bool DataReductionProxyParams::AreProxiesBypassed( |
+ const net::ProxyRetryInfoMap& retry_map, |
+ bool is_https, |
+ base::TimeDelta* min_retry_delay) const { |
+ if (retry_map.size() == 0) |
+ return false; |
+ |
+ if (is_https && alt_allowed_) |
Alexei Svitkine (slow)
2014/07/22 13:57:21
Nit: Add {}'s
megjablon
2014/07/22 18:40:45
Done.
|
+ return ArePrimaryAndFallbackBypassed( |
+ retry_map, ssl_origin_, GURL(), min_retry_delay); |
+ |
+ if (allowed_) { |
+ if (ArePrimaryAndFallbackBypassed( |
Alexei Svitkine (slow)
2014/07/22 13:57:21
Nit: Merge with if above.
megjablon
2014/07/22 18:40:45
Done.
|
+ retry_map, origin_, fallback_origin_, min_retry_delay)) { |
+ return true; |
+ } |
+ } |
+ |
+ if (alt_allowed_) { |
+ if (ArePrimaryAndFallbackBypassed( |
Alexei Svitkine (slow)
2014/07/22 13:57:21
Nit: Merge with if above.
megjablon
2014/07/22 18:40:45
Done.
|
+ retry_map, alt_origin_, alt_fallback_origin_, min_retry_delay)) { |
+ return true; |
+ } |
+ } |
+ |
+ return false; |
+} |
+ |
+bool DataReductionProxyParams::ArePrimaryAndFallbackBypassed( |
+ const net::ProxyRetryInfoMap& retry_map, |
+ const GURL& primary, |
+ const GURL& fallback, |
+ base::TimeDelta* min_retry_delay) const { |
+ base::TimeDelta min_delay; |
+ net::ProxyRetryInfoMap::const_iterator found; |
+ |
+ found = retry_map.find( |
+ net::ProxyServer(primary.SchemeIs(url::kHttpsScheme) ? |
+ net::ProxyServer::SCHEME_HTTPS : net::ProxyServer::SCHEME_HTTP, |
+ net::HostPortPair::FromURL(primary)).ToURI()); |
+ if (!(found == retry_map.end())) { |
Alexei Svitkine (slow)
2014/07/22 13:57:21
Nit: Change to !=
megjablon
2014/07/22 18:40:45
Done.
|
+ min_delay = found->second.current_delay; |
+ if (fallback_allowed_ && fallback.is_valid()) { |
+ found = retry_map.find( |
+ net::ProxyServer(fallback.SchemeIs(url::kHttpsScheme) ? |
+ net::ProxyServer::SCHEME_HTTPS : net::ProxyServer::SCHEME_HTTP, |
+ net::HostPortPair::FromURL(fallback)).ToURI()); |
+ if (!(found == retry_map.end())) { |
+ if(min_delay > found->second.current_delay) |
Alexei Svitkine (slow)
2014/07/22 13:57:21
Nit: Add space after if
megjablon
2014/07/22 18:40:45
Done.
|
+ min_delay = found->second.current_delay; |
+ if (min_retry_delay != NULL) |
+ *min_retry_delay = min_delay; |
+ return true; |
+ } |
+ } else { |
Alexei Svitkine (slow)
2014/07/22 13:57:21
Nit: Reverse the cond of the if (make it check for
megjablon
2014/07/22 18:40:45
Done.
|
+ if (min_retry_delay != NULL) |
+ *min_retry_delay = min_delay; |
+ return true; |
+ } |
+ } |
+ |
+ return false; |
+} |
+ |
std::string DataReductionProxyParams::GetDefaultOrigin() const { |
#if defined(SPDY_PROXY_AUTH_ORIGIN) |
return SPDY_PROXY_AUTH_ORIGIN; |