Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(728)

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_params.cc

Issue 464023002: Fixed DataReductionProxyParams::AreProxiesBypassed logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h " 10 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h "
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 return false; 353 return false;
354 } 354 }
355 355
356 bool DataReductionProxyParams::AreProxiesBypassed( 356 bool DataReductionProxyParams::AreProxiesBypassed(
357 const net::ProxyRetryInfoMap& retry_map, 357 const net::ProxyRetryInfoMap& retry_map,
358 bool is_https, 358 bool is_https,
359 base::TimeDelta* min_retry_delay) const { 359 base::TimeDelta* min_retry_delay) const {
360 if (retry_map.size() == 0) 360 if (retry_map.size() == 0)
361 return false; 361 return false;
362 362
363 if (min_retry_delay != NULL)
364 *min_retry_delay = base::TimeDelta::Max();
365
363 if (is_https && alt_allowed_) { 366 if (is_https && alt_allowed_) {
364 return ArePrimaryAndFallbackBypassed( 367 return ArePrimaryAndFallbackBypassed(
365 retry_map, ssl_origin_, GURL(), min_retry_delay); 368 retry_map, ssl_origin_, GURL(), min_retry_delay);
366 } 369 }
367 370
368 if (allowed_ && ArePrimaryAndFallbackBypassed( 371 if (allowed_ && ArePrimaryAndFallbackBypassed(
369 retry_map, origin_, fallback_origin_, min_retry_delay)) { 372 retry_map, origin_, fallback_origin_, min_retry_delay)) {
370 return true; 373 return true;
megjablon 2014/08/12 21:06:54 Ben, with the proxy logic does this work for min_r
371 } 374 }
372 375
373 if (alt_allowed_ && ArePrimaryAndFallbackBypassed( 376 if (alt_allowed_ && ArePrimaryAndFallbackBypassed(
374 retry_map, alt_origin_, alt_fallback_origin_, min_retry_delay)) { 377 retry_map, alt_origin_, alt_fallback_origin_, min_retry_delay)) {
375 return true; 378 return true;
376 } 379 }
377 380
378 return false; 381 return false;
379 } 382 }
380 383
381 bool DataReductionProxyParams::ArePrimaryAndFallbackBypassed( 384 bool DataReductionProxyParams::ArePrimaryAndFallbackBypassed(
382 const net::ProxyRetryInfoMap& retry_map, 385 const net::ProxyRetryInfoMap& retry_map,
383 const GURL& primary, 386 const GURL& primary,
384 const GURL& fallback, 387 const GURL& fallback,
385 base::TimeDelta* min_retry_delay) const { 388 base::TimeDelta* min_retry_delay) const {
386 net::ProxyRetryInfoMap::const_iterator found = retry_map.find( 389 net::ProxyRetryInfoMap::const_iterator found = retry_map.find(
387 net::ProxyServer(primary.SchemeIs(url::kHttpsScheme) ? 390 net::ProxyServer(primary.SchemeIs(url::kHttpsScheme) ?
388 net::ProxyServer::SCHEME_HTTPS : net::ProxyServer::SCHEME_HTTP, 391 net::ProxyServer::SCHEME_HTTPS : net::ProxyServer::SCHEME_HTTP,
389 net::HostPortPair::FromURL(primary)).ToURI()); 392 net::HostPortPair::FromURL(primary)).ToURI());
393 if (found != retry_map.end() &&
394 min_retry_delay != NULL &&
395 *min_retry_delay > found->second.current_delay) {
396 *min_retry_delay = found->second.current_delay;
397 }
398
399 if (fallback_allowed_ && fallback.is_valid()) {
400 found = retry_map.find(
401 net::ProxyServer(fallback.SchemeIs(url::kHttpsScheme) ?
402 net::ProxyServer::SCHEME_HTTPS : net::ProxyServer::SCHEME_HTTP,
403 net::HostPortPair::FromURL(fallback)).ToURI());
404 if (found != retry_map.end() &&
405 min_retry_delay != NULL &&
406 *min_retry_delay > found->second.current_delay) {
407 *min_retry_delay = found->second.current_delay;
408 }
409 }
390 410
391 if (found == retry_map.end()) 411 if (found == retry_map.end())
392 return false; 412 return false;
393
394 base::TimeDelta min_delay = found->second.current_delay;
395 if (!fallback_allowed_ || !fallback.is_valid()) {
396 if (min_retry_delay != NULL)
397 *min_retry_delay = min_delay;
398 return true;
399 }
400
401 found = retry_map.find(
402 net::ProxyServer(fallback.SchemeIs(url::kHttpsScheme) ?
403 net::ProxyServer::SCHEME_HTTPS : net::ProxyServer::SCHEME_HTTP,
404 net::HostPortPair::FromURL(fallback)).ToURI());
405
406 if (found == retry_map.end())
407 return false;
408
409 if (min_delay > found->second.current_delay)
410 min_delay = found->second.current_delay;
411 if (min_retry_delay != NULL)
412 *min_retry_delay = min_delay;
413 return true; 413 return true;
414 } 414 }
415 415
416 std::string DataReductionProxyParams::GetDefaultOrigin() const { 416 std::string DataReductionProxyParams::GetDefaultOrigin() const {
417 #if defined(SPDY_PROXY_AUTH_ORIGIN) 417 #if defined(SPDY_PROXY_AUTH_ORIGIN)
418 return SPDY_PROXY_AUTH_ORIGIN; 418 return SPDY_PROXY_AUTH_ORIGIN;
419 #endif 419 #endif
420 return std::string(); 420 return std::string();
421 } 421 }
422 422
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 456 }
457 457
458 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { 458 std::string DataReductionProxyParams::GetDefaultWarmupURL() const {
459 #if defined(DATA_REDUCTION_PROXY_WARMUP_URL) 459 #if defined(DATA_REDUCTION_PROXY_WARMUP_URL)
460 return DATA_REDUCTION_PROXY_WARMUP_URL; 460 return DATA_REDUCTION_PROXY_WARMUP_URL;
461 #endif 461 #endif
462 return std::string(); 462 return std::string();
463 } 463 }
464 464
465 } // namespace data_reduction_proxy 465 } // namespace data_reduction_proxy
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698