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

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

Issue 1212643009: Allow for an existing bad proxy to be given a new retry delay. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2403
Patch Set: Created 5 years, 5 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 | net/proxy/proxy_list_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) 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_list.h" 5 #include "net/proxy/proxy_list.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_tokenizer.h" 9 #include "base/strings/string_tokenizer.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 return !proxies_.empty(); 180 return !proxies_.empty();
181 } 181 }
182 182
183 void ProxyList::AddProxyToRetryList(ProxyRetryInfoMap* proxy_retry_info, 183 void ProxyList::AddProxyToRetryList(ProxyRetryInfoMap* proxy_retry_info,
184 base::TimeDelta retry_delay, 184 base::TimeDelta retry_delay,
185 bool try_while_bad, 185 bool try_while_bad,
186 const ProxyServer& proxy_to_retry, 186 const ProxyServer& proxy_to_retry,
187 int net_error, 187 int net_error,
188 const BoundNetLog& net_log) const { 188 const BoundNetLog& net_log) const {
189 // Mark this proxy as bad. 189 // Mark this proxy as bad.
190 TimeTicks bad_until = TimeTicks::Now() + retry_delay;
190 std::string proxy_key = proxy_to_retry.ToURI(); 191 std::string proxy_key = proxy_to_retry.ToURI();
191 ProxyRetryInfoMap::iterator iter = proxy_retry_info->find(proxy_key); 192 ProxyRetryInfoMap::iterator iter = proxy_retry_info->find(proxy_key);
192 if (iter != proxy_retry_info->end()) { 193 if (iter == proxy_retry_info->end() || bad_until > iter->second.bad_until) {
193 // TODO(nsylvain): This is not the first time we get this. We should
194 // double the retry time. Bug 997660.
195 iter->second.bad_until = TimeTicks::Now() + iter->second.current_delay;
196 } else {
197 ProxyRetryInfo retry_info; 194 ProxyRetryInfo retry_info;
198 retry_info.current_delay = retry_delay; 195 retry_info.current_delay = retry_delay;
199 retry_info.bad_until = TimeTicks().Now() + retry_info.current_delay; 196 retry_info.bad_until = bad_until;
200 retry_info.try_while_bad = try_while_bad; 197 retry_info.try_while_bad = try_while_bad;
201 retry_info.net_error = net_error; 198 retry_info.net_error = net_error;
202 (*proxy_retry_info)[proxy_key] = retry_info; 199 (*proxy_retry_info)[proxy_key] = retry_info;
203 } 200 }
204 net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK, 201 net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK,
205 NetLog::StringCallback("bad_proxy", &proxy_key)); 202 NetLog::StringCallback("bad_proxy", &proxy_key));
206 } 203 }
207 204
208 void ProxyList::UpdateRetryInfoOnFallback( 205 void ProxyList::UpdateRetryInfoOnFallback(
209 ProxyRetryInfoMap* proxy_retry_info, 206 ProxyRetryInfoMap* proxy_retry_info,
(...skipping 19 matching lines...) Expand all
229 // If any additional proxies to bypass are specified, add to the retry map 226 // If any additional proxies to bypass are specified, add to the retry map
230 // as well. 227 // as well.
231 for (const ProxyServer& additional_proxy : additional_proxies_to_bypass) { 228 for (const ProxyServer& additional_proxy : additional_proxies_to_bypass) {
232 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider, 229 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider,
233 additional_proxy, net_error, net_log); 230 additional_proxy, net_error, net_log);
234 } 231 }
235 } 232 }
236 } 233 }
237 234
238 } // namespace net 235 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/proxy/proxy_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698