diff options
Diffstat (limited to 'net/base/host_port_pair.cc')
-rw-r--r-- | net/base/host_port_pair.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/net/base/host_port_pair.cc b/net/base/host_port_pair.cc index 1c4406f..5164fcf 100644 --- a/net/base/host_port_pair.cc +++ b/net/base/host_port_pair.cc @@ -7,6 +7,8 @@ #include "base/string_util.h" #include "base/stringprintf.h" #include "googleurl/src/gurl.h" +#include "net/base/net_util.h" +#include "net/base/sys_addrinfo.h" namespace net { @@ -19,6 +21,12 @@ HostPortPair HostPortPair::FromURL(const GURL& url) { return HostPortPair(url.HostNoBrackets(), url.EffectiveIntPort()); } +// static +HostPortPair HostPortPair::FromAddrInfo(const struct addrinfo* ai) { + return HostPortPair(NetAddressToString(ai), + GetPortFromSockaddr(ai->ai_addr, ai->ai_addrlen)); +} + std::string HostPortPair::ToString() const { return base::StringPrintf("%s:%u", HostForURL().c_str(), port_); } |