| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/shared_impl/private/ppb_host_resolver_shared.h" | 5 #include "ppapi/shared_impl/private/ppb_host_resolver_shared.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 | 9 |
| 10 #include "net/base/sys_addrinfo.h" | 10 #include "net/base/address_list.h" |
| 11 #include "ppapi/c/pp_errors.h" | 11 #include "ppapi/c/pp_errors.h" |
| 12 #include "ppapi/shared_impl/private/net_address_private_impl.h" | 12 #include "ppapi/shared_impl/private/net_address_private_impl.h" |
| 13 #include "ppapi/shared_impl/var.h" | 13 #include "ppapi/shared_impl/var.h" |
| 14 #include "ppapi/thunk/thunk.h" | 14 #include "ppapi/thunk/thunk.h" |
| 15 | 15 |
| 16 namespace ppapi { | 16 namespace ppapi { |
| 17 | 17 |
| 18 NetAddressList* CreateNetAddressListFromAddrInfo(const addrinfo* ai) { | 18 NetAddressList* CreateNetAddressListFromAddressList( |
| 19 const net::AddressList& list) { |
| 19 scoped_ptr<NetAddressList> net_address_list(new NetAddressList()); | 20 scoped_ptr<NetAddressList> net_address_list(new NetAddressList()); |
| 20 PP_NetAddress_Private address; | 21 PP_NetAddress_Private address; |
| 21 | 22 |
| 22 while (ai != NULL) { | 23 for (net::AddressList::const_iterator it = list.begin(); it != list.end(); |
| 23 if (!NetAddressPrivateImpl::SockaddrToNetAddress( | 24 ++it) { |
| 24 ai->ai_addr, ai->ai_addrlen, &address)) { | 25 if (!NetAddressPrivateImpl::IPEndPointToNetAddress(*it, &address)) |
| 25 return NULL; | 26 return NULL; |
| 26 } | |
| 27 net_address_list->push_back(address); | 27 net_address_list->push_back(address); |
| 28 ai = ai->ai_next; | |
| 29 } | 28 } |
| 30 | 29 |
| 31 return net_address_list.release(); | 30 return net_address_list.release(); |
| 32 } | 31 } |
| 33 | 32 |
| 34 PPB_HostResolver_Shared::PPB_HostResolver_Shared(PP_Instance instance) | 33 PPB_HostResolver_Shared::PPB_HostResolver_Shared(PP_Instance instance) |
| 35 : Resource(OBJECT_IS_IMPL, instance), | 34 : Resource(OBJECT_IS_IMPL, instance), |
| 36 host_resolver_id_(GenerateHostResolverID()) { | 35 host_resolver_id_(GenerateHostResolverID()) { |
| 37 } | 36 } |
| 38 | 37 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 uint32 PPB_HostResolver_Shared::GenerateHostResolverID() { | 108 uint32 PPB_HostResolver_Shared::GenerateHostResolverID() { |
| 110 static uint32 host_resolver_id = 0; | 109 static uint32 host_resolver_id = 0; |
| 111 return host_resolver_id++; | 110 return host_resolver_id++; |
| 112 } | 111 } |
| 113 | 112 |
| 114 bool PPB_HostResolver_Shared::ResolveInProgress() const { | 113 bool PPB_HostResolver_Shared::ResolveInProgress() const { |
| 115 return TrackedCallback::IsPending(resolve_callback_); | 114 return TrackedCallback::IsPending(resolve_callback_); |
| 116 } | 115 } |
| 117 | 116 |
| 118 } // namespace ppapi | 117 } // namespace ppapi |
| OLD | NEW |