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

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

Issue 10987043: Receiving Connection: Proxy-Bypass induces proxy fallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fallback without modifying proxy_list during the transaction. Created 8 years, 2 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
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/string_tokenizer.h" 9 #include "base/string_tokenizer.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 for (; iter != proxies_.end(); ++iter) { 119 for (; iter != proxies_.end(); ++iter) {
120 if (!proxy_list.empty()) 120 if (!proxy_list.empty())
121 proxy_list += ";"; 121 proxy_list += ";";
122 proxy_list += iter->ToPacString(); 122 proxy_list += iter->ToPacString();
123 } 123 }
124 return proxy_list.empty() ? std::string() : proxy_list; 124 return proxy_list.empty() ? std::string() : proxy_list;
125 } 125 }
126 126
127 bool ProxyList::Fallback(ProxyRetryInfoMap* proxy_retry_info, 127 bool ProxyList::Fallback(ProxyRetryInfoMap* proxy_retry_info,
128 const BoundNetLog& net_log) { 128 const BoundNetLog& net_log) {
129 // Number of minutes to wait before retrying a bad proxy server.
130 const TimeDelta kProxyRetryDelay = TimeDelta::FromMinutes(5);
131 129
132 // TODO(eroman): It would be good if instead of removing failed proxies 130 // TODO(eroman): It would be good if instead of removing failed proxies
133 // from the list, we simply annotated them with the error code they failed 131 // from the list, we simply annotated them with the error code they failed
134 // with. Of course, ProxyService::ReconsiderProxyAfterError() would need to 132 // with. Of course, ProxyService::ReconsiderProxyAfterError() would need to
135 // be given this information by the network transaction. 133 // be given this information by the network transaction.
136 // 134 //
137 // The advantage of this approach is when the network transaction 135 // The advantage of this approach is when the network transaction
138 // fails, we could output the full list of proxies that were attempted, and 136 // fails, we could output the full list of proxies that were attempted, and
139 // why each one of those failed (as opposed to just the last failure). 137 // why each one of those failed (as opposed to just the last failure).
140 // 138 //
141 // And also, before failing the transaction wholesale, we could go back and 139 // And also, before failing the transaction wholesale, we could go back and
142 // retry the "bad proxies" which we never tried to begin with. 140 // retry the "bad proxies" which we never tried to begin with.
143 // (RemoveBadProxies would annotate them as 'expected bad' rather then delete 141 // (RemoveBadProxies would annotate them as 'expected bad' rather then delete
144 // them from the list, so we would know what they were). 142 // them from the list, so we would know what they were).
145 143
146 if (proxies_.empty()) { 144 if (proxies_.empty()) {
147 NOTREACHED(); 145 NOTREACHED();
148 return false; 146 return false;
149 } 147 }
148 UpdateRetryInfoOnFallback(proxy_retry_info, net_log);
149
150 // Remove this proxy from our list.
151 proxies_.erase(proxies_.begin());
152 return !proxies_.empty();
153 }
154
155 void ProxyList::UpdateRetryInfoOnFallback(
156 ProxyRetryInfoMap* proxy_retry_info, const BoundNetLog& net_log) const {
157 // Number of minutes to wait before retrying a bad proxy server.
158 const TimeDelta kProxyRetryDelay = TimeDelta::FromMinutes(5);
159
160 if (proxies_.empty()) {
161 NOTREACHED();
162 return;
163 }
150 164
151 if (!proxies_[0].is_direct()) { 165 if (!proxies_[0].is_direct()) {
152 std::string key = proxies_[0].ToURI(); 166 std::string key = proxies_[0].ToURI();
153 // Mark this proxy as bad. 167 // Mark this proxy as bad.
154 ProxyRetryInfoMap::iterator iter = proxy_retry_info->find(key); 168 ProxyRetryInfoMap::iterator iter = proxy_retry_info->find(key);
155 if (iter != proxy_retry_info->end()) { 169 if (iter != proxy_retry_info->end()) {
156 // TODO(nsylvain): This is not the first time we get this. We should 170 // TODO(nsylvain): This is not the first time we get this. We should
157 // double the retry time. Bug 997660. 171 // double the retry time. Bug 997660.
158 iter->second.bad_until = TimeTicks::Now() + iter->second.current_delay; 172 iter->second.bad_until = TimeTicks::Now() + iter->second.current_delay;
159 } else { 173 } else {
160 ProxyRetryInfo retry_info; 174 ProxyRetryInfo retry_info;
161 retry_info.current_delay = kProxyRetryDelay; 175 retry_info.current_delay = kProxyRetryDelay;
162 retry_info.bad_until = TimeTicks().Now() + retry_info.current_delay; 176 retry_info.bad_until = TimeTicks().Now() + retry_info.current_delay;
163 (*proxy_retry_info)[key] = retry_info; 177 (*proxy_retry_info)[key] = retry_info;
164 } 178 }
165 net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK, 179 net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK,
166 NetLog::StringCallback("bad_proxy", &key)); 180 NetLog::StringCallback("bad_proxy", &key));
167 } 181 }
168
169 // Remove this proxy from our list.
170 proxies_.erase(proxies_.begin());
171
172 return !proxies_.empty();
173 } 182 }
174 183
175 } // namespace net 184 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_list.h ('k') | net/proxy/proxy_service.h » ('j') | net/proxy/proxy_service.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698