| 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 (size_t i = 0; i < list.size(); ++i) { |
| 23 if (!NetAddressPrivateImpl::SockaddrToNetAddress( | 24 if (!NetAddressPrivateImpl::IPEndPointToNetAddress(list[i], &address)) |
| 24 ai->ai_addr, ai->ai_addrlen, &address)) { | |
| 25 return NULL; | 25 return NULL; |
| 26 } | |
| 27 net_address_list->push_back(address); | 26 net_address_list->push_back(address); |
| 28 ai = ai->ai_next; | |
| 29 } | 27 } |
| 30 | 28 |
| 31 return net_address_list.release(); | 29 return net_address_list.release(); |
| 32 } | 30 } |
| 33 | 31 |
| 34 PPB_HostResolver_Shared::PPB_HostResolver_Shared(PP_Instance instance) | 32 PPB_HostResolver_Shared::PPB_HostResolver_Shared(PP_Instance instance) |
| 35 : Resource(OBJECT_IS_IMPL, instance), | 33 : Resource(OBJECT_IS_IMPL, instance), |
| 36 host_resolver_id_(GenerateHostResolverID()) { | 34 host_resolver_id_(GenerateHostResolverID()) { |
| 37 } | 35 } |
| 38 | 36 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 uint32 PPB_HostResolver_Shared::GenerateHostResolverID() { | 107 uint32 PPB_HostResolver_Shared::GenerateHostResolverID() { |
| 110 static uint32 host_resolver_id = 0; | 108 static uint32 host_resolver_id = 0; |
| 111 return host_resolver_id++; | 109 return host_resolver_id++; |
| 112 } | 110 } |
| 113 | 111 |
| 114 bool PPB_HostResolver_Shared::ResolveInProgress() const { | 112 bool PPB_HostResolver_Shared::ResolveInProgress() const { |
| 115 return TrackedCallback::IsPending(resolve_callback_); | 113 return TrackedCallback::IsPending(resolve_callback_); |
| 116 } | 114 } |
| 117 | 115 |
| 118 } // namespace ppapi | 116 } // namespace ppapi |
| OLD | NEW |