diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-05 01:06:46 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-05 01:06:46 +0000 |
commit | e6a1b4ee5411faaf44a95204299e9738bffc8a80 (patch) | |
tree | 068d777fdaadeb9f1574b459c4b64fdf4ee51816 /ppapi | |
parent | 47ebce481df17bd82c0966403fc26a424beea077 (diff) | |
download | chromium_src-e6a1b4ee5411faaf44a95204299e9738bffc8a80.zip chromium_src-e6a1b4ee5411faaf44a95204299e9738bffc8a80.tar.gz chromium_src-e6a1b4ee5411faaf44a95204299e9738bffc8a80.tar.bz2 |
Use PP_ArrayOutput and PPB_NetAddress in PPB_NetworkList_Private..
PPB_NetworkList_Private was implemented before PP_ArrayOutput and PPB_NetAddress
was added. Refactor GetIPAddress() to use these new types.
Also removed in-process support because PPB_NetAddress doesn't support in-process mode.
BUG=281781
TBR=piman@chromium.org (trivial changes in content_renderer.gypi)
Review URL: https://chromiumcodereview.appspot.com/23806003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221324 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/api/private/ppb_network_list_private.idl | 64 | ||||
-rw-r--r-- | ppapi/c/private/ppb_network_list_private.h | 69 | ||||
-rw-r--r-- | ppapi/cpp/private/network_list_private.cc | 74 | ||||
-rw-r--r-- | ppapi/cpp/private/network_list_private.h | 6 | ||||
-rw-r--r-- | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c | 66 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_network_list_private_shared.cc | 30 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_network_list_private_shared.h | 4 | ||||
-rw-r--r-- | ppapi/tests/test_network_monitor_private.cc | 91 | ||||
-rw-r--r-- | ppapi/thunk/interfaces_ppb_private_no_permissions.h | 4 | ||||
-rw-r--r-- | ppapi/thunk/ppb_network_list_api.h | 3 | ||||
-rw-r--r-- | ppapi/thunk/ppb_network_list_private_thunk.cc | 13 |
11 files changed, 246 insertions, 178 deletions
diff --git a/ppapi/api/private/ppb_network_list_private.idl b/ppapi/api/private/ppb_network_list_private.idl index 8ec330f..f7e1e48 100644 --- a/ppapi/api/private/ppb_network_list_private.idl +++ b/ppapi/api/private/ppb_network_list_private.idl @@ -10,7 +10,7 @@ [generate_thunk] label Chrome { - M19 = 0.2 + M31 = 0.3 }; /** @@ -76,12 +76,23 @@ interface PPB_NetworkList_Private { PP_Bool IsNetworkList([in] PP_Resource resource); /** + * Gets number of interfaces in the list. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * * @return Returns number of available network interfaces or 0 if * the list has never been updated. */ uint32_t GetCount([in] PP_Resource resource); /** + * Gets name of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * * @return Returns name for the network interface with the specified * <code>index</code>. */ @@ -89,6 +100,12 @@ interface PPB_NetworkList_Private { [in] uint32_t index); /** + * Gets type of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * * @return Returns type of the network interface with the specified * <code>index</code>. */ @@ -97,6 +114,12 @@ interface PPB_NetworkList_Private { [in] uint32_t index); /** + * Gets state of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * * @return Returns current state of the network interface with the * specified <code>index</code>. */ @@ -105,22 +128,29 @@ interface PPB_NetworkList_Private { [in] uint32_t index); /** - * Gets list of IP addresses for the network interface with the - * specified <code>index</code> and stores them in - * <code>addresses</code>. If the caller didn't allocate sufficient - * space to store all addresses, then only the first - * <code>count</code> addresses are filled in. - * - * @return Returns total number of IP addresses assigned to the - * network interface or a negative error code. + * Gets list of IP addresses for a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * @param[in] output An output array which will receive + * <code>PPB_NetAddress</code> resources on success. Please note that the + * ref count of those resources has already been increased by 1 for the + * caller. + * + * @return An error code from <code>pp_errors.h</code>. */ - int32_t GetIpAddresses( - [in] PP_Resource resource, - [in] uint32_t index, - [inout, size_is(count)] PP_NetAddress_Private[] addresses, - [in] uint32_t count); + int32_t GetIpAddresses([in] PP_Resource resource, + [in] uint32_t index, + [in] PP_ArrayOutput output); /** + * Gets display name of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * * @return Returns display name for the network interface with the * specified <code>index</code>. */ @@ -128,6 +158,12 @@ interface PPB_NetworkList_Private { [in] uint32_t index); /** + * Gets MTU (Maximum Transmission Unit) of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * * @return Returns MTU for the network interface with the specified * <code>index</code> or 0 if MTU is unknown. */ diff --git a/ppapi/c/private/ppb_network_list_private.h b/ppapi/c/private/ppb_network_list_private.h index 2cba362..296d0df 100644 --- a/ppapi/c/private/ppb_network_list_private.h +++ b/ppapi/c/private/ppb_network_list_private.h @@ -4,21 +4,21 @@ */ /* From private/ppb_network_list_private.idl, - * modified Thu Mar 1 16:24:33 2012. + * modified Wed Sep 4 11:42:02 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_NETWORK_LIST_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_NETWORK_LIST_PRIVATE_H_ +#include "ppapi/c/pp_array_output.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" -#include "ppapi/c/private/ppb_net_address_private.h" -#define PPB_NETWORKLIST_PRIVATE_INTERFACE_0_2 "PPB_NetworkList_Private;0.2" -#define PPB_NETWORKLIST_PRIVATE_INTERFACE PPB_NETWORKLIST_PRIVATE_INTERFACE_0_2 +#define PPB_NETWORKLIST_PRIVATE_INTERFACE_0_3 "PPB_NetworkList_Private;0.3" +#define PPB_NETWORKLIST_PRIVATE_INTERFACE PPB_NETWORKLIST_PRIVATE_INTERFACE_0_3 /** * @file @@ -82,7 +82,7 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetworkListState_Private, 4); * received using the <code>PPB_NetworkMonitor_Private</code> * interface. */ -struct PPB_NetworkList_Private_0_2 { +struct PPB_NetworkList_Private_0_3 { /** * Determines if the specified <code>resource</code> is a * <code>NetworkList</code> object. @@ -95,52 +95,89 @@ struct PPB_NetworkList_Private_0_2 { */ PP_Bool (*IsNetworkList)(PP_Resource resource); /** + * Gets number of interfaces in the list. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * * @return Returns number of available network interfaces or 0 if * the list has never been updated. */ uint32_t (*GetCount)(PP_Resource resource); /** + * Gets name of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * * @return Returns name for the network interface with the specified * <code>index</code>. */ struct PP_Var (*GetName)(PP_Resource resource, uint32_t index); /** + * Gets type of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * * @return Returns type of the network interface with the specified * <code>index</code>. */ PP_NetworkListType_Private (*GetType)(PP_Resource resource, uint32_t index); /** + * Gets state of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * * @return Returns current state of the network interface with the * specified <code>index</code>. */ PP_NetworkListState_Private (*GetState)(PP_Resource resource, uint32_t index); /** - * Gets list of IP addresses for the network interface with the - * specified <code>index</code> and stores them in - * <code>addresses</code>. If the caller didn't allocate sufficient - * space to store all addresses, then only the first - * <code>count</code> addresses are filled in. - * - * @return Returns total number of IP addresses assigned to the - * network interface or a negative error code. + * Gets list of IP addresses for a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * @param[in] output An output array which will receive + * <code>PPB_NetAddress</code> resources on success. Please note that the + * ref count of those resources has already been increased by 1 for the + * caller. + * + * @return An error code from <code>pp_errors.h</code>. */ int32_t (*GetIpAddresses)(PP_Resource resource, uint32_t index, - struct PP_NetAddress_Private addresses[], - uint32_t count); + struct PP_ArrayOutput output); /** + * Gets display name of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * * @return Returns display name for the network interface with the * specified <code>index</code>. */ struct PP_Var (*GetDisplayName)(PP_Resource resource, uint32_t index); /** + * Gets MTU (Maximum Transmission Unit) of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * * @return Returns MTU for the network interface with the specified * <code>index</code> or 0 if MTU is unknown. */ uint32_t (*GetMTU)(PP_Resource resource, uint32_t index); }; -typedef struct PPB_NetworkList_Private_0_2 PPB_NetworkList_Private; +typedef struct PPB_NetworkList_Private_0_3 PPB_NetworkList_Private; /** * @} */ diff --git a/ppapi/cpp/private/network_list_private.cc b/ppapi/cpp/private/network_list_private.cc index 1297aa3..5a3a5be 100644 --- a/ppapi/cpp/private/network_list_private.cc +++ b/ppapi/cpp/private/network_list_private.cc @@ -4,15 +4,19 @@ #include "ppapi/cpp/private/network_list_private.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/cpp/array_output.h" +#include "ppapi/cpp/logging.h" #include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/net_address.h" #include "ppapi/cpp/var.h" namespace pp { namespace { -template <> const char* interface_name<PPB_NetworkList_Private>() { - return PPB_NETWORKLIST_PRIVATE_INTERFACE; +template <> const char* interface_name<PPB_NetworkList_Private_0_3>() { + return PPB_NETWORKLIST_PRIVATE_INTERFACE_0_3; } } // namespace @@ -26,84 +30,64 @@ NetworkListPrivate::NetworkListPrivate(PassRef, PP_Resource resource) // static bool NetworkListPrivate::IsAvailable() { - return has_interface<PPB_NetworkList_Private>(); + return has_interface<PPB_NetworkList_Private_0_3>(); } uint32_t NetworkListPrivate::GetCount() const { - if (!has_interface<PPB_NetworkList_Private>()) + if (!has_interface<PPB_NetworkList_Private_0_3>()) return 0; - return get_interface<PPB_NetworkList_Private>()->GetCount(pp_resource()); + return get_interface<PPB_NetworkList_Private_0_3>()->GetCount(pp_resource()); } std::string NetworkListPrivate::GetName(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private>()) + if (!has_interface<PPB_NetworkList_Private_0_3>()) return std::string(); Var result(PASS_REF, - get_interface<PPB_NetworkList_Private>()->GetName( + get_interface<PPB_NetworkList_Private_0_3>()->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>()) + if (!has_interface<PPB_NetworkList_Private_0_3>()) return PP_NETWORKLIST_ETHERNET; - return get_interface<PPB_NetworkList_Private>()->GetType( + return get_interface<PPB_NetworkList_Private_0_3>()->GetType( pp_resource(), index); } PP_NetworkListState_Private NetworkListPrivate::GetState(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private>()) + if (!has_interface<PPB_NetworkList_Private_0_3>()) return PP_NETWORKLIST_DOWN; - return get_interface<PPB_NetworkList_Private>()->GetState( + return get_interface<PPB_NetworkList_Private_0_3>()->GetState( pp_resource(), index); } -void NetworkListPrivate::GetIpAddresses( +int32_t NetworkListPrivate::GetIpAddresses( uint32_t index, - std::vector<PP_NetAddress_Private>* addresses) const { - if (!has_interface<PPB_NetworkList_Private>()) - return; - - // Most network interfaces don't have more than 3 network - // interfaces. - addresses->resize(3); - - int32_t result = get_interface<PPB_NetworkList_Private>()->GetIpAddresses( - pp_resource(), index, &addresses->front(), addresses->size()); - - if (result < 0) { - addresses->resize(0); - return; - } - - if (result <= static_cast<int32_t>(addresses->size())) { - addresses->resize(result); - return; - } - - addresses->resize(result); - result = get_interface<PPB_NetworkList_Private>()->GetIpAddresses( - pp_resource(), index, &addresses->front(), addresses->size()); - if (result < 0) { - addresses->resize(0); - } else if (result < static_cast<int32_t>(addresses->size())) { - addresses->resize(result); - } + std::vector<NetAddress>* addresses) const { + if (!has_interface<PPB_NetworkList_Private_0_3>()) + return PP_ERROR_NOINTERFACE; + if (!addresses) + return PP_ERROR_BADARGUMENT; + + ResourceArrayOutputAdapter<NetAddress> adapter(addresses); + return get_interface<PPB_NetworkList_Private_0_3>()->GetIpAddresses( + pp_resource(), index, adapter.pp_array_output()); } std::string NetworkListPrivate::GetDisplayName(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private>()) + if (!has_interface<PPB_NetworkList_Private_0_3>()) return std::string(); Var result(PASS_REF, - get_interface<PPB_NetworkList_Private>()->GetDisplayName( + get_interface<PPB_NetworkList_Private_0_3>()->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>()) + if (!has_interface<PPB_NetworkList_Private_0_3>()) return 0; - return get_interface<PPB_NetworkList_Private>()->GetMTU( + return get_interface<PPB_NetworkList_Private_0_3>()->GetMTU( pp_resource(), index); } diff --git a/ppapi/cpp/private/network_list_private.h b/ppapi/cpp/private/network_list_private.h index 31cd9b5..c338aa6 100644 --- a/ppapi/cpp/private/network_list_private.h +++ b/ppapi/cpp/private/network_list_private.h @@ -14,6 +14,8 @@ namespace pp { +class NetAddress; + class NetworkListPrivate : public Resource { public: NetworkListPrivate(); @@ -41,8 +43,8 @@ class NetworkListPrivate : public Resource { /// Gets the list of IP addresses for the network interface with the /// specified <code>index</code> and stores them in /// <code>addresses</code>. - void GetIpAddresses(uint32_t index, - std::vector<PP_NetAddress_Private>* addresses) const; + int32_t GetIpAddresses(uint32_t index, + std::vector<NetAddress>* addresses) const; /// @return Returns the display name for the network interface with /// the specified <code>index</code>. diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index 50268de..b1b5667 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -207,7 +207,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NaCl_Private_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_1_1; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkList_Private_0_3; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_OutputProtection_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Talk_Private_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Talk_Private_2_0; @@ -3012,49 +3012,49 @@ static void Pnacl_M19_1_PPB_NetAddress_Private_CreateFromIPv6Address(const uint8 /* End wrapper methods for PPB_NetAddress_Private_1_1 */ -/* Begin wrapper methods for PPB_NetworkList_Private_0_2 */ +/* Begin wrapper methods for PPB_NetworkList_Private_0_3 */ -static PP_Bool Pnacl_M19_PPB_NetworkList_Private_IsNetworkList(PP_Resource resource) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; +static PP_Bool Pnacl_M31_PPB_NetworkList_Private_IsNetworkList(PP_Resource resource) { + const struct PPB_NetworkList_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_3.real_iface; return iface->IsNetworkList(resource); } -static uint32_t Pnacl_M19_PPB_NetworkList_Private_GetCount(PP_Resource resource) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; +static uint32_t Pnacl_M31_PPB_NetworkList_Private_GetCount(PP_Resource resource) { + const struct PPB_NetworkList_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_3.real_iface; return iface->GetCount(resource); } -static void Pnacl_M19_PPB_NetworkList_Private_GetName(struct PP_Var* _struct_result, PP_Resource resource, uint32_t index) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; +static void Pnacl_M31_PPB_NetworkList_Private_GetName(struct PP_Var* _struct_result, PP_Resource resource, uint32_t index) { + const struct PPB_NetworkList_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_3.real_iface; *_struct_result = iface->GetName(resource, index); } -static PP_NetworkListType_Private Pnacl_M19_PPB_NetworkList_Private_GetType(PP_Resource resource, uint32_t index) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; +static PP_NetworkListType_Private Pnacl_M31_PPB_NetworkList_Private_GetType(PP_Resource resource, uint32_t index) { + const struct PPB_NetworkList_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_3.real_iface; return iface->GetType(resource, index); } -static PP_NetworkListState_Private Pnacl_M19_PPB_NetworkList_Private_GetState(PP_Resource resource, uint32_t index) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; +static PP_NetworkListState_Private Pnacl_M31_PPB_NetworkList_Private_GetState(PP_Resource resource, uint32_t index) { + const struct PPB_NetworkList_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_3.real_iface; return iface->GetState(resource, index); } -static int32_t Pnacl_M19_PPB_NetworkList_Private_GetIpAddresses(PP_Resource resource, uint32_t index, struct PP_NetAddress_Private addresses[], uint32_t count) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; - return iface->GetIpAddresses(resource, index, addresses, count); +static int32_t Pnacl_M31_PPB_NetworkList_Private_GetIpAddresses(PP_Resource resource, uint32_t index, struct PP_ArrayOutput* output) { + const struct PPB_NetworkList_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_3.real_iface; + return iface->GetIpAddresses(resource, index, *output); } -static void Pnacl_M19_PPB_NetworkList_Private_GetDisplayName(struct PP_Var* _struct_result, PP_Resource resource, uint32_t index) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; +static void Pnacl_M31_PPB_NetworkList_Private_GetDisplayName(struct PP_Var* _struct_result, PP_Resource resource, uint32_t index) { + const struct PPB_NetworkList_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_3.real_iface; *_struct_result = iface->GetDisplayName(resource, index); } -static uint32_t Pnacl_M19_PPB_NetworkList_Private_GetMTU(PP_Resource resource, uint32_t index) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; +static uint32_t Pnacl_M31_PPB_NetworkList_Private_GetMTU(PP_Resource resource, uint32_t index) { + const struct PPB_NetworkList_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_3.real_iface; return iface->GetMTU(resource, index); } -/* End wrapper methods for PPB_NetworkList_Private_0_2 */ +/* End wrapper methods for PPB_NetworkList_Private_0_3 */ /* Not generating wrapper methods for PPB_NetworkMonitor_Private_0_2 */ @@ -4725,15 +4725,15 @@ struct PPB_NetAddress_Private_1_1 Pnacl_Wrappers_PPB_NetAddress_Private_1_1 = { .CreateFromIPv6Address = (void (*)(const uint8_t ip[16], uint32_t scope_id, uint16_t port, struct PP_NetAddress_Private* addr_out))&Pnacl_M19_1_PPB_NetAddress_Private_CreateFromIPv6Address }; -struct PPB_NetworkList_Private_0_2 Pnacl_Wrappers_PPB_NetworkList_Private_0_2 = { - .IsNetworkList = (PP_Bool (*)(PP_Resource resource))&Pnacl_M19_PPB_NetworkList_Private_IsNetworkList, - .GetCount = (uint32_t (*)(PP_Resource resource))&Pnacl_M19_PPB_NetworkList_Private_GetCount, - .GetName = (struct PP_Var (*)(PP_Resource resource, uint32_t index))&Pnacl_M19_PPB_NetworkList_Private_GetName, - .GetType = (PP_NetworkListType_Private (*)(PP_Resource resource, uint32_t index))&Pnacl_M19_PPB_NetworkList_Private_GetType, - .GetState = (PP_NetworkListState_Private (*)(PP_Resource resource, uint32_t index))&Pnacl_M19_PPB_NetworkList_Private_GetState, - .GetIpAddresses = (int32_t (*)(PP_Resource resource, uint32_t index, struct PP_NetAddress_Private addresses[], uint32_t count))&Pnacl_M19_PPB_NetworkList_Private_GetIpAddresses, - .GetDisplayName = (struct PP_Var (*)(PP_Resource resource, uint32_t index))&Pnacl_M19_PPB_NetworkList_Private_GetDisplayName, - .GetMTU = (uint32_t (*)(PP_Resource resource, uint32_t index))&Pnacl_M19_PPB_NetworkList_Private_GetMTU +struct PPB_NetworkList_Private_0_3 Pnacl_Wrappers_PPB_NetworkList_Private_0_3 = { + .IsNetworkList = (PP_Bool (*)(PP_Resource resource))&Pnacl_M31_PPB_NetworkList_Private_IsNetworkList, + .GetCount = (uint32_t (*)(PP_Resource resource))&Pnacl_M31_PPB_NetworkList_Private_GetCount, + .GetName = (struct PP_Var (*)(PP_Resource resource, uint32_t index))&Pnacl_M31_PPB_NetworkList_Private_GetName, + .GetType = (PP_NetworkListType_Private (*)(PP_Resource resource, uint32_t index))&Pnacl_M31_PPB_NetworkList_Private_GetType, + .GetState = (PP_NetworkListState_Private (*)(PP_Resource resource, uint32_t index))&Pnacl_M31_PPB_NetworkList_Private_GetState, + .GetIpAddresses = (int32_t (*)(PP_Resource resource, uint32_t index, struct PP_ArrayOutput output))&Pnacl_M31_PPB_NetworkList_Private_GetIpAddresses, + .GetDisplayName = (struct PP_Var (*)(PP_Resource resource, uint32_t index))&Pnacl_M31_PPB_NetworkList_Private_GetDisplayName, + .GetMTU = (uint32_t (*)(PP_Resource resource, uint32_t index))&Pnacl_M31_PPB_NetworkList_Private_GetMTU }; /* Not generating wrapper interface for PPB_NetworkMonitor_Private_0_2 */ @@ -5394,9 +5394,9 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_1_1 = .real_iface = NULL }; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2 = { - .iface_macro = PPB_NETWORKLIST_PRIVATE_INTERFACE_0_2, - .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_NetworkList_Private_0_2, +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkList_Private_0_3 = { + .iface_macro = PPB_NETWORKLIST_PRIVATE_INTERFACE_0_3, + .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_NetworkList_Private_0_3, .real_iface = NULL }; @@ -5598,7 +5598,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_NetAddress_Private_0_1, &Pnacl_WrapperInfo_PPB_NetAddress_Private_1_0, &Pnacl_WrapperInfo_PPB_NetAddress_Private_1_1, - &Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2, + &Pnacl_WrapperInfo_PPB_NetworkList_Private_0_3, &Pnacl_WrapperInfo_PPB_OutputProtection_Private_0_1, &Pnacl_WrapperInfo_PPB_Talk_Private_1_0, &Pnacl_WrapperInfo_PPB_Talk_Private_2_0, diff --git a/ppapi/shared_impl/ppb_network_list_private_shared.cc b/ppapi/shared_impl/ppb_network_list_private_shared.cc index 29874b3..d299c06 100644 --- a/ppapi/shared_impl/ppb_network_list_private_shared.cc +++ b/ppapi/shared_impl/ppb_network_list_private_shared.cc @@ -6,8 +6,10 @@ #include "base/logging.h" #include "ppapi/c/pp_errors.h" +#include "ppapi/shared_impl/array_writer.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 +85,27 @@ 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) { - if (index >= list_->list().size()) + const PP_ArrayOutput& output) { + ArrayWriter writer(output); + if (index >= list_->list().size() || !writer.is_valid()) + return PP_ERROR_BADARGUMENT; + + thunk::EnterResourceCreationNoLock enter(pp_instance()); + if (enter.failed()) 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()); + + const std::vector<PP_NetAddress_Private>& addresses = + list_->list().at(index).addresses; + std::vector<PP_Resource> addr_resources; + for (size_t i = 0; i < addresses.size(); ++i) { + addr_resources.push_back( + enter.functions()->CreateNetAddressFromNetAddressPrivate( + pp_instance(), addresses[i])); + } + if (!writer.StoreResourceVector(addr_resources)) + return PP_ERROR_FAILED; + + return PP_OK; } PP_Var PPB_NetworkList_Private_Shared::GetDisplayName(uint32_t index) { diff --git a/ppapi/shared_impl/ppb_network_list_private_shared.h b/ppapi/shared_impl/ppb_network_list_private_shared.h index 916cc12..8396003 100644 --- a/ppapi/shared_impl/ppb_network_list_private_shared.h +++ b/ppapi/shared_impl/ppb_network_list_private_shared.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" +#include "ppapi/c/private/ppb_net_address_private.h" #include "ppapi/shared_impl/resource.h" #include "ppapi/thunk/ppb_network_list_api.h" @@ -68,8 +69,7 @@ class PPAPI_SHARED_EXPORT PPB_NetworkList_Private_Shared virtual PP_NetworkListType_Private GetType(uint32_t index) OVERRIDE; virtual PP_NetworkListState_Private GetState(uint32_t index) OVERRIDE; virtual int32_t GetIpAddresses(uint32_t index, - PP_NetAddress_Private addresses[], - uint32_t count) OVERRIDE; + const PP_ArrayOutput& output) OVERRIDE; virtual PP_Var GetDisplayName(uint32_t index) OVERRIDE; virtual uint32_t GetMTU(uint32_t index) OVERRIDE; diff --git a/ppapi/tests/test_network_monitor_private.cc b/ppapi/tests/test_network_monitor_private.cc index b2114da..a945251 100644 --- a/ppapi/tests/test_network_monitor_private.cc +++ b/ppapi/tests/test_network_monitor_private.cc @@ -8,7 +8,7 @@ #include "ppapi/cpp/instance_handle.h" #include "ppapi/cpp/module.h" -#include "ppapi/cpp/private/net_address_private.h" +#include "ppapi/cpp/net_address.h" #include "ppapi/cpp/private/network_list_private.h" #include "ppapi/cpp/private/network_monitor_private.h" #include "ppapi/tests/testing_instance.h" @@ -92,31 +92,55 @@ std::string TestNetworkMonitorPrivate::VerifyNetworkList( // Iterate over all interfaces and verify their properties. for (size_t iface = 0; iface < count; ++iface) { // Verify that the first interface has at least one address. - std::vector<PP_NetAddress_Private> addresses; + std::vector<pp::NetAddress> addresses; network_list.GetIpAddresses(iface, &addresses); ASSERT_TRUE(addresses.size() >= 1U); // Verify that the addresses are valid. for (size_t i = 0; i < addresses.size(); ++i) { - PP_NetAddressFamily_Private family = - pp::NetAddressPrivate::GetFamily(addresses[i]); - - ASSERT_TRUE(family == PP_NETADDRESSFAMILY_PRIVATE_IPV4 || - family == PP_NETADDRESSFAMILY_PRIVATE_IPV6); - - char ip[16] = { 0 }; - ASSERT_TRUE(pp::NetAddressPrivate::GetAddress( - addresses[i], ip, sizeof(ip))); - - // Verify that the address is not zero. - size_t j; - for (j = 0; j < sizeof(ip); ++j) { - if (ip[j] != 0) + PP_NetAddress_Family family = addresses[i].GetFamily(); + + switch (family) { + case PP_NETADDRESS_FAMILY_IPV4: { + PP_NetAddress_IPv4 ipv4; + ASSERT_TRUE(addresses[i].DescribeAsIPv4Address(&ipv4)); + + // Verify that the address is not zero. + bool all_zeros = true; + for (size_t j = 0; j < sizeof(ipv4.addr); ++j) { + if (ipv4.addr[j] != 0) { + all_zeros = false; + break; + } + } + ASSERT_TRUE(!all_zeros); + + // Verify that port is set to 0. + ASSERT_TRUE(ipv4.port == 0); break; - } - ASSERT_TRUE(j != addresses[i].size); + } + + case PP_NETADDRESS_FAMILY_IPV6: { + PP_NetAddress_IPv6 ipv6; + ASSERT_TRUE(addresses[i].DescribeAsIPv6Address(&ipv6)); + + // Verify that the address is not zero. + bool all_zeros = true; + for (size_t j = 0; j < sizeof(ipv6.addr); ++j) { + if (ipv6.addr[j] != 0) { + all_zeros = false; + break; + } + } + ASSERT_TRUE(!all_zeros); + + // Verify that port is set to 0. + ASSERT_TRUE(ipv6.port == 0); + break; + } - // Verify that port is set to 0. - ASSERT_TRUE(pp::NetAddressPrivate::GetPort(addresses[i]) == 0); + default: + ASSERT_TRUE(false); + } } // Verify that each interface has a unique name and a display name. @@ -132,33 +156,6 @@ std::string TestNetworkMonitorPrivate::VerifyNetworkList( ASSERT_TRUE(state <= PP_NETWORKLIST_UP); } - // Try to call GetIpAddresses() without C++ wrapper and verify that - // it always returns correct value. - const PPB_NetworkList_Private* interface = - static_cast<const PPB_NetworkList_Private*>( - pp::Module::Get()->GetBrowserInterface( - PPB_NETWORKLIST_PRIVATE_INTERFACE)); - ASSERT_TRUE(interface); - std::vector<PP_NetAddress_Private> addresses; - network_list.GetIpAddresses(0, &addresses); - size_t address_count = addresses.size(); - addresses.resize(addresses.size() + 3); - for (size_t i = 0; i < addresses.size(); ++i) { - const char kFillValue = 123; - memset(&addresses.front(), kFillValue, - addresses.size() * sizeof(PP_NetAddress_Private)); - int result = interface->GetIpAddresses(network_list.pp_resource(), 0, - &addresses.front(), i); - ASSERT_EQ(result, static_cast<int>(address_count)); - - // Verify that nothing outside the buffer was touched. - for (char* pos = reinterpret_cast<char*>(&addresses[result]); - pos != reinterpret_cast<char*>(&addresses[0] + addresses.size()); - ++pos) { - ASSERT_TRUE(*pos == kFillValue); - } - } - PASS(); } diff --git a/ppapi/thunk/interfaces_ppb_private_no_permissions.h b/ppapi/thunk/interfaces_ppb_private_no_permissions.h index eae9023..b072b18 100644 --- a/ppapi/thunk/interfaces_ppb_private_no_permissions.h +++ b/ppapi/thunk/interfaces_ppb_private_no_permissions.h @@ -37,8 +37,8 @@ PROXIED_IFACE(NoAPIName, PPB_NETADDRESS_PRIVATE_INTERFACE_1_0, PPB_NetAddress_Private_1_0) PROXIED_IFACE(NoAPIName, PPB_NETADDRESS_PRIVATE_INTERFACE_1_1, PPB_NetAddress_Private_1_1) -PROXIED_IFACE(NoAPIName, PPB_NETWORKLIST_PRIVATE_INTERFACE_0_2, - PPB_NetworkList_Private_0_2) +PROXIED_IFACE(NoAPIName, PPB_NETWORKLIST_PRIVATE_INTERFACE_0_3, + PPB_NetworkList_Private_0_3) PROXIED_IFACE(PPB_NetworkMonitor_Private, PPB_NETWORKMONITOR_PRIVATE_INTERFACE_0_2, PPB_NetworkMonitor_Private_0_2) diff --git a/ppapi/thunk/ppb_network_list_api.h b/ppapi/thunk/ppb_network_list_api.h index bbadded..b8fb9a3 100644 --- a/ppapi/thunk/ppb_network_list_api.h +++ b/ppapi/thunk/ppb_network_list_api.h @@ -31,8 +31,7 @@ class PPAPI_THUNK_EXPORT PPB_NetworkList_API { virtual PP_NetworkListType_Private GetType(uint32_t index) = 0; virtual PP_NetworkListState_Private GetState(uint32_t index) = 0; virtual int32_t GetIpAddresses(uint32_t index, - PP_NetAddress_Private addresses[], - uint32_t count) = 0; + const PP_ArrayOutput& output) = 0; virtual PP_Var GetDisplayName(uint32_t index) = 0; virtual uint32_t GetMTU(uint32_t index) = 0; }; diff --git a/ppapi/thunk/ppb_network_list_private_thunk.cc b/ppapi/thunk/ppb_network_list_private_thunk.cc index 211c7936..1a372b3 100644 --- a/ppapi/thunk/ppb_network_list_private_thunk.cc +++ b/ppapi/thunk/ppb_network_list_private_thunk.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. // From private/ppb_network_list_private.idl, -// modified Tue Apr 16 11:25:45 2013. +// modified Fri Aug 30 12:04:19 2013. #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_network_list_private.h" @@ -59,13 +59,12 @@ PP_NetworkListState_Private GetState(PP_Resource resource, uint32_t index) { int32_t GetIpAddresses(PP_Resource resource, uint32_t index, - struct PP_NetAddress_Private addresses[], - uint32_t count) { + struct PP_ArrayOutput output) { VLOG(4) << "PPB_NetworkList_Private::GetIpAddresses()"; EnterResource<PPB_NetworkList_API> enter(resource, true); if (enter.failed()) return enter.retval(); - return enter.object()->GetIpAddresses(index, addresses, count); + return enter.object()->GetIpAddresses(index, output); } struct PP_Var GetDisplayName(PP_Resource resource, uint32_t index) { @@ -84,7 +83,7 @@ uint32_t GetMTU(PP_Resource resource, uint32_t index) { return enter.object()->GetMTU(index); } -const PPB_NetworkList_Private_0_2 g_ppb_networklist_private_thunk_0_2 = { +const PPB_NetworkList_Private_0_3 g_ppb_networklist_private_thunk_0_3 = { &IsNetworkList, &GetCount, &GetName, @@ -97,8 +96,8 @@ const PPB_NetworkList_Private_0_2 g_ppb_networklist_private_thunk_0_2 = { } // namespace -const PPB_NetworkList_Private_0_2* GetPPB_NetworkList_Private_0_2_Thunk() { - return &g_ppb_networklist_private_thunk_0_2; +const PPB_NetworkList_Private_0_3* GetPPB_NetworkList_Private_0_3_Thunk() { + return &g_ppb_networklist_private_thunk_0_3; } } // namespace thunk |