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

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

Issue 382313003: Add data reduction functionality to all platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed code review comments by asvitkine@. Created 6 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
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"
10 #include "base/strings/string_tokenizer.h" 9 #include "base/strings/string_tokenizer.h"
11 #include "base/time/time.h" 10 #include "base/time/time.h"
12 #include "base/values.h" 11 #include "base/values.h"
13 #include "net/proxy/proxy_server.h" 12 #include "net/proxy/proxy_server.h"
14 13
15 using base::TimeDelta; 14 using base::TimeDelta;
16 using base::TimeTicks; 15 using base::TimeTicks;
17 16
18 namespace net { 17 namespace net {
19 18
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // 159 //
161 // And also, before failing the transaction wholesale, we could go back and 160 // And also, before failing the transaction wholesale, we could go back and
162 // retry the "bad proxies" which we never tried to begin with. 161 // retry the "bad proxies" which we never tried to begin with.
163 // (RemoveBadProxies would annotate them as 'expected bad' rather then delete 162 // (RemoveBadProxies would annotate them as 'expected bad' rather then delete
164 // them from the list, so we would know what they were). 163 // them from the list, so we would know what they were).
165 164
166 if (proxies_.empty()) { 165 if (proxies_.empty()) {
167 NOTREACHED(); 166 NOTREACHED();
168 return false; 167 return false;
169 } 168 }
170 UpdateRetryInfoOnFallback(proxy_retry_info, base::TimeDelta(), true, 169 UpdateRetryInfoOnFallback(proxy_retry_info, TimeDelta::FromMinutes(5), true,
bengr 2014/07/21 22:45:16 Add a comment that say by default proxies are not
Not at Google. Contact bengr 2014/07/22 00:12:09 Done.
171 ProxyServer(), net_log); 170 ProxyServer(), net_log);
172 171
173 // Remove this proxy from our list. 172 // Remove this proxy from our list.
174 proxies_.erase(proxies_.begin()); 173 proxies_.erase(proxies_.begin());
175 return !proxies_.empty(); 174 return !proxies_.empty();
176 } 175 }
177 176
178 void ProxyList::AddProxyToRetryList(ProxyRetryInfoMap* proxy_retry_info, 177 void ProxyList::AddProxyToRetryList(ProxyRetryInfoMap* proxy_retry_info,
179 base::TimeDelta retry_delay, 178 base::TimeDelta retry_delay,
180 bool try_while_bad, 179 bool try_while_bad,
(...skipping 16 matching lines...) Expand all
197 net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK, 196 net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK,
198 NetLog::StringCallback("bad_proxy", &proxy_key)); 197 NetLog::StringCallback("bad_proxy", &proxy_key));
199 } 198 }
200 199
201 void ProxyList::UpdateRetryInfoOnFallback( 200 void ProxyList::UpdateRetryInfoOnFallback(
202 ProxyRetryInfoMap* proxy_retry_info, 201 ProxyRetryInfoMap* proxy_retry_info,
203 base::TimeDelta retry_delay, 202 base::TimeDelta retry_delay,
204 bool reconsider, 203 bool reconsider,
205 const ProxyServer& another_proxy_to_bypass, 204 const ProxyServer& another_proxy_to_bypass,
206 const BoundNetLog& net_log) const { 205 const BoundNetLog& net_log) const {
207 // Time to wait before retrying a bad proxy server. 206 DCHECK(retry_delay != base::TimeDelta());
208 if (retry_delay == base::TimeDelta()) {
209 #if defined(SPDY_PROXY_AUTH_ORIGIN)
210 // Randomize the timeout over a range from one to five minutes.
211 retry_delay =
212 TimeDelta::FromMilliseconds(
213 base::RandInt(1 * 60 * 1000, 5 * 60 * 1000));
214 #else
215 retry_delay = TimeDelta::FromMinutes(5);
216 #endif
217 }
218
219 if (proxies_.empty()) { 207 if (proxies_.empty()) {
220 NOTREACHED(); 208 NOTREACHED();
221 return; 209 return;
222 } 210 }
223 211
224 if (!proxies_[0].is_direct()) { 212 if (!proxies_[0].is_direct()) {
225 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider, proxies_[0], 213 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider, proxies_[0],
226 net_log); 214 net_log);
227 215
228 // If an additional proxy to bypass is specified, add it to the retry map 216 // If an additional proxy to bypass is specified, add it to the retry map
229 // as well. 217 // as well.
230 if (another_proxy_to_bypass.is_valid()) { 218 if (another_proxy_to_bypass.is_valid()) {
231 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider, 219 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider,
232 another_proxy_to_bypass, net_log); 220 another_proxy_to_bypass, net_log);
233 } 221 }
234 } 222 }
235 } 223 }
236 224
237 } // namespace net 225 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698