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..33af3588b809464fd40de89cb32b5445c36ab168 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,87 @@ 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_) { |
+ return ArePrimaryAndFallbackBypassed( |
+ retry_map, ssl_origin_, GURL(), min_retry_delay); |
+ } else { |
Alexei Svitkine (slow)
2014/07/22 18:50:18
No else after early return.
megjablon
2014/07/22 21:41:45
Done.
|
+ if (allowed_) { |
+ if (ArePrimaryAndFallbackBypassed( |
Alexei Svitkine (slow)
2014/07/22 18:50:18
I think you misunderstood my previous comment. My
megjablon
2014/07/22 21:41:45
Ahh that makes much more sense. Fixed.
|
+ retry_map, origin_, fallback_origin_, min_retry_delay)) { |
+ return true; |
+ } |
+ } |
+ |
+ if (alt_allowed_) { |
+ if (ArePrimaryAndFallbackBypassed( |
+ 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( |
Alexei Svitkine (slow)
2014/07/22 18:50:18
nit: just put = on the previous line and wrap afte
megjablon
2014/07/22 21:41:45
Done.
|
+ net::ProxyServer(primary.SchemeIs(url::kHttpsScheme) ? |
+ net::ProxyServer::SCHEME_HTTPS : net::ProxyServer::SCHEME_HTTP, |
+ net::HostPortPair::FromURL(primary)).ToURI()); |
+ |
+ if (found == retry_map.end()) { |
+ return false; |
Alexei Svitkine (slow)
2014/07/22 18:50:18
Nit: No need for {}'s since body is one line.
megjablon
2014/07/22 21:41:45
Done.
|
+ } |
+ |
+ min_delay = found->second.current_delay; |
Alexei Svitkine (slow)
2014/07/22 18:50:18
Just declare min_delay and assign to it here, inst
megjablon
2014/07/22 21:41:45
Done.
|
+ if (!fallback_allowed_ || !fallback.is_valid()) { |
+ if (min_retry_delay != NULL) |
+ *min_retry_delay = min_delay; |
+ return true; |
+ } |
+ |
+ 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()) { |
+ return false; |
Alexei Svitkine (slow)
2014/07/22 18:50:18
Nit: No need for {}'s
megjablon
2014/07/22 21:41:45
Done.
|
+ } |
+ |
+ if (min_delay > found->second.current_delay) |
+ min_delay = found->second.current_delay; |
+ if (min_retry_delay != NULL) |
+ *min_retry_delay = min_delay; |
+ return true; |
+} |
+ |
std::string DataReductionProxyParams::GetDefaultOrigin() const { |
#if defined(SPDY_PROXY_AUTH_ORIGIN) |
return SPDY_PROXY_AUTH_ORIGIN; |