| 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 #ifndef NET_PROXY_PROXY_LIST_H_ | 5 #ifndef NET_PROXY_PROXY_LIST_H_ |
| 6 #define NET_PROXY_PROXY_LIST_H_ | 6 #define NET_PROXY_PROXY_LIST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // Does a best-effort parse, and silently discards any errors. | 71 // Does a best-effort parse, and silently discards any errors. |
| 72 void SetFromPacString(const std::string& pac_string); | 72 void SetFromPacString(const std::string& pac_string); |
| 73 | 73 |
| 74 // Returns a PAC-style semicolon-separated list of valid proxy servers. | 74 // Returns a PAC-style semicolon-separated list of valid proxy servers. |
| 75 // For example: "PROXY xxx.xxx.xxx.xxx:xx; SOCKS yyy.yyy.yyy:yy". | 75 // For example: "PROXY xxx.xxx.xxx.xxx:xx; SOCKS yyy.yyy.yyy:yy". |
| 76 std::string ToPacString() const; | 76 std::string ToPacString() const; |
| 77 | 77 |
| 78 // Returns a serialized value for the list. The caller takes ownership of it. | 78 // Returns a serialized value for the list. The caller takes ownership of it. |
| 79 base::ListValue* ToValue() const; | 79 base::ListValue* ToValue() const; |
| 80 | 80 |
| 81 // Marks the current proxy server as bad and deletes it from the list. The | 81 // Marks the current proxy server as bad and deletes it from the list. The |
| 82 // list of known bad proxies is given by proxy_retry_info. Returns true if | 82 // list of known bad proxies is given by |proxy_retry_info|. |net_error| |
| 83 // there is another server available in the list. | 83 // should contain the network error encountered when this proxy was tried, if |
| 84 // any. If this fallback is not because of a network error, then |OK| should |
| 85 // be passed in (eg. for reasons such as local policy). Returns true if there |
| 86 // is another server available in the list. |
| 84 bool Fallback(ProxyRetryInfoMap* proxy_retry_info, | 87 bool Fallback(ProxyRetryInfoMap* proxy_retry_info, |
| 88 int net_error, |
| 85 const BoundNetLog& net_log); | 89 const BoundNetLog& net_log); |
| 86 | 90 |
| 87 // Updates |proxy_retry_info| to indicate that the first proxy in the list | 91 // Updates |proxy_retry_info| to indicate that the first proxy in the list |
| 88 // is bad. This is distinct from Fallback(), above, to allow updating proxy | 92 // is bad. This is distinct from Fallback(), above, to allow updating proxy |
| 89 // retry information without modifying a given transction's proxy list. Will | 93 // retry information without modifying a given transction's proxy list. Will |
| 90 // retry after |retry_delay| if positive, and will use the default proxy retry | 94 // retry after |retry_delay| if positive, and will use the default proxy retry |
| 91 // duration otherwise. It may reconsider the proxy beforehand if |reconsider| | 95 // duration otherwise. It may reconsider the proxy beforehand if |reconsider| |
| 92 // is true. Additionally updates |proxy_retry_info| with | 96 // is true. Additionally updates |proxy_retry_info| with |
| 93 // |another_proxy_to_bypass| if non-empty. | 97 // |another_proxy_to_bypass| if non-empty. |net_error| should contain the |
| 98 // network error countered when this proxy was tried, or OK if the proxy retry |
| 99 // info is being updated for a non-network related reason (e.g. local policy). |
| 94 void UpdateRetryInfoOnFallback( | 100 void UpdateRetryInfoOnFallback( |
| 95 ProxyRetryInfoMap* proxy_retry_info, | 101 ProxyRetryInfoMap* proxy_retry_info, |
| 96 base::TimeDelta retry_delay, | 102 base::TimeDelta retry_delay, |
| 97 bool reconsider, | 103 bool reconsider, |
| 98 const ProxyServer& another_proxy_to_bypass, | 104 const ProxyServer& another_proxy_to_bypass, |
| 105 int net_error, |
| 99 const BoundNetLog& net_log) const; | 106 const BoundNetLog& net_log) const; |
| 100 | 107 |
| 101 private: | 108 private: |
| 102 // Updates |proxy_retry_info| to indicate that the |proxy_to_retry| in | 109 // Updates |proxy_retry_info| to indicate that the |proxy_to_retry| in |
| 103 // |proxies_| is bad for |retry_delay|, but may be reconsidered earlier if | 110 // |proxies_| is bad for |retry_delay|, but may be reconsidered earlier if |
| 104 // |try_while_bad| is true. | 111 // |try_while_bad| is true. |net_error| should contain the network error |
| 112 // countered when this proxy was tried, or OK if the proxy retry info is |
| 113 // being updated for a non-network related reason (e.g. local policy). |
| 105 void AddProxyToRetryList(ProxyRetryInfoMap* proxy_retry_info, | 114 void AddProxyToRetryList(ProxyRetryInfoMap* proxy_retry_info, |
| 106 base::TimeDelta retry_delay, | 115 base::TimeDelta retry_delay, |
| 107 bool try_while_bad, | 116 bool try_while_bad, |
| 108 const ProxyServer& proxy_to_retry, | 117 const ProxyServer& proxy_to_retry, |
| 118 int net_error, |
| 109 const BoundNetLog& net_log) const; | 119 const BoundNetLog& net_log) const; |
| 110 | 120 |
| 111 // List of proxies. | 121 // List of proxies. |
| 112 std::vector<ProxyServer> proxies_; | 122 std::vector<ProxyServer> proxies_; |
| 113 }; | 123 }; |
| 114 | 124 |
| 115 } // namespace net | 125 } // namespace net |
| 116 | 126 |
| 117 #endif // NET_PROXY_PROXY_LIST_H_ | 127 #endif // NET_PROXY_PROXY_LIST_H_ |
| OLD | NEW |