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

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

Issue 473513002: Keep track of network error in ProxyRetryInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge to head. Created 6 years, 4 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 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 proxy_retry_info_.clear(); 1204 proxy_retry_info_.clear();
1205 return ResolveProxy(url, load_flags, result, callback, pac_request, 1205 return ResolveProxy(url, load_flags, result, callback, pac_request,
1206 network_delegate, net_log); 1206 network_delegate, net_log);
1207 } 1207 }
1208 1208
1209 DCHECK(!result->is_empty()); 1209 DCHECK(!result->is_empty());
1210 ProxyServer bad_proxy = result->proxy_server(); 1210 ProxyServer bad_proxy = result->proxy_server();
1211 1211
1212 // We don't have new proxy settings to try, try to fallback to the next proxy 1212 // We don't have new proxy settings to try, try to fallback to the next proxy
1213 // in the list. 1213 // in the list.
1214 bool did_fallback = result->Fallback(net_log); 1214 bool did_fallback = result->Fallback(net_error, net_log);
1215
1216 if (network_delegate) {
1217 network_delegate->NotifyProxyFallback(bad_proxy, net_error, did_fallback);
1218 }
1219 1215
1220 // Return synchronous failure if there is nothing left to fall-back to. 1216 // Return synchronous failure if there is nothing left to fall-back to.
1221 // TODO(eroman): This is a yucky API, clean it up. 1217 // TODO(eroman): This is a yucky API, clean it up.
1222 return did_fallback ? OK : ERR_FAILED; 1218 return did_fallback ? OK : ERR_FAILED;
1223 } 1219 }
1224 1220
1225 bool ProxyService::MarkProxiesAsBadUntil( 1221 bool ProxyService::MarkProxiesAsBadUntil(
1226 const ProxyInfo& result, 1222 const ProxyInfo& result,
1227 base::TimeDelta retry_delay, 1223 base::TimeDelta retry_delay,
1228 const ProxyServer& another_bad_proxy, 1224 const ProxyServer& another_bad_proxy,
1229 const BoundNetLog& net_log) { 1225 const BoundNetLog& net_log) {
1230 result.proxy_list_.UpdateRetryInfoOnFallback(&proxy_retry_info_, retry_delay, 1226 result.proxy_list_.UpdateRetryInfoOnFallback(&proxy_retry_info_,
1227 retry_delay,
1231 false, 1228 false,
1232 another_bad_proxy, 1229 another_bad_proxy,
1230 OK,
Ryan Sleevi 2014/08/15 00:02:24 This is a little weird. When would this be called
Not at Google. Contact bengr 2014/08/15 17:26:59 Clarified in the .h file. MarkProxiesAsBadUntil is
1233 net_log); 1231 net_log);
1234 if (another_bad_proxy.is_valid()) 1232 if (another_bad_proxy.is_valid())
1235 return result.proxy_list_.size() > 2; 1233 return result.proxy_list_.size() > 2;
1236 else 1234 else
1237 return result.proxy_list_.size() > 1; 1235 return result.proxy_list_.size() > 1;
1238 } 1236 }
1239 1237
1240 void ProxyService::ReportSuccess(const ProxyInfo& result) { 1238 void ProxyService::ReportSuccess(const ProxyInfo& result,
1239 NetworkDelegate* network_delegate) {
1241 DCHECK(CalledOnValidThread()); 1240 DCHECK(CalledOnValidThread());
1242 1241
1243 const ProxyRetryInfoMap& new_retry_info = result.proxy_retry_info(); 1242 const ProxyRetryInfoMap& new_retry_info = result.proxy_retry_info();
1244 if (new_retry_info.empty()) 1243 if (new_retry_info.empty())
1245 return; 1244 return;
1246 1245
1247 for (ProxyRetryInfoMap::const_iterator iter = new_retry_info.begin(); 1246 for (ProxyRetryInfoMap::const_iterator iter = new_retry_info.begin();
1248 iter != new_retry_info.end(); ++iter) { 1247 iter != new_retry_info.end(); ++iter) {
1249 ProxyRetryInfoMap::iterator existing = proxy_retry_info_.find(iter->first); 1248 ProxyRetryInfoMap::iterator existing = proxy_retry_info_.find(iter->first);
1250 if (existing == proxy_retry_info_.end()) 1249 if (existing == proxy_retry_info_.end()) {
1251 proxy_retry_info_[iter->first] = iter->second; 1250 proxy_retry_info_[iter->first] = iter->second;
1251 if (network_delegate) {
1252 const ProxyRetryInfo& proxy_retry_info = iter->second;
1253 network_delegate->NotifyProxyFallback(result.proxy_server(),
1254 proxy_retry_info.net_error);
1255 }
1256 }
1252 else if (existing->second.bad_until < iter->second.bad_until) 1257 else if (existing->second.bad_until < iter->second.bad_until)
1253 existing->second.bad_until = iter->second.bad_until; 1258 existing->second.bad_until = iter->second.bad_until;
1254 } 1259 }
1255 if (net_log_) { 1260 if (net_log_) {
1256 net_log_->AddGlobalEntry( 1261 net_log_->AddGlobalEntry(
1257 NetLog::TYPE_BAD_PROXY_LIST_REPORTED, 1262 NetLog::TYPE_BAD_PROXY_LIST_REPORTED,
1258 base::Bind(&NetLogBadProxyListCallback, &new_retry_info)); 1263 base::Bind(&NetLogBadProxyListCallback, &new_retry_info));
1259 } 1264 }
1260 } 1265 }
1261 1266
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 State previous_state = ResetProxyConfig(false); 1560 State previous_state = ResetProxyConfig(false);
1556 if (previous_state != STATE_NONE) 1561 if (previous_state != STATE_NONE)
1557 ApplyProxyConfigIfAvailable(); 1562 ApplyProxyConfigIfAvailable();
1558 } 1563 }
1559 1564
1560 void ProxyService::OnDNSChanged() { 1565 void ProxyService::OnDNSChanged() {
1561 OnIPAddressChanged(); 1566 OnIPAddressChanged();
1562 } 1567 }
1563 1568
1564 } // namespace net 1569 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698