Chromium Code Reviews| 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..bc8cc5adab00b78a342c66f4aa32794f7cb02a05 100644 |
| --- a/components/data_reduction_proxy/browser/data_reduction_proxy_params.cc |
| +++ b/components/data_reduction_proxy/browser/data_reduction_proxy_params.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/metrics/field_trial.h" |
|
bengr
2014/07/21 22:23:56
#include "base/time/time.h"
megjablon
2014/07/22 02:11:30
Done.
|
| #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h" |
| #include "net/proxy/proxy_info.h" |
| +#include "net/proxy/proxy_retry_info.h" |
| #include "net/proxy/proxy_service.h" |
| #include "net/url_request/url_request.h" |
| #include "net/url_request/url_request_context.h" |
| @@ -161,7 +162,6 @@ bool DataReductionProxyParams::Init( |
| } |
| - |
| void DataReductionProxyParams::InitWithoutChecks() { |
| const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| std::string origin; |
| @@ -329,6 +329,91 @@ std::string DataReductionProxyParams::GetDefaultDevOrigin() const { |
| return std::string(); |
| } |
| +bool DataReductionProxyParams::AreDataReductionProxiesBypassed( |
| + const net::URLRequest& request, base::TimeDelta* delay_seconds) const { |
| + DCHECK(request.context()); |
| + if (request.context() == NULL || |
| + request.context()->proxy_service() == NULL) { |
| + return AreProxiesBypassed( |
| + request.context()->proxy_service()->proxy_retry_info(), |
| + request.url().SchemeIs(url::kHttpsScheme), |
| + delay_seconds); |
| + } |
| + |
| + return false; |
| +} |
| + |
| +bool DataReductionProxyParams::AreProxiesBypassed( |
| + const net::ProxyRetryInfoMap& retry_map, |
| + bool is_https, |
| + base::TimeDelta* delay_seconds) const { |
| + if (retry_map.size() == 0) |
| + return false; |
| + |
| + if (is_https && alt_allowed_) { |
| + if (ArePrimaryAndFallbackBypassed( |
| + retry_map, ssl_origin_, GURL(), delay_seconds)) { |
| + return true; |
| + } |
| + } else { |
| + if (allowed_) { |
| + if (ArePrimaryAndFallbackBypassed(retry_map, |
|
bengr
2014/07/21 22:23:57
Here and below you can probably fit all parameters
megjablon
2014/07/22 02:11:29
Done.
|
| + origin_, |
| + fallback_origin_, |
| + delay_seconds)) { |
| + return true; |
| + } |
| + } |
| + |
| + if (alt_allowed_) { |
| + if (ArePrimaryAndFallbackBypassed(retry_map, |
| + alt_origin_, |
| + alt_fallback_origin_, |
| + delay_seconds)) { |
| + return true; |
| + } |
| + } |
| + } |
| + |
| + return false; |
| +} |
| + |
| +bool DataReductionProxyParams::ArePrimaryAndFallbackBypassed( |
| + const net::ProxyRetryInfoMap& retry_map, |
| + const GURL& primary, |
| + const GURL& fallback, |
| + base::TimeDelta* delay_seconds) const { |
|
bengr
2014/07/21 22:23:57
This is no longer in seconds and it otherwise vagu
megjablon
2014/07/22 02:11:29
Done.
|
| + base::TimeDelta shortest_delay; |
| + net::ProxyRetryInfoMap::const_iterator found; |
| + |
| + found = retry_map.find( |
| + net::ProxyServer(primary.SchemeIs(url::kHttpsScheme) ? |
| + net::ProxyServer::SCHEME_HTTPS : net::ProxyServer::SCHEME_HTTP, |
|
bengr
2014/07/21 22:23:56
#include "net/proxy/proxy_server.h"
megjablon
2014/07/22 02:11:29
Done.
|
| + net::HostPortPair::FromURL(primary)).ToURI()); |
| + if (!(found == retry_map.end())) { |
| + shortest_delay = found->second.current_delay; |
|
bengr
2014/07/21 22:23:57
There are only two possible delays, so this should
megjablon
2014/07/22 02:11:30
Done.
|
| + if (fallback_allowed_ && fallback.is_valid()) { |
| + found = retry_map.find( |
| + net::ProxyServer(fallback.SchemeIs(url::kHttpsScheme) ? |
|
bengr
2014/07/21 22:23:57
#include "url/url_constants.h"
megjablon
2014/07/22 02:11:29
Done.
|
| + net::ProxyServer::SCHEME_HTTPS : net::ProxyServer::SCHEME_HTTP, |
| + net::HostPortPair::FromURL(fallback)).ToURI()); |
|
bengr
2014/07/21 22:23:56
#include "net/base/host_port_pair.h"
megjablon
2014/07/22 02:11:30
Done.
|
| + if (!(found == retry_map.end())) { |
| + if(shortest_delay > found->second.current_delay) |
| + shortest_delay = found->second.current_delay; |
| + if (delay_seconds != NULL) |
| + *delay_seconds = shortest_delay; |
| + return true; |
| + } |
| + } else { |
| + if (delay_seconds != NULL) |
| + *delay_seconds = shortest_delay; |
| + return true; |
| + } |
| + } |
| + |
| + return false; |
| +} |
| + |
| std::string DataReductionProxyParams::GetDefaultOrigin() const { |
| #if defined(SPDY_PROXY_AUTH_ORIGIN) |
| return SPDY_PROXY_AUTH_ORIGIN; |