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

Side by Side Diff: chrome/browser/net/pref_proxy_config_tracker_impl.cc

Issue 1145513004: Record UMA when googlezip proxies are removed from the proxy config. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed to report number of proxies removed Created 5 years, 7 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 | chrome/browser/net/pref_proxy_config_tracker_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/net/pref_proxy_config_tracker_impl.h" 5 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram_macros.h"
8 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
9 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/prefs/proxy_config_dictionary.h" 14 #include "chrome/browser/prefs/proxy_config_dictionary.h"
14 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
15 #include "components/pref_registry/pref_registry_syncable.h" 16 #include "components/pref_registry/pref_registry_syncable.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/notification_details.h" 18 #include "content/public/browser/notification_details.h"
18 #include "content/public/browser/notification_source.h" 19 #include "content/public/browser/notification_source.h"
19 #include "net/proxy/proxy_list.h" 20 #include "net/proxy/proxy_list.h"
20 #include "net/proxy/proxy_server.h" 21 #include "net/proxy/proxy_server.h"
21 22
22 using content::BrowserThread; 23 using content::BrowserThread;
23 24
24 namespace { 25 namespace {
25 26
26 // Determine if |proxy| is of the form "*.googlezip.net". 27 // Determine if |proxy| is of the form "*.googlezip.net".
27 bool IsGooglezipDataReductionProxy(const net::ProxyServer& proxy) { 28 bool IsGooglezipDataReductionProxy(const net::ProxyServer& proxy) {
28 return proxy.is_valid() && !proxy.is_direct() && 29 return proxy.is_valid() && !proxy.is_direct() &&
29 EndsWith(proxy.host_port_pair().host(), ".googlezip.net", true); 30 EndsWith(proxy.host_port_pair().host(), ".googlezip.net", true);
30 } 31 }
31 32
32 // Removes any Data Reduction Proxies like *.googlezip.net from |proxy_list|. 33 // Removes any Data Reduction Proxies like *.googlezip.net from |proxy_list|.
33 void RemoveGooglezipDataReductionProxiesFromList(net::ProxyList* proxy_list) { 34 // Returns the number of proxies that were removed from |proxy_list|.
34 if (proxy_list->IsEmpty()) 35 size_t RemoveGooglezipDataReductionProxiesFromList(net::ProxyList* proxy_list) {
35 return;
36
37 bool found_googlezip_proxy = false; 36 bool found_googlezip_proxy = false;
38 for (const net::ProxyServer& proxy : proxy_list->GetAll()) { 37 for (const net::ProxyServer& proxy : proxy_list->GetAll()) {
39 if (IsGooglezipDataReductionProxy(proxy)) { 38 if (IsGooglezipDataReductionProxy(proxy)) {
40 found_googlezip_proxy = true; 39 found_googlezip_proxy = true;
41 break; 40 break;
42 } 41 }
43 } 42 }
44 if (!found_googlezip_proxy) 43 if (!found_googlezip_proxy)
45 return; 44 return 0;
46 45
46 size_t num_removed_proxies = 0;
47 net::ProxyList replacement_list; 47 net::ProxyList replacement_list;
48 for (const net::ProxyServer& proxy : proxy_list->GetAll()) { 48 for (const net::ProxyServer& proxy : proxy_list->GetAll()) {
49 if (!IsGooglezipDataReductionProxy(proxy)) 49 if (!IsGooglezipDataReductionProxy(proxy))
50 replacement_list.AddProxyServer(proxy); 50 replacement_list.AddProxyServer(proxy);
51 else
52 ++num_removed_proxies;
51 } 53 }
52 54
53 if (replacement_list.IsEmpty()) 55 if (replacement_list.IsEmpty())
54 replacement_list.AddProxyServer(net::ProxyServer::Direct()); 56 replacement_list.AddProxyServer(net::ProxyServer::Direct());
55 *proxy_list = replacement_list; 57 *proxy_list = replacement_list;
58 return num_removed_proxies;
56 } 59 }
57 60
58 // Remove any Data Reduction Proxies like *.googlezip.net from |proxy_rules|. 61 // Remove any Data Reduction Proxies like *.googlezip.net from |proxy_rules|.
59 // This is to prevent a Data Reduction Proxy from being activated in an 62 // This is to prevent a Data Reduction Proxy from being activated in an
60 // unsupported way, such as from a proxy pref, which could cause Chrome to use 63 // unsupported way, such as from a proxy pref, which could cause Chrome to use
61 // the Data Reduction Proxy without adding any of the necessary authentication 64 // the Data Reduction Proxy without adding any of the necessary authentication
62 // headers or applying the Data Reduction Proxy bypass logic. See 65 // headers or applying the Data Reduction Proxy bypass logic. See
63 // http://crbug.com/476610. 66 // http://crbug.com/476610.
64 // TODO(sclittle): Add UMA to record how often this method is called, and how 67 // TODO(sclittle): This method should be removed once the UMA indicates that
65 // often it actually removes a *.googlezip.net proxy. This method should be 68 // *.googlezip.net proxies are no longer present in the |proxy_rules|.
66 // removed once it stops actually finding and removing *.googlezip.net proxies
67 // from the proxy rules.
68 void RemoveGooglezipDataReductionProxies( 69 void RemoveGooglezipDataReductionProxies(
69 net::ProxyConfig::ProxyRules* proxy_rules) { 70 net::ProxyConfig::ProxyRules* proxy_rules) {
70 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->fallback_proxies); 71 size_t num_removed_proxies =
71 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_ftp); 72 RemoveGooglezipDataReductionProxiesFromList(
72 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_http); 73 &proxy_rules->fallback_proxies) +
73 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_https); 74 RemoveGooglezipDataReductionProxiesFromList(
74 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->single_proxies); 75 &proxy_rules->proxies_for_ftp) +
76 RemoveGooglezipDataReductionProxiesFromList(
77 &proxy_rules->proxies_for_http) +
78 RemoveGooglezipDataReductionProxiesFromList(
79 &proxy_rules->proxies_for_https) +
80 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->single_proxies);
81
82 UMA_HISTOGRAM_COUNTS_100("Net.PrefProxyConfig.GooglezipProxyRemovalCount",
83 num_removed_proxies);
75 } 84 }
76 85
77 } // namespace 86 } // namespace
78 87
79 //============================= ChromeProxyConfigService ======================= 88 //============================= ChromeProxyConfigService =======================
80 89
81 ChromeProxyConfigService::ChromeProxyConfigService( 90 ChromeProxyConfigService::ChromeProxyConfigService(
82 net::ProxyConfigService* base_service) 91 net::ProxyConfigService* base_service)
83 : base_service_(base_service), 92 : base_service_(base_service),
84 pref_config_state_(ProxyPrefs::CONFIG_UNSET), 93 pref_config_state_(ProxyPrefs::CONFIG_UNSET),
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 (config_state_ != ProxyPrefs::CONFIG_UNSET && 424 (config_state_ != ProxyPrefs::CONFIG_UNSET &&
416 !pref_config_.Equals(new_config))) { 425 !pref_config_.Equals(new_config))) {
417 config_state_ = config_state; 426 config_state_ = config_state;
418 if (config_state_ != ProxyPrefs::CONFIG_UNSET) 427 if (config_state_ != ProxyPrefs::CONFIG_UNSET)
419 pref_config_ = new_config; 428 pref_config_ = new_config;
420 update_pending_ = true; 429 update_pending_ = true;
421 } 430 }
422 if (update_pending_) 431 if (update_pending_)
423 OnProxyConfigChanged(config_state, new_config); 432 OnProxyConfigChanged(config_state, new_config);
424 } 433 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/pref_proxy_config_tracker_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698