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

Unified Diff: ppapi/cpp/private/net_address_private.cc

Issue 9235035: Add getter methods for sockaddr. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Fixing errors found by review system. Created 8 years, 11 months 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
Index: ppapi/cpp/private/net_address_private.cc
===================================================================
--- ppapi/cpp/private/net_address_private.cc (revision 119128)
+++ ppapi/cpp/private/net_address_private.cc (working copy)
@@ -18,6 +18,10 @@
return PPB_NETADDRESS_PRIVATE_INTERFACE;
}
+template <> const char* interface_name<PPB_NetAddress_Private_0_1>() {
+ return PPB_NETADDRESS_PRIVATE_INTERFACE_0_1;
+}
+
} // namespace
// static
@@ -28,24 +32,25 @@
// static
bool NetAddressPrivate::AreEqual(const PP_NetAddress_Private& addr1,
const PP_NetAddress_Private& addr2) {
- if (!has_interface<PPB_NetAddress_Private>())
+ if (!has_interface<PPB_NetAddress_Private_0_1>())
return false;
- return !!get_interface<PPB_NetAddress_Private>()->AreEqual(&addr1, &addr2);
+ return !!get_interface<PPB_NetAddress_Private_0_1>()->AreEqual(&addr1,
+ &addr2);
}
// static
bool NetAddressPrivate::AreHostsEqual(const PP_NetAddress_Private& addr1,
const PP_NetAddress_Private& addr2) {
- if (!has_interface<PPB_NetAddress_Private>())
+ if (!has_interface<PPB_NetAddress_Private_0_1>())
return false;
- return !!get_interface<PPB_NetAddress_Private>()->AreHostsEqual(&addr1,
+ return !!get_interface<PPB_NetAddress_Private_0_1>()->AreHostsEqual(&addr1,
&addr2);
}
// static
std::string NetAddressPrivate::Describe(const PP_NetAddress_Private& addr,
bool include_port) {
- if (!has_interface<PPB_NetAddress_Private>())
+ if (!has_interface<PPB_NetAddress_Private_0_1>())
return std::string();
Module* module = Module::Get();
@@ -53,7 +58,7 @@
return std::string();
Var result(Var::PassRef(),
- get_interface<PPB_NetAddress_Private>()->Describe(
+ get_interface<PPB_NetAddress_Private_0_1>()->Describe(
module->pp_module(),
&addr,
PP_FromBool(include_port)));
@@ -64,9 +69,9 @@
bool NetAddressPrivate::ReplacePort(const PP_NetAddress_Private& addr_in,
uint16_t port,
PP_NetAddress_Private* addr_out) {
- if (!has_interface<PPB_NetAddress_Private>())
+ if (!has_interface<PPB_NetAddress_Private_0_1>())
return false;
- return !!get_interface<PPB_NetAddress_Private>()->ReplacePort(&addr_in,
+ return !!get_interface<PPB_NetAddress_Private_0_1>()->ReplacePort(&addr_in,
port,
addr_out);
}
@@ -74,10 +79,36 @@
// static
void NetAddressPrivate::GetAnyAddress(bool is_ipv6,
PP_NetAddress_Private* addr) {
- if (!has_interface<PPB_NetAddress_Private>())
+ if (!has_interface<PPB_NetAddress_Private_0_1>())
return;
- get_interface<PPB_NetAddress_Private>()->GetAnyAddress(PP_FromBool(is_ipv6),
- addr);
+ get_interface<PPB_NetAddress_Private_0_1>()->GetAnyAddress(
+ PP_FromBool(is_ipv6),
+ addr);
}
+// static
+uint16_t NetAddressPrivate::GetFamily(const PP_NetAddress_Private* addr) {
+ if (!has_interface<PPB_NetAddress_Private>())
+ return 0;
+ return get_interface<PPB_NetAddress_Private>()->GetFamily(addr);
+}
+
+// static
+uint16_t NetAddressPrivate::GetPort(const PP_NetAddress_Private* addr) {
+ if (!has_interface<PPB_NetAddress_Private>())
+ return 0;
+ return get_interface<PPB_NetAddress_Private>()->GetPort(addr);
+}
+
+bool NetAddressPrivate::GetAddress(const PP_NetAddress_Private* addr,
+ void* address,
+ uint16_t address_size) {
+ if (!has_interface<PPB_NetAddress_Private>())
+ return false;
+ return PP_ToBool(get_interface<PPB_NetAddress_Private>()->GetAddress(
+ addr,
+ address,
+ address_size));
+}
+
} // namespace pp

Powered by Google App Engine
This is Rietveld 408576698