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

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: 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
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 true if any proxies were removed from |proxy_list|, false otherwise.
34 if (proxy_list->IsEmpty()) 35 bool 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 false;
46 45
47 net::ProxyList replacement_list; 46 net::ProxyList replacement_list;
48 for (const net::ProxyServer& proxy : proxy_list->GetAll()) { 47 for (const net::ProxyServer& proxy : proxy_list->GetAll()) {
49 if (!IsGooglezipDataReductionProxy(proxy)) 48 if (!IsGooglezipDataReductionProxy(proxy))
50 replacement_list.AddProxyServer(proxy); 49 replacement_list.AddProxyServer(proxy);
51 } 50 }
52 51
53 if (replacement_list.IsEmpty()) 52 if (replacement_list.IsEmpty())
54 replacement_list.AddProxyServer(net::ProxyServer::Direct()); 53 replacement_list.AddProxyServer(net::ProxyServer::Direct());
55 *proxy_list = replacement_list; 54 *proxy_list = replacement_list;
55 return true;
56 }
57
58 void RecordGooglezipProxyRemovalResultHistogram(
59 PrefProxyConfigTrackerImpl::GooglezipProxyRemovalResult result) {
60 UMA_HISTOGRAM_ENUMERATION(
61 "Net.PrefProxyConfig.GooglezipProxyRemovalResult", result,
62 PrefProxyConfigTrackerImpl::GOOGLEZIP_PROXY_REMOVAL_RESULT_MAX);
56 } 63 }
57 64
58 // Remove any Data Reduction Proxies like *.googlezip.net from |proxy_rules|. 65 // 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 66 // 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 67 // 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 68 // the Data Reduction Proxy without adding any of the necessary authentication
62 // headers or applying the Data Reduction Proxy bypass logic. See 69 // headers or applying the Data Reduction Proxy bypass logic. See
63 // http://crbug.com/476610. 70 // http://crbug.com/476610.
64 // TODO(sclittle): Add UMA to record how often this method is called, and how 71 // 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 72 // *.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( 73 void RemoveGooglezipDataReductionProxies(
69 net::ProxyConfig::ProxyRules* proxy_rules) { 74 net::ProxyConfig::ProxyRules* proxy_rules) {
70 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->fallback_proxies); 75 if (RemoveGooglezipDataReductionProxiesFromList(
71 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_ftp); 76 &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.
72 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_http); 77 RemoveGooglezipDataReductionProxiesFromList(
73 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_https); 78 &proxy_rules->proxies_for_ftp) |
74 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->single_proxies); 79 RemoveGooglezipDataReductionProxiesFromList(
80 &proxy_rules->proxies_for_http) |
81 RemoveGooglezipDataReductionProxiesFromList(
82 &proxy_rules->proxies_for_https) |
83 RemoveGooglezipDataReductionProxiesFromList(
84 &proxy_rules->single_proxies)) {
85 RecordGooglezipProxyRemovalResultHistogram(
86 PrefProxyConfigTrackerImpl::
87 GOOGLEZIP_PROXY_REMOVAL_RESULT_FOUND_AND_REMOVED);
88 } else {
89 RecordGooglezipProxyRemovalResultHistogram(
90 PrefProxyConfigTrackerImpl::GOOGLEZIP_PROXY_REMOVAL_RESULT_NOT_FOUND);
91 }
75 } 92 }
76 93
77 } // namespace 94 } // namespace
78 95
79 //============================= ChromeProxyConfigService ======================= 96 //============================= ChromeProxyConfigService =======================
80 97
81 ChromeProxyConfigService::ChromeProxyConfigService( 98 ChromeProxyConfigService::ChromeProxyConfigService(
82 net::ProxyConfigService* base_service) 99 net::ProxyConfigService* base_service)
83 : base_service_(base_service), 100 : base_service_(base_service),
84 pref_config_state_(ProxyPrefs::CONFIG_UNSET), 101 pref_config_state_(ProxyPrefs::CONFIG_UNSET),
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 (config_state_ != ProxyPrefs::CONFIG_UNSET && 432 (config_state_ != ProxyPrefs::CONFIG_UNSET &&
416 !pref_config_.Equals(new_config))) { 433 !pref_config_.Equals(new_config))) {
417 config_state_ = config_state; 434 config_state_ = config_state;
418 if (config_state_ != ProxyPrefs::CONFIG_UNSET) 435 if (config_state_ != ProxyPrefs::CONFIG_UNSET)
419 pref_config_ = new_config; 436 pref_config_ = new_config;
420 update_pending_ = true; 437 update_pending_ = true;
421 } 438 }
422 if (update_pending_) 439 if (update_pending_)
423 OnProxyConfigChanged(config_state, new_config); 440 OnProxyConfigChanged(config_state, new_config);
424 } 441 }
OLDNEW
« no previous file with comments | « chrome/browser/net/pref_proxy_config_tracker_impl.h ('k') | 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