| 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/string_tokenizer.h" | 9 #include "base/strings/string_tokenizer.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 #include "net/proxy/proxy_server.h" | 11 #include "net/proxy/proxy_server.h" |
| 12 | 12 |
| 13 using base::TimeDelta; | 13 using base::TimeDelta; |
| 14 using base::TimeTicks; | 14 using base::TimeTicks; |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 ProxyList::ProxyList() { | 18 ProxyList::ProxyList() { |
| 19 } | 19 } |
| 20 | 20 |
| 21 ProxyList::~ProxyList() { | 21 ProxyList::~ProxyList() { |
| 22 } | 22 } |
| 23 | 23 |
| 24 void ProxyList::Set(const std::string& proxy_uri_list) { | 24 void ProxyList::Set(const std::string& proxy_uri_list) { |
| 25 proxies_.clear(); | 25 proxies_.clear(); |
| 26 StringTokenizer str_tok(proxy_uri_list, ";"); | 26 base::StringTokenizer str_tok(proxy_uri_list, ";"); |
| 27 while (str_tok.GetNext()) { | 27 while (str_tok.GetNext()) { |
| 28 ProxyServer uri = ProxyServer::FromURI( | 28 ProxyServer uri = ProxyServer::FromURI( |
| 29 str_tok.token_begin(), str_tok.token_end(), ProxyServer::SCHEME_HTTP); | 29 str_tok.token_begin(), str_tok.token_end(), ProxyServer::SCHEME_HTTP); |
| 30 // Silently discard malformed inputs. | 30 // Silently discard malformed inputs. |
| 31 if (uri.is_valid()) | 31 if (uri.is_valid()) |
| 32 proxies_.push_back(uri); | 32 proxies_.push_back(uri); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 void ProxyList::SetSingleProxyServer(const ProxyServer& proxy_server) { | 36 void ProxyList::SetSingleProxyServer(const ProxyServer& proxy_server) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 size_t ProxyList::size() const { | 109 size_t ProxyList::size() const { |
| 110 return proxies_.size(); | 110 return proxies_.size(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 const ProxyServer& ProxyList::Get() const { | 113 const ProxyServer& ProxyList::Get() const { |
| 114 DCHECK(!proxies_.empty()); | 114 DCHECK(!proxies_.empty()); |
| 115 return proxies_[0]; | 115 return proxies_[0]; |
| 116 } | 116 } |
| 117 | 117 |
| 118 void ProxyList::SetFromPacString(const std::string& pac_string) { | 118 void ProxyList::SetFromPacString(const std::string& pac_string) { |
| 119 StringTokenizer entry_tok(pac_string, ";"); | 119 base::StringTokenizer entry_tok(pac_string, ";"); |
| 120 proxies_.clear(); | 120 proxies_.clear(); |
| 121 while (entry_tok.GetNext()) { | 121 while (entry_tok.GetNext()) { |
| 122 ProxyServer uri = ProxyServer::FromPacString( | 122 ProxyServer uri = ProxyServer::FromPacString( |
| 123 entry_tok.token_begin(), entry_tok.token_end()); | 123 entry_tok.token_begin(), entry_tok.token_end()); |
| 124 // Silently discard malformed inputs. | 124 // Silently discard malformed inputs. |
| 125 if (uri.is_valid()) | 125 if (uri.is_valid()) |
| 126 proxies_.push_back(uri); | 126 proxies_.push_back(uri); |
| 127 } | 127 } |
| 128 | 128 |
| 129 // If we failed to parse anything from the PAC results list, fallback to | 129 // If we failed to parse anything from the PAC results list, fallback to |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 retry_info.current_delay = kProxyRetryDelay; | 195 retry_info.current_delay = kProxyRetryDelay; |
| 196 retry_info.bad_until = TimeTicks().Now() + retry_info.current_delay; | 196 retry_info.bad_until = TimeTicks().Now() + retry_info.current_delay; |
| 197 (*proxy_retry_info)[key] = retry_info; | 197 (*proxy_retry_info)[key] = retry_info; |
| 198 } | 198 } |
| 199 net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK, | 199 net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK, |
| 200 NetLog::StringCallback("bad_proxy", &key)); | 200 NetLog::StringCallback("bad_proxy", &key)); |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace net | 204 } // namespace net |
| OLD | NEW |