Chromium Code Reviews| Index: ppapi/shared_impl/private/net_address_private_impl.cc |
| diff --git a/ppapi/shared_impl/private/net_address_private_impl.cc b/ppapi/shared_impl/private/net_address_private_impl.cc |
| index 6e154107e67bc036147f7c495420dc9161135fbb..42c7fee2d4ddb66841b395e79cbd103a896151e0 100644 |
| --- a/ppapi/shared_impl/private/net_address_private_impl.cc |
| +++ b/ppapi/shared_impl/private/net_address_private_impl.cc |
| @@ -281,19 +281,11 @@ std::string ConvertIPv6AddressToString(const NetAddress* net_addr, |
| PP_Var Describe(PP_Module /*module*/, |
| const struct PP_NetAddress_Private* addr, |
| PP_Bool include_port) { |
| - const NetAddress* net_addr = ToNetAddress(addr); |
| - if (!IsValid(net_addr)) |
| + std::string str = NetAddressPrivateImpl::DescribeNetAddress(*addr, |
| + !!include_port); |
|
brettw
2012/10/31 23:34:23
Please use PP_ToBool(include_port) like the old co
Dmitry Polukhin
2012/11/01 07:59:52
Done.
|
| + if (str.empty()) |
| return PP_MakeUndefined(); |
| - |
| - std::string description; |
| - if (net_addr->is_ipv6) { |
| - description = ConvertIPv6AddressToString(net_addr, |
| - PP_ToBool(include_port)); |
| - } else { |
| - description = ConvertIPv4AddressToString(net_addr, |
| - PP_ToBool(include_port)); |
| - } |
| - return StringVar::StringToPPVar(description); |
| + return StringVar::StringToPPVar(str); |
| } |
| PP_Bool ReplacePort(const struct PP_NetAddress_Private* src_addr, |
| @@ -498,4 +490,23 @@ bool NetAddressPrivateImpl::NetAddressToIPEndPoint( |
| } |
| #endif // !defined(OS_NACL) |
| +// static |
| +std::string NetAddressPrivateImpl::DescribeNetAddress( |
| + const PP_NetAddress_Private& addr, |
| + bool include_port) { |
| + const NetAddress* net_addr = ToNetAddress(&addr); |
| + if (!IsValid(net_addr)) |
| + return std::string(); |
| + |
| + // On Windows, |NetAddressToString()| doesn't work in the sandbox. On Mac, |
| + // the output isn't consistent with RFC 5952, at least on Mac OS 10.6: |
| + // |getnameinfo()| collapses length-one runs of zeros (and also doesn't |
| + // display the scope). |
| + if (net_addr->is_ipv6) |
| + return ConvertIPv6AddressToString(net_addr, include_port); |
| + else |
|
brettw
2012/10/31 23:34:23
else
return
return
should be just
"return Conve
Dmitry Polukhin
2012/11/01 07:59:52
Done.
|
| + return ConvertIPv4AddressToString(net_addr, include_port); |
| + return std::string(); |
| +} |
| + |
| } // namespace ppapi |