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

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

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 years, 3 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/strings/string_tokenizer.h" 9 #include "base/strings/string_tokenizer.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 std::unique_ptr<base::ListValue> ProxyList::ToValue() const { 148 std::unique_ptr<base::ListValue> ProxyList::ToValue() const {
149 std::unique_ptr<base::ListValue> list(new base::ListValue()); 149 std::unique_ptr<base::ListValue> list(new base::ListValue());
150 for (size_t i = 0; i < proxies_.size(); ++i) 150 for (size_t i = 0; i < proxies_.size(); ++i)
151 list->AppendString(proxies_[i].ToURI()); 151 list->AppendString(proxies_[i].ToURI());
152 return list; 152 return list;
153 } 153 }
154 154
155 bool ProxyList::Fallback(ProxyRetryInfoMap* proxy_retry_info, 155 bool ProxyList::Fallback(ProxyRetryInfoMap* proxy_retry_info,
156 int net_error, 156 int net_error,
157 const BoundNetLog& net_log) { 157 const NetLogWithSource& net_log) {
158 // TODO(eroman): It would be good if instead of removing failed proxies 158 // TODO(eroman): It would be good if instead of removing failed proxies
159 // from the list, we simply annotated them with the error code they failed 159 // from the list, we simply annotated them with the error code they failed
160 // with. Of course, ProxyService::ReconsiderProxyAfterError() would need to 160 // with. Of course, ProxyService::ReconsiderProxyAfterError() would need to
161 // be given this information by the network transaction. 161 // be given this information by the network transaction.
162 // 162 //
163 // The advantage of this approach is when the network transaction 163 // The advantage of this approach is when the network transaction
164 // fails, we could output the full list of proxies that were attempted, and 164 // fails, we could output the full list of proxies that were attempted, and
165 // why each one of those failed (as opposed to just the last failure). 165 // why each one of those failed (as opposed to just the last failure).
166 // 166 //
167 // And also, before failing the transaction wholesale, we could go back and 167 // And also, before failing the transaction wholesale, we could go back and
(...skipping 12 matching lines...) Expand all
180 // Remove this proxy from our list. 180 // Remove this proxy from our list.
181 proxies_.erase(proxies_.begin()); 181 proxies_.erase(proxies_.begin());
182 return !proxies_.empty(); 182 return !proxies_.empty();
183 } 183 }
184 184
185 void ProxyList::AddProxyToRetryList(ProxyRetryInfoMap* proxy_retry_info, 185 void ProxyList::AddProxyToRetryList(ProxyRetryInfoMap* proxy_retry_info,
186 base::TimeDelta retry_delay, 186 base::TimeDelta retry_delay,
187 bool try_while_bad, 187 bool try_while_bad,
188 const ProxyServer& proxy_to_retry, 188 const ProxyServer& proxy_to_retry,
189 int net_error, 189 int net_error,
190 const BoundNetLog& net_log) const { 190 const NetLogWithSource& net_log) const {
191 // Mark this proxy as bad. 191 // Mark this proxy as bad.
192 TimeTicks bad_until = TimeTicks::Now() + retry_delay; 192 TimeTicks bad_until = TimeTicks::Now() + retry_delay;
193 std::string proxy_key = proxy_to_retry.ToURI(); 193 std::string proxy_key = proxy_to_retry.ToURI();
194 ProxyRetryInfoMap::iterator iter = proxy_retry_info->find(proxy_key); 194 ProxyRetryInfoMap::iterator iter = proxy_retry_info->find(proxy_key);
195 if (iter == proxy_retry_info->end() || bad_until > iter->second.bad_until) { 195 if (iter == proxy_retry_info->end() || bad_until > iter->second.bad_until) {
196 ProxyRetryInfo retry_info; 196 ProxyRetryInfo retry_info;
197 retry_info.current_delay = retry_delay; 197 retry_info.current_delay = retry_delay;
198 retry_info.bad_until = bad_until; 198 retry_info.bad_until = bad_until;
199 retry_info.try_while_bad = try_while_bad; 199 retry_info.try_while_bad = try_while_bad;
200 retry_info.net_error = net_error; 200 retry_info.net_error = net_error;
201 (*proxy_retry_info)[proxy_key] = retry_info; 201 (*proxy_retry_info)[proxy_key] = retry_info;
202 } 202 }
203 net_log.AddEvent(NetLogEventType::PROXY_LIST_FALLBACK, 203 net_log.AddEvent(NetLogEventType::PROXY_LIST_FALLBACK,
204 NetLog::StringCallback("bad_proxy", &proxy_key)); 204 NetLog::StringCallback("bad_proxy", &proxy_key));
205 } 205 }
206 206
207 void ProxyList::UpdateRetryInfoOnFallback( 207 void ProxyList::UpdateRetryInfoOnFallback(
208 ProxyRetryInfoMap* proxy_retry_info, 208 ProxyRetryInfoMap* proxy_retry_info,
209 base::TimeDelta retry_delay, 209 base::TimeDelta retry_delay,
210 bool reconsider, 210 bool reconsider,
211 const std::vector<ProxyServer>& additional_proxies_to_bypass, 211 const std::vector<ProxyServer>& additional_proxies_to_bypass,
212 int net_error, 212 int net_error,
213 const BoundNetLog& net_log) const { 213 const NetLogWithSource& net_log) const {
214 DCHECK(!retry_delay.is_zero()); 214 DCHECK(!retry_delay.is_zero());
215 215
216 if (proxies_.empty()) { 216 if (proxies_.empty()) {
217 NOTREACHED(); 217 NOTREACHED();
218 return; 218 return;
219 } 219 }
220 220
221 if (!proxies_[0].is_direct()) { 221 if (!proxies_[0].is_direct()) {
222 AddProxyToRetryList(proxy_retry_info, 222 AddProxyToRetryList(proxy_retry_info,
223 retry_delay, 223 retry_delay,
224 reconsider, 224 reconsider,
225 proxies_[0], 225 proxies_[0],
226 net_error, 226 net_error,
227 net_log); 227 net_log);
228 // If any additional proxies to bypass are specified, add to the retry map 228 // If any additional proxies to bypass are specified, add to the retry map
229 // as well. 229 // as well.
230 for (const ProxyServer& additional_proxy : additional_proxies_to_bypass) { 230 for (const ProxyServer& additional_proxy : additional_proxies_to_bypass) {
231 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider, 231 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider,
232 additional_proxy, net_error, net_log); 232 additional_proxy, net_error, net_log);
233 } 233 }
234 } 234 }
235 } 235 }
236 236
237 } // namespace net 237 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698