OLD | NEW |
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 std::string proxy_list; | 135 std::string proxy_list; |
136 std::vector<ProxyServer>::const_iterator iter = proxies_.begin(); | 136 std::vector<ProxyServer>::const_iterator iter = proxies_.begin(); |
137 for (; iter != proxies_.end(); ++iter) { | 137 for (; iter != proxies_.end(); ++iter) { |
138 if (!proxy_list.empty()) | 138 if (!proxy_list.empty()) |
139 proxy_list += ";"; | 139 proxy_list += ";"; |
140 proxy_list += iter->ToPacString(); | 140 proxy_list += iter->ToPacString(); |
141 } | 141 } |
142 return proxy_list.empty() ? std::string() : proxy_list; | 142 return proxy_list.empty() ? std::string() : proxy_list; |
143 } | 143 } |
144 | 144 |
145 base::ListValue* ProxyList::ToValue() const { | 145 scoped_ptr<base::ListValue> ProxyList::ToValue() const { |
146 scoped_ptr<base::ListValue> list(new base::ListValue()); | 146 scoped_ptr<base::ListValue> list(new base::ListValue()); |
147 for (size_t i = 0; i < proxies_.size(); ++i) | 147 for (size_t i = 0; i < proxies_.size(); ++i) |
148 list->AppendString(proxies_[i].ToURI()); | 148 list->AppendString(proxies_[i].ToURI()); |
149 return list.release(); | 149 return list.Pass(); |
150 } | 150 } |
151 | 151 |
152 bool ProxyList::Fallback(ProxyRetryInfoMap* proxy_retry_info, | 152 bool ProxyList::Fallback(ProxyRetryInfoMap* proxy_retry_info, |
153 int net_error, | 153 int net_error, |
154 const BoundNetLog& net_log) { | 154 const BoundNetLog& net_log) { |
155 | |
156 // TODO(eroman): It would be good if instead of removing failed proxies | 155 // TODO(eroman): It would be good if instead of removing failed proxies |
157 // from the list, we simply annotated them with the error code they failed | 156 // from the list, we simply annotated them with the error code they failed |
158 // with. Of course, ProxyService::ReconsiderProxyAfterError() would need to | 157 // with. Of course, ProxyService::ReconsiderProxyAfterError() would need to |
159 // be given this information by the network transaction. | 158 // be given this information by the network transaction. |
160 // | 159 // |
161 // The advantage of this approach is when the network transaction | 160 // The advantage of this approach is when the network transaction |
162 // fails, we could output the full list of proxies that were attempted, and | 161 // fails, we could output the full list of proxies that were attempted, and |
163 // why each one of those failed (as opposed to just the last failure). | 162 // why each one of those failed (as opposed to just the last failure). |
164 // | 163 // |
165 // And also, before failing the transaction wholesale, we could go back and | 164 // And also, before failing the transaction wholesale, we could go back and |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // If any additional proxies to bypass are specified, add to the retry map | 225 // If any additional proxies to bypass are specified, add to the retry map |
227 // as well. | 226 // as well. |
228 for (const ProxyServer& additional_proxy : additional_proxies_to_bypass) { | 227 for (const ProxyServer& additional_proxy : additional_proxies_to_bypass) { |
229 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider, | 228 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider, |
230 additional_proxy, net_error, net_log); | 229 additional_proxy, net_error, net_log); |
231 } | 230 } |
232 } | 231 } |
233 } | 232 } |
234 | 233 |
235 } // namespace net | 234 } // namespace net |
OLD | NEW |