Chromium Code Reviews| Index: chrome/browser/net/pref_proxy_config_tracker_impl.cc |
| diff --git a/chrome/browser/net/pref_proxy_config_tracker_impl.cc b/chrome/browser/net/pref_proxy_config_tracker_impl.cc |
| index 49161ba7564b6119dba89c9f8a7dffb6913092f4..dce4de8ebf77dbd8ca88cfd957f83482ff8a1e97 100644 |
| --- a/chrome/browser/net/pref_proxy_config_tracker_impl.cc |
| +++ b/chrome/browser/net/pref_proxy_config_tracker_impl.cc |
| @@ -5,6 +5,7 @@ |
| #include "chrome/browser/net/pref_proxy_config_tracker_impl.h" |
| #include "base/bind.h" |
| +#include "base/metrics/histogram_macros.h" |
| #include "base/prefs/pref_registry_simple.h" |
| #include "base/prefs/pref_service.h" |
| #include "base/strings/string_util.h" |
| @@ -30,10 +31,8 @@ bool IsGooglezipDataReductionProxy(const net::ProxyServer& proxy) { |
| } |
| // Removes any Data Reduction Proxies like *.googlezip.net from |proxy_list|. |
| -void RemoveGooglezipDataReductionProxiesFromList(net::ProxyList* proxy_list) { |
| - if (proxy_list->IsEmpty()) |
| - return; |
| - |
| +// Returns true if any proxies were removed from |proxy_list|, false otherwise. |
| +bool RemoveGooglezipDataReductionProxiesFromList(net::ProxyList* proxy_list) { |
| bool found_googlezip_proxy = false; |
| for (const net::ProxyServer& proxy : proxy_list->GetAll()) { |
| if (IsGooglezipDataReductionProxy(proxy)) { |
| @@ -42,7 +41,7 @@ void RemoveGooglezipDataReductionProxiesFromList(net::ProxyList* proxy_list) { |
| } |
| } |
| if (!found_googlezip_proxy) |
| - return; |
| + return false; |
| net::ProxyList replacement_list; |
| for (const net::ProxyServer& proxy : proxy_list->GetAll()) { |
| @@ -53,6 +52,14 @@ void RemoveGooglezipDataReductionProxiesFromList(net::ProxyList* proxy_list) { |
| if (replacement_list.IsEmpty()) |
| replacement_list.AddProxyServer(net::ProxyServer::Direct()); |
| *proxy_list = replacement_list; |
| + return true; |
| +} |
| + |
| +void RecordGooglezipProxyRemovalResultHistogram( |
| + PrefProxyConfigTrackerImpl::GooglezipProxyRemovalResult result) { |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Net.PrefProxyConfig.GooglezipProxyRemovalResult", result, |
| + PrefProxyConfigTrackerImpl::GOOGLEZIP_PROXY_REMOVAL_RESULT_MAX); |
| } |
| // Remove any Data Reduction Proxies like *.googlezip.net from |proxy_rules|. |
| @@ -61,17 +68,27 @@ void RemoveGooglezipDataReductionProxiesFromList(net::ProxyList* proxy_list) { |
| // the Data Reduction Proxy without adding any of the necessary authentication |
| // headers or applying the Data Reduction Proxy bypass logic. See |
| // http://crbug.com/476610. |
| -// TODO(sclittle): Add UMA to record how often this method is called, and how |
| -// often it actually removes a *.googlezip.net proxy. This method should be |
| -// removed once it stops actually finding and removing *.googlezip.net proxies |
| -// from the proxy rules. |
| +// TODO(sclittle): This method should be removed once the UMA indicates that |
| +// *.googlezip.net proxies are no longer present in the |proxy_rules|. |
| void RemoveGooglezipDataReductionProxies( |
| net::ProxyConfig::ProxyRules* proxy_rules) { |
| - RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->fallback_proxies); |
| - RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_ftp); |
| - RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_http); |
| - RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_https); |
| - RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->single_proxies); |
| + if (RemoveGooglezipDataReductionProxiesFromList( |
| + &proxy_rules->fallback_proxies) | |
|
Alexei Svitkine (slow)
2015/05/14 20:46:34
Nit: Are you using bitwise OR's to avoid short-cir
sclittle
2015/05/14 20:56:29
Done.
|
| + RemoveGooglezipDataReductionProxiesFromList( |
| + &proxy_rules->proxies_for_ftp) | |
| + RemoveGooglezipDataReductionProxiesFromList( |
| + &proxy_rules->proxies_for_http) | |
| + RemoveGooglezipDataReductionProxiesFromList( |
| + &proxy_rules->proxies_for_https) | |
| + RemoveGooglezipDataReductionProxiesFromList( |
| + &proxy_rules->single_proxies)) { |
| + RecordGooglezipProxyRemovalResultHistogram( |
| + PrefProxyConfigTrackerImpl:: |
| + GOOGLEZIP_PROXY_REMOVAL_RESULT_FOUND_AND_REMOVED); |
| + } else { |
| + RecordGooglezipProxyRemovalResultHistogram( |
| + PrefProxyConfigTrackerImpl::GOOGLEZIP_PROXY_REMOVAL_RESULT_NOT_FOUND); |
| + } |
| } |
| } // namespace |