Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 return false; | 393 return false; |
| 394 } | 394 } |
| 395 | 395 |
| 396 bool DataReductionProxyParams::AreProxiesBypassed( | 396 bool DataReductionProxyParams::AreProxiesBypassed( |
| 397 const net::ProxyRetryInfoMap& retry_map, | 397 const net::ProxyRetryInfoMap& retry_map, |
| 398 bool is_https, | 398 bool is_https, |
| 399 base::TimeDelta* min_retry_delay) const { | 399 base::TimeDelta* min_retry_delay) const { |
| 400 if (retry_map.size() == 0) | 400 if (retry_map.size() == 0) |
| 401 return false; | 401 return false; |
| 402 | 402 |
| 403 if (is_https && alt_allowed_) { | 403 // If the request is https, consider only the ssl proxy. |
| 404 return ArePrimaryAndFallbackBypassed( | 404 if (is_https) { |
| 405 retry_map, ssl_origin_, GURL(), min_retry_delay); | 405 if (alt_allowed_) { |
| 406 return ArePrimaryAndFallbackBypassed( | |
| 407 retry_map, ssl_origin_, GURL(), min_retry_delay); | |
| 408 } else { | |
| 409 NOTREACHED(); | |
| 410 return false; | |
| 411 } | |
| 406 } | 412 } |
| 407 | 413 |
| 408 if (allowed_ && ArePrimaryAndFallbackBypassed( | 414 if (allowed_ && ArePrimaryAndFallbackBypassed( |
| 409 retry_map, origin_, fallback_origin_, min_retry_delay)) { | 415 retry_map, origin_, fallback_origin_, min_retry_delay)) { |
| 410 return true; | 416 return true; |
| 411 } | 417 } |
| 412 | 418 |
| 413 if (alt_allowed_ && ArePrimaryAndFallbackBypassed( | 419 if (alt_allowed_ && ArePrimaryAndFallbackBypassed( |
| 414 retry_map, alt_origin_, alt_fallback_origin_, min_retry_delay)) { | 420 retry_map, alt_origin_, alt_fallback_origin_, min_retry_delay)) { |
| 415 return true; | 421 return true; |
| 416 } | 422 } |
| 417 | 423 |
| 418 return false; | 424 return false; |
| 419 } | 425 } |
| 420 | 426 |
| 421 bool DataReductionProxyParams::ArePrimaryAndFallbackBypassed( | 427 bool DataReductionProxyParams::ArePrimaryAndFallbackBypassed( |
| 422 const net::ProxyRetryInfoMap& retry_map, | 428 const net::ProxyRetryInfoMap& retry_map, |
| 423 const GURL& primary, | 429 const GURL& primary, |
| 424 const GURL& fallback, | 430 const GURL& fallback, |
| 425 base::TimeDelta* min_retry_delay) const { | 431 base::TimeDelta* min_retry_delay) const { |
| 432 // Look for the primary proxy in the retry map. This must be done before | |
| 433 // looking for the fallback in order to assign |min_retry_delay| if the | |
| 434 // primary proxy has a shorter delay. | |
| 435 base::TimeDelta delay; | |
| 426 net::ProxyRetryInfoMap::const_iterator found = retry_map.find( | 436 net::ProxyRetryInfoMap::const_iterator found = retry_map.find( |
| 427 net::ProxyServer(primary.SchemeIs(url::kHttpsScheme) ? | 437 net::ProxyServer(primary.SchemeIs(url::kHttpsScheme) ? |
| 428 net::ProxyServer::SCHEME_HTTPS : net::ProxyServer::SCHEME_HTTP, | 438 net::ProxyServer::SCHEME_HTTPS : |
| 429 net::HostPortPair::FromURL(primary)).ToURI()); | 439 net::ProxyServer::SCHEME_HTTP, |
| 440 net::HostPortPair::FromURL(primary)).ToURI()); | |
| 441 if (found != retry_map.end()) { | |
|
bengr
2014/08/15 06:16:06
You don't have to do this work if !fallback_allowe
bengr
2014/08/15 17:58:56
I see. This is needed.
| |
| 442 delay = found->second.current_delay; | |
| 443 } | |
| 444 | |
| 445 if (fallback_allowed_ && fallback.is_valid()) { | |
| 446 // If fallback is allowed, only the fallback proxy needs to be on the retry | |
| 447 // map to know if there was a bypass. We can reset found and forget if the | |
| 448 // primary was on the retry map. | |
| 449 found = retry_map.find( | |
| 450 net::ProxyServer(fallback.SchemeIs(url::kHttpsScheme) ? | |
| 451 net::ProxyServer::SCHEME_HTTPS : | |
| 452 net::ProxyServer::SCHEME_HTTP, | |
| 453 net::HostPortPair::FromURL(fallback)).ToURI()); | |
| 454 if (found != retry_map.end() && | |
| 455 delay > found->second.current_delay) { | |
| 456 delay = found->second.current_delay; | |
|
bengr
2014/08/15 06:16:05
Does this work? If the primary proxy is not found
megjablon
2014/08/15 19:04:23
Added in setting delay to max to fix.
| |
| 457 } | |
| 458 } | |
| 459 | |
| 460 if (min_retry_delay != NULL) { | |
| 461 *min_retry_delay = delay; | |
| 462 } | |
| 430 | 463 |
| 431 if (found == retry_map.end()) | 464 if (found == retry_map.end()) |
| 432 return false; | 465 return false; |
| 433 | |
| 434 base::TimeDelta min_delay = found->second.current_delay; | |
| 435 if (!fallback_allowed_ || !fallback.is_valid()) { | |
| 436 if (min_retry_delay != NULL) | |
| 437 *min_retry_delay = min_delay; | |
| 438 return true; | |
| 439 } | |
| 440 | |
| 441 found = retry_map.find( | |
| 442 net::ProxyServer(fallback.SchemeIs(url::kHttpsScheme) ? | |
| 443 net::ProxyServer::SCHEME_HTTPS : net::ProxyServer::SCHEME_HTTP, | |
| 444 net::HostPortPair::FromURL(fallback)).ToURI()); | |
| 445 | |
| 446 if (found == retry_map.end()) | |
| 447 return false; | |
| 448 | |
| 449 if (min_delay > found->second.current_delay) | |
| 450 min_delay = found->second.current_delay; | |
| 451 if (min_retry_delay != NULL) | |
| 452 *min_retry_delay = min_delay; | |
| 453 return true; | 466 return true; |
| 454 } | 467 } |
| 455 | 468 |
| 456 std::string DataReductionProxyParams::GetDefaultOrigin() const { | 469 std::string DataReductionProxyParams::GetDefaultOrigin() const { |
| 457 #if defined(SPDY_PROXY_AUTH_ORIGIN) | 470 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
| 458 return SPDY_PROXY_AUTH_ORIGIN; | 471 return SPDY_PROXY_AUTH_ORIGIN; |
| 459 #endif | 472 #endif |
| 460 return std::string(); | 473 return std::string(); |
| 461 } | 474 } |
| 462 | 475 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 } | 509 } |
| 497 | 510 |
| 498 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { | 511 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { |
| 499 #if defined(DATA_REDUCTION_PROXY_WARMUP_URL) | 512 #if defined(DATA_REDUCTION_PROXY_WARMUP_URL) |
| 500 return DATA_REDUCTION_PROXY_WARMUP_URL; | 513 return DATA_REDUCTION_PROXY_WARMUP_URL; |
| 501 #endif | 514 #endif |
| 502 return std::string(); | 515 return std::string(); |
| 503 } | 516 } |
| 504 | 517 |
| 505 } // namespace data_reduction_proxy | 518 } // namespace data_reduction_proxy |
| OLD | NEW |