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

Side by Side Diff: net/proxy/proxy_service.cc

Issue 298883011: Record errors that trigger a data reduction proxy bypass (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 6 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/proxy/proxy_service.h" 5 #include "net/proxy/proxy_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 29 matching lines...) Expand all
40 #include "net/proxy/proxy_config_service_mac.h" 40 #include "net/proxy/proxy_config_service_mac.h"
41 #include "net/proxy/proxy_resolver_mac.h" 41 #include "net/proxy/proxy_resolver_mac.h"
42 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) 42 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
43 #include "net/proxy/proxy_config_service_linux.h" 43 #include "net/proxy/proxy_config_service_linux.h"
44 #elif defined(OS_ANDROID) 44 #elif defined(OS_ANDROID)
45 #include "net/proxy/proxy_config_service_android.h" 45 #include "net/proxy/proxy_config_service_android.h"
46 #endif 46 #endif
47 47
48 #if defined(SPDY_PROXY_AUTH_ORIGIN) 48 #if defined(SPDY_PROXY_AUTH_ORIGIN)
49 #include "base/metrics/histogram.h" 49 #include "base/metrics/histogram.h"
50 #include "base/metrics/sparse_histogram.h"
50 #endif 51 #endif
51 52
52 using base::TimeDelta; 53 using base::TimeDelta;
53 using base::TimeTicks; 54 using base::TimeTicks;
54 55
55 namespace net { 56 namespace net {
56 57
57 namespace { 58 namespace {
58 59
59 // When the IP address changes we don't immediately re-run proxy auto-config. 60 // When the IP address changes we don't immediately re-run proxy auto-config.
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 // due to ProxyScriptDeciderPoller. 1162 // due to ProxyScriptDeciderPoller.
1162 config_.set_id(fetched_config_.id()); 1163 config_.set_id(fetched_config_.id());
1163 config_.set_source(fetched_config_.source()); 1164 config_.set_source(fetched_config_.source());
1164 1165
1165 // Resume any requests which we had to defer until the PAC script was 1166 // Resume any requests which we had to defer until the PAC script was
1166 // downloaded. 1167 // downloaded.
1167 SetReady(); 1168 SetReady();
1168 } 1169 }
1169 1170
1170 int ProxyService::ReconsiderProxyAfterError(const GURL& url, 1171 int ProxyService::ReconsiderProxyAfterError(const GURL& url,
1172 int net_error,
1171 ProxyInfo* result, 1173 ProxyInfo* result,
1172 const CompletionCallback& callback, 1174 const CompletionCallback& callback,
1173 PacRequest** pac_request, 1175 PacRequest** pac_request,
1174 const BoundNetLog& net_log) { 1176 const BoundNetLog& net_log) {
1175 DCHECK(CalledOnValidThread()); 1177 DCHECK(CalledOnValidThread());
1176 1178
1177 // Check to see if we have a new config since ResolveProxy was called. We 1179 // Check to see if we have a new config since ResolveProxy was called. We
1178 // want to re-run ResolveProxy in two cases: 1) we have a new config, or 2) a 1180 // want to re-run ResolveProxy in two cases: 1) we have a new config, or 2) a
1179 // direct connection failed and we never tried the current config. 1181 // direct connection failed and we never tried the current config.
1180 1182
1181 bool re_resolve = result->config_id_ != config_.id(); 1183 bool re_resolve = result->config_id_ != config_.id();
1182 1184
1183 if (re_resolve) { 1185 if (re_resolve) {
1184 // If we have a new config or the config was never tried, we delete the 1186 // If we have a new config or the config was never tried, we delete the
1185 // list of bad proxies and we try again. 1187 // list of bad proxies and we try again.
1186 proxy_retry_info_.clear(); 1188 proxy_retry_info_.clear();
1187 return ResolveProxy(url, result, callback, pac_request, net_log); 1189 return ResolveProxy(url, result, callback, pac_request, net_log);
1188 } 1190 }
1189 1191
1190 #if defined(SPDY_PROXY_AUTH_ORIGIN) 1192 #if defined(SPDY_PROXY_AUTH_ORIGIN)
1191 if (result->proxy_server().isDataReductionProxy()) { 1193 if (result->proxy_server().isDataReductionProxy()) {
1192 RecordDataReductionProxyBypassInfo( 1194 RecordDataReductionProxyBypassInfo(
1193 true, result->proxy_server(), ERROR_BYPASS); 1195 true, result->proxy_server(), ERROR_BYPASS);
1196 RecordDataReductionProxyBypassOnNetworkError(
1197 true, result->proxy_server(), net_error);
mef 2014/05/28 15:39:57 is |is_primary| expected to be |true| in both case
bengr 2014/05/29 16:09:48 No. Only in the first case: if (result->proxy_serv
1194 } else if (result->proxy_server().isDataReductionProxyFallback()) { 1198 } else if (result->proxy_server().isDataReductionProxyFallback()) {
1195 RecordDataReductionProxyBypassInfo( 1199 RecordDataReductionProxyBypassInfo(
1196 false, result->proxy_server(), ERROR_BYPASS); 1200 false, result->proxy_server(), ERROR_BYPASS);
1201 RecordDataReductionProxyBypassOnNetworkError(
1202 true, result->proxy_server(), net_error);
1197 } 1203 }
1198 #endif 1204 #endif
1199 1205
1200 // We don't have new proxy settings to try, try to fallback to the next proxy 1206 // We don't have new proxy settings to try, try to fallback to the next proxy
1201 // in the list. 1207 // in the list.
1202 bool did_fallback = result->Fallback(net_log); 1208 bool did_fallback = result->Fallback(net_log);
1203 1209
1204 // Return synchronous failure if there is nothing left to fall-back to. 1210 // Return synchronous failure if there is nothing left to fall-back to.
1205 // TODO(eroman): This is a yucky API, clean it up. 1211 // TODO(eroman): This is a yucky API, clean it up.
1206 return did_fallback ? OK : ERR_FAILED; 1212 return did_fallback ? OK : ERR_FAILED;
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 return; 1438 return;
1433 1439
1434 if (is_primary) { 1440 if (is_primary) {
1435 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.BypassInfoPrimary", 1441 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.BypassInfoPrimary",
1436 bypass_type, BYPASS_EVENT_TYPE_MAX); 1442 bypass_type, BYPASS_EVENT_TYPE_MAX);
1437 } else { 1443 } else {
1438 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.BypassInfoFallback", 1444 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.BypassInfoFallback",
1439 bypass_type, BYPASS_EVENT_TYPE_MAX); 1445 bypass_type, BYPASS_EVENT_TYPE_MAX);
1440 } 1446 }
1441 } 1447 }
1448
1449 void ProxyService::RecordDataReductionProxyBypassOnNetworkError(
1450 bool is_primary,
1451 const ProxyServer& proxy_server,
1452 int net_error) {
1453 // Only record UMA if the proxy isn't already on the retry list.
1454 if (proxy_retry_info_.find(proxy_server.ToURI()) != proxy_retry_info_.end())
1455 return;
1456
1457 if (is_primary) {
1458 UMA_HISTOGRAM_SPARSE_SLOWLY(
1459 "DataReductionProxy.BypassOnNetworkErrorPrimary",
1460 std::abs(net_error));
1461 return;
1462 }
1463 UMA_HISTOGRAM_SPARSE_SLOWLY(
1464 "DataReductionProxy.BypassOnNetworkErrorFallback",
1465 std::abs(net_error));
1466 }
1442 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) 1467 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
1443 1468
1444 void ProxyService::OnProxyConfigChanged( 1469 void ProxyService::OnProxyConfigChanged(
1445 const ProxyConfig& config, 1470 const ProxyConfig& config,
1446 ProxyConfigService::ConfigAvailability availability) { 1471 ProxyConfigService::ConfigAvailability availability) {
1447 // Retrieve the current proxy configuration from the ProxyConfigService. 1472 // Retrieve the current proxy configuration from the ProxyConfigService.
1448 // If a configuration is not available yet, we will get called back later 1473 // If a configuration is not available yet, we will get called back later
1449 // by our ProxyConfigService::Observer once it changes. 1474 // by our ProxyConfigService::Observer once it changes.
1450 ProxyConfig effective_config; 1475 ProxyConfig effective_config;
1451 switch (availability) { 1476 switch (availability) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 1599
1575 event_.Wait(); 1600 event_.Wait();
1576 1601
1577 if (result_ == net::OK) { 1602 if (result_ == net::OK) {
1578 *proxy_info = proxy_info_; 1603 *proxy_info = proxy_info_;
1579 } 1604 }
1580 return result_; 1605 return result_;
1581 } 1606 }
1582 1607
1583 int SyncProxyServiceHelper::ReconsiderProxyAfterError( 1608 int SyncProxyServiceHelper::ReconsiderProxyAfterError(
1584 const GURL& url, ProxyInfo* proxy_info, const BoundNetLog& net_log) { 1609 const GURL& url, int net_error, ProxyInfo* proxy_info,
1610 const BoundNetLog& net_log) {
1585 DCHECK(io_message_loop_ != base::MessageLoop::current()); 1611 DCHECK(io_message_loop_ != base::MessageLoop::current());
1586 1612
1587 io_message_loop_->PostTask( 1613 io_message_loop_->PostTask(
1588 FROM_HERE, 1614 FROM_HERE,
1589 base::Bind(&SyncProxyServiceHelper::StartAsyncReconsider, this, url, 1615 base::Bind(&SyncProxyServiceHelper::StartAsyncReconsider, this, url,
1590 net_log)); 1616 net_error, net_log));
1591 1617
1592 event_.Wait(); 1618 event_.Wait();
1593 1619
1594 if (result_ == net::OK) { 1620 if (result_ == net::OK) {
1595 *proxy_info = proxy_info_; 1621 *proxy_info = proxy_info_;
1596 } 1622 }
1597 return result_; 1623 return result_;
1598 } 1624 }
1599 1625
1600 SyncProxyServiceHelper::~SyncProxyServiceHelper() {} 1626 SyncProxyServiceHelper::~SyncProxyServiceHelper() {}
1601 1627
1602 void SyncProxyServiceHelper::StartAsyncResolve(const GURL& url, 1628 void SyncProxyServiceHelper::StartAsyncResolve(const GURL& url,
1603 const BoundNetLog& net_log) { 1629 const BoundNetLog& net_log) {
1604 result_ = proxy_service_->ResolveProxy( 1630 result_ = proxy_service_->ResolveProxy(
1605 url, &proxy_info_, callback_, NULL, net_log); 1631 url, &proxy_info_, callback_, NULL, net_log);
1606 if (result_ != net::ERR_IO_PENDING) { 1632 if (result_ != net::ERR_IO_PENDING) {
1607 OnCompletion(result_); 1633 OnCompletion(result_);
1608 } 1634 }
1609 } 1635 }
1610 1636
1611 void SyncProxyServiceHelper::StartAsyncReconsider(const GURL& url, 1637 void SyncProxyServiceHelper::StartAsyncReconsider(const GURL& url,
1638 int net_error,
1612 const BoundNetLog& net_log) { 1639 const BoundNetLog& net_log) {
1613 result_ = proxy_service_->ReconsiderProxyAfterError( 1640 result_ = proxy_service_->ReconsiderProxyAfterError(
1614 url, &proxy_info_, callback_, NULL, net_log); 1641 url, net_error, &proxy_info_, callback_, NULL, net_log);
1615 if (result_ != net::ERR_IO_PENDING) { 1642 if (result_ != net::ERR_IO_PENDING) {
1616 OnCompletion(result_); 1643 OnCompletion(result_);
1617 } 1644 }
1618 } 1645 }
1619 1646
1620 void SyncProxyServiceHelper::OnCompletion(int rv) { 1647 void SyncProxyServiceHelper::OnCompletion(int rv) {
1621 result_ = rv; 1648 result_ = rv;
1622 event_.Signal(); 1649 event_.Signal();
1623 } 1650 }
1624 1651
1625 } // namespace net 1652 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698