summaryrefslogtreecommitdiffstats
path: root/ppapi/shared_impl
diff options
context:
space:
mode:
authorszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-07 21:44:56 +0000
committerszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-07 21:44:56 +0000
commit7054e78fe6a2fcda72b06dc196b5f91cfdc75872 (patch)
tree2efdd9b07a784a17905d737df9b762d88a6cd1c4 /ppapi/shared_impl
parentcd46545164adf645d744f3955b256cf89412cdc6 (diff)
downloadchromium_src-7054e78fe6a2fcda72b06dc196b5f91cfdc75872.zip
chromium_src-7054e78fe6a2fcda72b06dc196b5f91cfdc75872.tar.gz
chromium_src-7054e78fe6a2fcda72b06dc196b5f91cfdc75872.tar.bz2
Reimplements net::AddressList without struct addrinfo.
net::AddressList extends std::vector<std::IPEndPoint> by canonical name. (Canonical name is planned to be removed as well.) Removes dependency on sys_addrinfo.h throughout the codebase. Introduces net::SockaddrStorage for convenience. BUG=125696 TEST=green waterfall Review URL: http://codereview.chromium.org/10309002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135731 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl')
-rw-r--r--ppapi/shared_impl/private/net_address_private_impl.cc17
-rw-r--r--ppapi/shared_impl/private/ppb_host_resolver_shared.cc12
-rw-r--r--ppapi/shared_impl/private/ppb_host_resolver_shared.h6
3 files changed, 15 insertions, 20 deletions
diff --git a/ppapi/shared_impl/private/net_address_private_impl.cc b/ppapi/shared_impl/private/net_address_private_impl.cc
index 148d5e5..2d181ec 100644
--- a/ppapi/shared_impl/private/net_address_private_impl.cc
+++ b/ppapi/shared_impl/private/net_address_private_impl.cc
@@ -16,7 +16,6 @@
#include "net/base/address_list.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_util.h"
-#include "net/base/sys_addrinfo.h"
#include "ppapi/c/pp_var.h"
#include "ppapi/c/private/ppb_net_address_private.h"
#include "ppapi/shared_impl/var.h"
@@ -472,21 +471,18 @@ bool NetAddressPrivateImpl::SockaddrToNetAddress(
bool NetAddressPrivateImpl::IPEndPointToNetAddress(
const net::IPEndPoint& ip,
PP_NetAddress_Private* net_addr) {
- sockaddr_storage storage = { 0 };
- size_t length = sizeof(storage);
+ net::SockaddrStorage storage;
- return ip.ToSockAddr(reinterpret_cast<sockaddr*>(&storage), &length) &&
- SockaddrToNetAddress(reinterpret_cast<const sockaddr*>(&storage), length,
- net_addr);
+ return ip.ToSockAddr(storage.addr, &storage.addr_len) &&
+ SockaddrToNetAddress(storage.addr, storage.addr_len, net_addr);
}
// static
bool NetAddressPrivateImpl::AddressListToNetAddress(
const net::AddressList& address_list,
PP_NetAddress_Private* net_addr) {
- const addrinfo* head = address_list.head();
- return head && SockaddrToNetAddress(head->ai_addr, head->ai_addrlen,
- net_addr);
+ return !address_list.empty() && IPEndPointToNetAddress(address_list.front(),
+ net_addr);
}
// static
@@ -514,8 +510,7 @@ bool NetAddressPrivateImpl::NetAddressToAddressList(
if (!NetAddressToIPEndPoint(net_addr, &ip_end_point))
return false;
- *address_list = net::AddressList::CreateFromIPAddress(ip_end_point.address(),
- ip_end_point.port());
+ *address_list = net::AddressList(ip_end_point);
return true;
}
diff --git a/ppapi/shared_impl/private/ppb_host_resolver_shared.cc b/ppapi/shared_impl/private/ppb_host_resolver_shared.cc
index af3db62..9a145a9 100644
--- a/ppapi/shared_impl/private/ppb_host_resolver_shared.cc
+++ b/ppapi/shared_impl/private/ppb_host_resolver_shared.cc
@@ -7,7 +7,7 @@
#include <cstddef>
#include <cstring>
-#include "net/base/sys_addrinfo.h"
+#include "net/base/address_list.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/shared_impl/private/net_address_private_impl.h"
#include "ppapi/shared_impl/var.h"
@@ -15,17 +15,15 @@
namespace ppapi {
-NetAddressList* CreateNetAddressListFromAddrInfo(const addrinfo* ai) {
+NetAddressList* CreateNetAddressListFromAddressList(
+ const net::AddressList& list) {
scoped_ptr<NetAddressList> net_address_list(new NetAddressList());
PP_NetAddress_Private address;
- while (ai != NULL) {
- if (!NetAddressPrivateImpl::SockaddrToNetAddress(
- ai->ai_addr, ai->ai_addrlen, &address)) {
+ for (size_t i = 0; i < list.size(); ++i) {
+ if (!NetAddressPrivateImpl::IPEndPointToNetAddress(list[i], &address))
return NULL;
- }
net_address_list->push_back(address);
- ai = ai->ai_next;
}
return net_address_list.release();
diff --git a/ppapi/shared_impl/private/ppb_host_resolver_shared.h b/ppapi/shared_impl/private/ppb_host_resolver_shared.h
index a0b080f..7a5404f 100644
--- a/ppapi/shared_impl/private/ppb_host_resolver_shared.h
+++ b/ppapi/shared_impl/private/ppb_host_resolver_shared.h
@@ -15,7 +15,9 @@
#include "ppapi/shared_impl/tracked_callback.h"
#include "ppapi/thunk/ppb_host_resolver_private_api.h"
-struct addrinfo;
+namespace net {
+class AddressList;
+}
namespace ppapi {
@@ -27,7 +29,7 @@ struct HostPortPair {
typedef std::vector<PP_NetAddress_Private> NetAddressList;
PPAPI_SHARED_EXPORT NetAddressList*
- CreateNetAddressListFromAddrInfo(const addrinfo* ai);
+ CreateNetAddressListFromAddressList(const net::AddressList& list);
class PPAPI_SHARED_EXPORT PPB_HostResolver_Shared
: public thunk::PPB_HostResolver_Private_API,