Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Unified Diff: ppapi/shared_impl/private/net_address_private_impl.cc

Issue 10993078: Use extensions socket permission for TCP/UDP socket APIs in Pepper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed Android build Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/shared_impl/private/net_address_private_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7a8e375ec8b7e39924db09696957f8493ccc0cb6 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, PP_ToBool(include_port));
+ 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,21 @@ 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);
+ return ConvertIPv4AddressToString(net_addr, include_port);
+}
+
} // namespace ppapi
« no previous file with comments | « ppapi/shared_impl/private/net_address_private_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698