Chromium Code Reviews| Index: ppapi/shared_impl/ppb_network_list_private_shared.cc |
| diff --git a/ppapi/shared_impl/ppb_network_list_private_shared.cc b/ppapi/shared_impl/ppb_network_list_private_shared.cc |
| index 29874b36cfcbe66393cc6ddf40edd71e62a4306c..520b980172c1201aa0191bc485b39d2def842b0f 100644 |
| --- a/ppapi/shared_impl/ppb_network_list_private_shared.cc |
| +++ b/ppapi/shared_impl/ppb_network_list_private_shared.cc |
| @@ -8,6 +8,7 @@ |
| #include "ppapi/c/pp_errors.h" |
| #include "ppapi/shared_impl/ppb_network_list_private_shared.h" |
| #include "ppapi/shared_impl/var.h" |
| +#include "ppapi/thunk/enter.h" |
| namespace ppapi { |
| @@ -83,15 +84,30 @@ PP_NetworkListState_Private PPB_NetworkList_Private_Shared::GetState( |
| int32_t PPB_NetworkList_Private_Shared::GetIpAddresses( |
| uint32_t index, |
| - struct PP_NetAddress_Private addresses[], |
| - uint32_t count) { |
| + const PP_ArrayOutput& output) { |
| if (index >= list_->list().size()) |
| return PP_ERROR_FAILED; |
| - count = std::min( |
| - count, static_cast<uint32_t>(list_->list().at(index).addresses.size())); |
| - memcpy(addresses, &(list_->list().at(index).addresses[0]), |
| - sizeof(PP_NetAddress_Private) * count); |
| - return static_cast<int32_t>(list_->list().at(index).addresses.size()); |
| + |
| + thunk::EnterResourceCreationNoLock enter(pp_instance()); |
| + if (enter.failed()) |
| + return PP_ERROR_FAILED; |
| + |
| + const std::vector<PP_NetAddress_Private>& addresses = |
| + list_->list().at(index).addresses; |
| + PP_Resource* address_resources = |
|
yzshen1
2013/09/03 17:47:32
It is preferred to use ArrayWriter, IMO.
Here is o
Sergey Ulanov
2013/09/03 23:42:54
Done.
|
| + reinterpret_cast<PP_Resource*>(output.GetDataBuffer( |
| + output.user_data, static_cast<uint32_t>(addresses.size()), |
| + sizeof(PP_Resource))); |
| + if (!address_resources) |
| + return PP_ERROR_NOMEMORY; |
| + |
| + for (size_t i = 0; i < addresses.size(); ++i) { |
| + address_resources[i] = |
| + enter.functions()->CreateNetAddressFromNetAddressPrivate( |
| + pp_instance(), addresses[i]); |
| + } |
| + |
| + return PP_OK; |
| } |
| PP_Var PPB_NetworkList_Private_Shared::GetDisplayName(uint32_t index) { |