Chromium Code Reviews| Index: ppapi/cpp/network_list.cc |
| diff --git a/ppapi/cpp/private/network_list_private.cc b/ppapi/cpp/network_list.cc |
| similarity index 37% |
| rename from ppapi/cpp/private/network_list_private.cc |
| rename to ppapi/cpp/network_list.cc |
| index 5a3a5be3d014f13502f6150e717df9d51c88cf46..56f8a0b5fb3fe207d597508e244d1289cf32e574 100644 |
| --- a/ppapi/cpp/private/network_list_private.cc |
| +++ b/ppapi/cpp/network_list.cc |
| @@ -2,7 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "ppapi/cpp/private/network_list_private.h" |
| +#include "ppapi/cpp/network_list.h" |
| #include "ppapi/c/pp_errors.h" |
| #include "ppapi/cpp/array_output.h" |
| @@ -15,79 +15,98 @@ namespace pp { |
| namespace { |
| -template <> const char* interface_name<PPB_NetworkList_Private_0_3>() { |
| - return PPB_NETWORKLIST_PRIVATE_INTERFACE_0_3; |
| +template <> const char* interface_name<PPB_NetworkList>() { |
|
yzshen1
2013/09/19 07:56:12
Please append version number explicitly.
(here and
Sergey Ulanov
2013/09/20 01:17:56
Done. Sorry, poorly executed merge.
|
| + return PPB_NETWORKLIST_INTERFACE_1_0; |
| +} |
| + |
| +// Used in GetIpAddresses(); |
| +struct ResourceArray { |
|
yzshen1
2013/09/19 07:56:12
This is not needed.
Sergey Ulanov
2013/09/20 01:17:56
Done.
|
| + PP_Resource* resources; |
| + int count; |
| +}; |
| + |
| +void* AllocateResourceArray(void* data, uint32_t count, uint32_t size) { |
|
yzshen1
2013/09/19 07:56:12
This is not needed.
Sergey Ulanov
2013/09/20 01:17:56
Done.
|
| + ResourceArray* resource_array = reinterpret_cast<ResourceArray*>(data); |
| + PP_DCHECK(size == sizeof(PP_Resource)); |
| + if (size) { |
| + resource_array->resources = new PP_Resource[count]; |
| + if (resource_array->resources) |
| + resource_array->count = count; |
| + } else { |
| + resource_array->resources = NULL; |
| + } |
| + return resource_array->resources; |
| } |
| } // namespace |
| -NetworkListPrivate::NetworkListPrivate() { |
| +NetworkList::NetworkList() { |
| } |
| -NetworkListPrivate::NetworkListPrivate(PassRef, PP_Resource resource) |
| +NetworkList::NetworkList(PassRef, PP_Resource resource) |
| : Resource(PASS_REF, resource) { |
| } |
| // static |
| -bool NetworkListPrivate::IsAvailable() { |
| - return has_interface<PPB_NetworkList_Private_0_3>(); |
| +bool NetworkList::IsAvailable() { |
| + return has_interface<PPB_NetworkList>(); |
| } |
| -uint32_t NetworkListPrivate::GetCount() const { |
| - if (!has_interface<PPB_NetworkList_Private_0_3>()) |
| +uint32_t NetworkList::GetCount() const { |
| + if (!has_interface<PPB_NetworkList>()) |
| return 0; |
| - return get_interface<PPB_NetworkList_Private_0_3>()->GetCount(pp_resource()); |
| + return get_interface<PPB_NetworkList>()->GetCount(pp_resource()); |
| } |
| -std::string NetworkListPrivate::GetName(uint32_t index) const { |
| - if (!has_interface<PPB_NetworkList_Private_0_3>()) |
| +std::string NetworkList::GetName(uint32_t index) const { |
| + if (!has_interface<PPB_NetworkList>()) |
| return std::string(); |
| Var result(PASS_REF, |
| - get_interface<PPB_NetworkList_Private_0_3>()->GetName( |
| + get_interface<PPB_NetworkList>()->GetName( |
| pp_resource(), index)); |
| return result.is_string() ? result.AsString() : std::string(); |
| } |
| -PP_NetworkListType_Private NetworkListPrivate::GetType(uint32_t index) const { |
| - if (!has_interface<PPB_NetworkList_Private_0_3>()) |
| - return PP_NETWORKLIST_ETHERNET; |
| - return get_interface<PPB_NetworkList_Private_0_3>()->GetType( |
| +PP_NetworkList_Type NetworkList::GetType(uint32_t index) const { |
| + if (!has_interface<PPB_NetworkList>()) |
| + return PP_NETWORKLIST_TYPE_ETHERNET; |
| + return get_interface<PPB_NetworkList>()->GetType( |
| pp_resource(), index); |
| } |
| -PP_NetworkListState_Private NetworkListPrivate::GetState(uint32_t index) const { |
| - if (!has_interface<PPB_NetworkList_Private_0_3>()) |
| - return PP_NETWORKLIST_DOWN; |
| - return get_interface<PPB_NetworkList_Private_0_3>()->GetState( |
| +PP_NetworkList_State NetworkList::GetState(uint32_t index) const { |
| + if (!has_interface<PPB_NetworkList>()) |
| + return PP_NETWORKLIST_STATE_DOWN; |
| + return get_interface<PPB_NetworkList>()->GetState( |
| pp_resource(), index); |
| } |
| -int32_t NetworkListPrivate::GetIpAddresses( |
| +int32_t NetworkList::GetIpAddresses( |
| uint32_t index, |
| std::vector<NetAddress>* addresses) const { |
| - if (!has_interface<PPB_NetworkList_Private_0_3>()) |
| + if (!has_interface<PPB_NetworkList_1_0>()) |
| return PP_ERROR_NOINTERFACE; |
| if (!addresses) |
| return PP_ERROR_BADARGUMENT; |
| ResourceArrayOutputAdapter<NetAddress> adapter(addresses); |
| - return get_interface<PPB_NetworkList_Private_0_3>()->GetIpAddresses( |
| + return get_interface<PPB_NetworkList_1_0>()->GetIpAddresses( |
| pp_resource(), index, adapter.pp_array_output()); |
| } |
| -std::string NetworkListPrivate::GetDisplayName(uint32_t index) const { |
| - if (!has_interface<PPB_NetworkList_Private_0_3>()) |
| +std::string NetworkList::GetDisplayName(uint32_t index) const { |
| + if (!has_interface<PPB_NetworkList>()) |
| return std::string(); |
| Var result(PASS_REF, |
| - get_interface<PPB_NetworkList_Private_0_3>()->GetDisplayName( |
| + get_interface<PPB_NetworkList>()->GetDisplayName( |
| pp_resource(), index)); |
| return result.is_string() ? result.AsString() : std::string(); |
| } |
| -uint32_t NetworkListPrivate::GetMTU(uint32_t index) const { |
| - if (!has_interface<PPB_NetworkList_Private_0_3>()) |
| +uint32_t NetworkList::GetMTU(uint32_t index) const { |
| + if (!has_interface<PPB_NetworkList>()) |
| return 0; |
| - return get_interface<PPB_NetworkList_Private_0_3>()->GetMTU( |
| + return get_interface<PPB_NetworkList>()->GetMTU( |
| pp_resource(), index); |
| } |