| 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/base/host_port_pair.h" | 5 #include "net/base/host_port_pair.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "net/base/ip_endpoint.h" | 12 #include "net/base/ip_endpoint.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 HostPortPair::HostPortPair() : port_(0) {} | 17 HostPortPair::HostPortPair() : port_(0) { |
| 18 } |
| 18 HostPortPair::HostPortPair(const std::string& in_host, uint16 in_port) | 19 HostPortPair::HostPortPair(const std::string& in_host, uint16 in_port) |
| 19 : host_(in_host), port_(in_port) {} | 20 : host_(in_host), port_(in_port) { |
| 21 } |
| 20 | 22 |
| 21 // static | 23 // static |
| 22 HostPortPair HostPortPair::FromURL(const GURL& url) { | 24 HostPortPair HostPortPair::FromURL(const GURL& url) { |
| 23 return HostPortPair(url.HostNoBrackets(), url.EffectiveIntPort()); | 25 return HostPortPair(url.HostNoBrackets(), url.EffectiveIntPort()); |
| 24 } | 26 } |
| 25 | 27 |
| 26 // static | 28 // static |
| 27 HostPortPair HostPortPair::FromIPEndPoint(const IPEndPoint& ipe) { | 29 HostPortPair HostPortPair::FromIPEndPoint(const IPEndPoint& ipe) { |
| 28 return HostPortPair(ipe.ToStringWithoutPort(), ipe.port()); | 30 return HostPortPair(ipe.ToStringWithoutPort(), ipe.port()); |
| 29 } | 31 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 60 // Check to see if the host is an IPv6 address. If so, added brackets. | 62 // Check to see if the host is an IPv6 address. If so, added brackets. |
| 61 if (host_.find(':') != std::string::npos) { | 63 if (host_.find(':') != std::string::npos) { |
| 62 DCHECK_NE(host_[0], '['); | 64 DCHECK_NE(host_[0], '['); |
| 63 return base::StringPrintf("[%s]", host_.c_str()); | 65 return base::StringPrintf("[%s]", host_.c_str()); |
| 64 } | 66 } |
| 65 | 67 |
| 66 return host_; | 68 return host_; |
| 67 } | 69 } |
| 68 | 70 |
| 69 } // namespace net | 71 } // namespace net |
| OLD | NEW |