| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_SERVER_H_ | 5 #ifndef NET_PROXY_PROXY_SERVER_H_ |
| 6 #define NET_PROXY_PROXY_SERVER_H_ | 6 #define NET_PROXY_PROXY_SERVER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // | 94 // |
| 95 // Examples: | 95 // Examples: |
| 96 // "PROXY foopy:19" {scheme=HTTP, host="foopy", port=19} | 96 // "PROXY foopy:19" {scheme=HTTP, host="foopy", port=19} |
| 97 // "DIRECT" {scheme=DIRECT} | 97 // "DIRECT" {scheme=DIRECT} |
| 98 // "SOCKS5 foopy" {scheme=SOCKS5, host="foopy", port=1080} | 98 // "SOCKS5 foopy" {scheme=SOCKS5, host="foopy", port=1080} |
| 99 // "BLAH xxx:xx" INVALID | 99 // "BLAH xxx:xx" INVALID |
| 100 static ProxyServer FromPacString(const std::string& pac_string); | 100 static ProxyServer FromPacString(const std::string& pac_string); |
| 101 static ProxyServer FromPacString(std::string::const_iterator pac_string_begin, | 101 static ProxyServer FromPacString(std::string::const_iterator pac_string_begin, |
| 102 std::string::const_iterator pac_string_end); | 102 std::string::const_iterator pac_string_end); |
| 103 | 103 |
| 104 // Returns a ProxyServer representing DIRECT connections. |
| 105 static ProxyServer Direct() { |
| 106 return ProxyServer(SCHEME_DIRECT, std::string(), -1); |
| 107 } |
| 108 |
| 104 // Format as a PAC result entry. This does the reverse of FromPacString(). | 109 // Format as a PAC result entry. This does the reverse of FromPacString(). |
| 105 std::string ToPacString() const; | 110 std::string ToPacString() const; |
| 106 | 111 |
| 107 // Returns the default port number for a proxy server with the specified | 112 // Returns the default port number for a proxy server with the specified |
| 108 // scheme. Returns -1 if unknown. | 113 // scheme. Returns -1 if unknown. |
| 109 static int GetDefaultPortForScheme(Scheme scheme); | 114 static int GetDefaultPortForScheme(Scheme scheme); |
| 110 | 115 |
| 111 bool operator==(const ProxyServer& other) const { | 116 bool operator==(const ProxyServer& other) const { |
| 112 return scheme_ == other.scheme_ && | 117 return scheme_ == other.scheme_ && |
| 113 host_ == other.host_ && | 118 host_ == other.host_ && |
| 114 port_ == other.port_; | 119 port_ == other.port_; |
| 115 } | 120 } |
| 116 | 121 |
| 117 private: | 122 private: |
| 118 // Create a ProxyServer given a scheme, and host/port string. If parsing the | 123 // Create a ProxyServer given a scheme, and host/port string. If parsing the |
| 119 // host/port string fails, the returned instance will be invalid. | 124 // host/port string fails, the returned instance will be invalid. |
| 120 static ProxyServer FromSchemeHostAndPort( | 125 static ProxyServer FromSchemeHostAndPort( |
| 121 Scheme scheme, | 126 Scheme scheme, |
| 122 std::string::const_iterator host_and_port_begin, | 127 std::string::const_iterator host_and_port_begin, |
| 123 std::string::const_iterator host_and_port_end); | 128 std::string::const_iterator host_and_port_end); |
| 124 | 129 |
| 125 Scheme scheme_; | 130 Scheme scheme_; |
| 126 std::string host_; | 131 std::string host_; |
| 127 int port_; | 132 int port_; |
| 128 }; | 133 }; |
| 129 | 134 |
| 130 } // namespace net | 135 } // namespace net |
| 131 | 136 |
| 132 #endif // NET_PROXY_PROXY_SERVER_H_ | 137 #endif // NET_PROXY_PROXY_SERVER_H_ |
| OLD | NEW |