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

Unified Diff: components/data_reduction_proxy/browser/data_reduction_proxy_params.cc

Issue 390533003: Bypassed Bytes UMAs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed WereDataReductionProxiesBypassed Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
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..e58518cc4c208592ff36b1a335d3a40e85f0e096 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_params.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_params.cc
@@ -18,6 +18,8 @@ namespace {
const char kEnabled[] = "Enabled";
}
+using namespace net;
+
namespace data_reduction_proxy {
// static
@@ -329,6 +331,82 @@ std::string DataReductionProxyParams::GetDefaultDevOrigin() const {
return std::string();
}
+bool WerePrimaryAndFallbackBypassed(
+ const net::ProxyRetryInfoMap& retry_map,
+ GURL primary,
+ GURL fallback,
+ bool fallback_allowed,
+ int64* delay_seconds) {
+ int64 shortest_delay = 0;
+ net::ProxyRetryInfoMap::const_iterator found;
+
+ std::string proxy = net::HostPortPair::FromURL(primary).ToString();
+ // The retry list has the scheme prefix for https but not for http.
+ if (primary.SchemeIs(url::kHttpsScheme))
+ proxy = std::string("https://") + proxy;
+
+ found = retry_map.find(proxy);
+ if (!(found == retry_map.end())) {
+ shortest_delay = found->second.current_delay.InSeconds();
+ if (fallback_allowed) {
+ proxy = net::HostPortPair::FromURL(fallback).ToString();
+ found = retry_map.find(proxy);
+ if (!(found == retry_map.end())) {
+ if(shortest_delay > found->second.current_delay.InSeconds())
+ shortest_delay = found->second.current_delay.InSeconds();
+ if (delay_seconds != NULL)
+ *delay_seconds = shortest_delay;
+ return true;
+ }
+ } else {
+ if (delay_seconds != NULL)
+ *delay_seconds = shortest_delay;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool DataReductionProxyParams::WereDataReductionProxiesBypassed(
+ const net::URLRequest* request, int64* delay_seconds) const {
+ DCHECK(request);
+ DCHECK(request->context());
+ DCHECK(request->context()->proxy_service());
+
+ const net::ProxyRetryInfoMap& retry_map =
+ request->context()->proxy_service()->proxy_retry_info();
+ if (retry_map.size() == 0)
+ return false;
+
+ if(allowed_) {
+ if (WerePrimaryAndFallbackBypassed(retry_map,
+ origin_,
+ fallback_origin_,
+ fallback_allowed_,
+ delay_seconds)) {
+ return true;
+ }
+ }
+
+ if (alt_allowed_) {
+ if (WerePrimaryAndFallbackBypassed(retry_map,
+ alt_origin_,
+ alt_fallback_origin_,
+ fallback_allowed_,
+ delay_seconds)) {
+ return true;
+ }
+
+ if (WerePrimaryAndFallbackBypassed(
+ retry_map, ssl_origin_, GURL(), false, delay_seconds)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
std::string DataReductionProxyParams::GetDefaultOrigin() const {
#if defined(SPDY_PROXY_AUTH_ORIGIN)
return SPDY_PROXY_AUTH_ORIGIN;

Powered by Google App Engine
This is Rietveld 408576698