| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_server.h" | 5 #include "net/proxy/proxy_server.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/trace_event/memory_usage_estimator.h" |
| 10 #include "net/base/url_util.h" | 11 #include "net/base/url_util.h" |
| 11 #include "net/http/http_util.h" | 12 #include "net/http/http_util.h" |
| 12 | 13 |
| 13 namespace net { | 14 namespace net { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 // Parses the proxy type from a PAC string, to a ProxyServer::Scheme. | 18 // Parses the proxy type from a PAC string, to a ProxyServer::Scheme. |
| 18 // This mapping is case-insensitive. If no type could be matched | 19 // This mapping is case-insensitive. If no type could be matched |
| 19 // returns SCHEME_INVALID. | 20 // returns SCHEME_INVALID. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 break; | 203 break; |
| 203 } | 204 } |
| 204 return -1; | 205 return -1; |
| 205 } | 206 } |
| 206 | 207 |
| 207 // static | 208 // static |
| 208 ProxyServer::Scheme ProxyServer::GetSchemeFromURI(const std::string& scheme) { | 209 ProxyServer::Scheme ProxyServer::GetSchemeFromURI(const std::string& scheme) { |
| 209 return GetSchemeFromURIInternal(scheme); | 210 return GetSchemeFromURIInternal(scheme); |
| 210 } | 211 } |
| 211 | 212 |
| 213 size_t ProxyServer::EstimateMemoryUsage() const { |
| 214 return base::trace_event::EstimateMemoryUsage(host_port_pair_); |
| 215 } |
| 216 |
| 212 // static | 217 // static |
| 213 ProxyServer ProxyServer::FromSchemeHostAndPort( | 218 ProxyServer ProxyServer::FromSchemeHostAndPort( |
| 214 Scheme scheme, | 219 Scheme scheme, |
| 215 std::string::const_iterator begin, | 220 std::string::const_iterator begin, |
| 216 std::string::const_iterator end) { | 221 std::string::const_iterator end) { |
| 217 | 222 |
| 218 // Trim leading/trailing space. | 223 // Trim leading/trailing space. |
| 219 HttpUtil::TrimLWS(&begin, &end); | 224 HttpUtil::TrimLWS(&begin, &end); |
| 220 | 225 |
| 221 if (scheme == SCHEME_DIRECT && begin != end) | 226 if (scheme == SCHEME_DIRECT && begin != end) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 235 if (port == -1) | 240 if (port == -1) |
| 236 port = GetDefaultPortForScheme(scheme); | 241 port = GetDefaultPortForScheme(scheme); |
| 237 | 242 |
| 238 host_port_pair = HostPortPair(host, static_cast<uint16_t>(port)); | 243 host_port_pair = HostPortPair(host, static_cast<uint16_t>(port)); |
| 239 } | 244 } |
| 240 | 245 |
| 241 return ProxyServer(scheme, host_port_pair); | 246 return ProxyServer(scheme, host_port_pair); |
| 242 } | 247 } |
| 243 | 248 |
| 244 } // namespace net | 249 } // namespace net |
| OLD | NEW |