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: net/proxy/proxy_list.cc

Issue 14623026: Merge 199288 "Randomize proxy timeout on Android over a range." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1500/src/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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/rand_util.h"
9 #include "base/strings/string_tokenizer.h" 10 #include "base/strings/string_tokenizer.h"
10 #include "base/time.h" 11 #include "base/time.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "net/proxy/proxy_server.h" 13 #include "net/proxy/proxy_server.h"
13 14
14 using base::TimeDelta; 15 using base::TimeDelta;
15 using base::TimeTicks; 16 using base::TimeTicks;
16 17
17 namespace net { 18 namespace net {
18 19
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 187 }
187 UpdateRetryInfoOnFallback(proxy_retry_info, net_log); 188 UpdateRetryInfoOnFallback(proxy_retry_info, net_log);
188 189
189 // Remove this proxy from our list. 190 // Remove this proxy from our list.
190 proxies_.erase(proxies_.begin()); 191 proxies_.erase(proxies_.begin());
191 return !proxies_.empty(); 192 return !proxies_.empty();
192 } 193 }
193 194
194 void ProxyList::UpdateRetryInfoOnFallback( 195 void ProxyList::UpdateRetryInfoOnFallback(
195 ProxyRetryInfoMap* proxy_retry_info, const BoundNetLog& net_log) const { 196 ProxyRetryInfoMap* proxy_retry_info, const BoundNetLog& net_log) const {
196 // Number of minutes to wait before retrying a bad proxy server. 197 // Time to wait before retrying a bad proxy server.
197 #if defined(OS_ANDROID) 198 #if defined(OS_ANDROID)
198 const TimeDelta kProxyRetryDelay = TimeDelta::FromMinutes(1); 199 // Randomize the timeout over a range from one to five minutes.
200 const TimeDelta proxy_retry_delay =
201 TimeDelta::FromMilliseconds(base::RandInt(1 * 60 * 1000, 5 * 60 * 1000));
199 #else 202 #else
200 const TimeDelta kProxyRetryDelay = TimeDelta::FromMinutes(5); 203 const TimeDelta proxy_retry_delay = TimeDelta::FromMinutes(5);
201 #endif 204 #endif
202 205
203 if (proxies_.empty()) { 206 if (proxies_.empty()) {
204 NOTREACHED(); 207 NOTREACHED();
205 return; 208 return;
206 } 209 }
207 210
208 if (!proxies_[0].is_direct()) { 211 if (!proxies_[0].is_direct()) {
209 std::string key = proxies_[0].ToURI(); 212 std::string key = proxies_[0].ToURI();
210 // Mark this proxy as bad. 213 // Mark this proxy as bad.
211 ProxyRetryInfoMap::iterator iter = proxy_retry_info->find(key); 214 ProxyRetryInfoMap::iterator iter = proxy_retry_info->find(key);
212 if (iter != proxy_retry_info->end()) { 215 if (iter != proxy_retry_info->end()) {
213 // TODO(nsylvain): This is not the first time we get this. We should 216 // TODO(nsylvain): This is not the first time we get this. We should
214 // double the retry time. Bug 997660. 217 // double the retry time. Bug 997660.
215 iter->second.bad_until = TimeTicks::Now() + iter->second.current_delay; 218 iter->second.bad_until = TimeTicks::Now() + iter->second.current_delay;
216 } else { 219 } else {
217 ProxyRetryInfo retry_info; 220 ProxyRetryInfo retry_info;
218 retry_info.current_delay = kProxyRetryDelay; 221 retry_info.current_delay = proxy_retry_delay;
219 retry_info.bad_until = TimeTicks().Now() + retry_info.current_delay; 222 retry_info.bad_until = TimeTicks().Now() + retry_info.current_delay;
220 (*proxy_retry_info)[key] = retry_info; 223 (*proxy_retry_info)[key] = retry_info;
221 } 224 }
222 net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK, 225 net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK,
223 NetLog::StringCallback("bad_proxy", &key)); 226 NetLog::StringCallback("bad_proxy", &key));
224 } 227 }
225 } 228 }
226 229
227 } // namespace net 230 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698