diff options
author | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-23 11:51:18 +0000 |
---|---|---|
committer | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-23 11:51:18 +0000 |
commit | a8d7f509a82030205617297b83bf4b66f192c815 (patch) | |
tree | ae2f365c71d0c7f16aa4df548480bde9ec90b6ff /ppapi | |
parent | 5f39adc248a281ceb57db98d272ee4b9c382b32f (diff) | |
download | chromium_src-a8d7f509a82030205617297b83bf4b66f192c815.zip chromium_src-a8d7f509a82030205617297b83bf4b66f192c815.tar.gz chromium_src-a8d7f509a82030205617297b83bf4b66f192c815.tar.bz2 |
Add multicast support for PPB_Ext_Socket_Dev.
BUG=226303
TEST=None
Review URL: https://chromiumcodereview.appspot.com/15545003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201759 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/api/extensions/dev/ppb_ext_socket_dev.idl | 127 | ||||
-rw-r--r-- | ppapi/c/extensions/dev/ppb_ext_socket_dev.h | 191 | ||||
-rw-r--r-- | ppapi/c/pp_macros.h | 4 | ||||
-rw-r--r-- | ppapi/cpp/extensions/dev/socket_dev.cc | 148 | ||||
-rw-r--r-- | ppapi/cpp/extensions/dev/socket_dev.h | 29 | ||||
-rw-r--r-- | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c | 135 | ||||
-rw-r--r-- | ppapi/proxy/extensions_common_resource.cc | 35 | ||||
-rw-r--r-- | ppapi/thunk/interfaces_ppb_public_dev.h | 2 | ||||
-rw-r--r-- | ppapi/thunk/ppb_ext_socket_thunk.cc | 116 |
9 files changed, 733 insertions, 54 deletions
diff --git a/ppapi/api/extensions/dev/ppb_ext_socket_dev.idl b/ppapi/api/extensions/dev/ppb_ext_socket_dev.idl index 10051d7..9b0fc7b 100644 --- a/ppapi/api/extensions/dev/ppb_ext_socket_dev.idl +++ b/ppapi/api/extensions/dev/ppb_ext_socket_dev.idl @@ -9,7 +9,8 @@ */ label Chrome { - M28 = 0.1 + M28 = 0.1, + M29 = 0.2 }; /** @@ -414,4 +415,128 @@ interface PPB_Ext_Socket_Dev { [in] PP_Instance instance, [out] PP_Ext_Socket_NetworkInterface_Dev_Array result, [in] PP_CompletionCallback callback); + + /** + * Joins the multicast group and starts to receive packets from that group. + * The socket must be of UDP type and must be bound to a local port before + * calling this method. + * + * @param[in] instance A <code>PP_Instance</code>. + * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID. + * @param[in] address A string <code>PP_Var</code>. The group address to join. + * Domain names are not supported. + * @param[out] result An integer <code>PP_Var</code>. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called + * upon completion. + * + * @return An error code from <code>pp_errors.h</code>. + */ + [version=0.2] + int32_t JoinGroup( + [in] PP_Instance instance, + [in] PP_Var socket_id, + [in] PP_Var address, + [out] PP_Var result, + [in] PP_CompletionCallback callback); + + /** + * Leaves the multicast group previously joined using <code>JoinGroup</code>. + * It's not necessary to leave the multicast group before destroying the + * socket or exiting. This is automatically called by the OS. + * + * Leaving the group will prevent the router from sending multicast datagrams + * to the local host, presuming no other process on the host is still joined + * to the group. + * + * @param[in] instance A <code>PP_Instance</code>. + * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID. + * @param[in] address A string <code>PP_Var</code>. The group address to + * leave. Domain names are not supported. + * @param[out] result An integer <code>PP_Var</code>. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called + * upon completion. + * + * @return An error code from <code>pp_errors.h</code>. + */ + [version=0.2] + int32_t LeaveGroup( + [in] PP_Instance instance, + [in] PP_Var socket_id, + [in] PP_Var address, + [out] PP_Var result, + [in] PP_CompletionCallback callback); + + /** + * Sets the time-to-live of multicast packets sent to the multicast group. + * + * Calling this method does not require multicast permissions. + * + * @param[in] instance A <code>PP_Instance</code>. + * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID. + * @param[in] ttl An integer <code>PP_Var</code>. The time-to-live value. + * @param[out] result An integer <code>PP_Var</code>. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called + * upon completion. + * + * @return An error code from <code>pp_errors.h</code>. + */ + [version=0.2] + int32_t SetMulticastTimeToLive( + [in] PP_Instance instance, + [in] PP_Var socket_id, + [in] PP_Var ttl, + [out] PP_Var result, + [in] PP_CompletionCallback callback); + + /** + * Sets whether multicast packets sent from the host to the multicast group + * will be looped back to the host. + * + * Note: the behavior of <code>SetMulticastLoopbackMode</code> is slightly + * different between Windows and Unix-like systems. The inconsistency + * happens only when there is more than one application on the same host + * joined to the same multicast group while having different settings on + * multicast loopback mode. On Windows, the applications with loopback off + * will not RECEIVE the loopback packets; while on Unix-like systems, the + * applications with loopback off will not SEND the loopback packets to + * other applications on the same host. See MSDN: http://goo.gl/6vqbj + * + * Calling this method does not require multicast permissions. + * + * @param[in] instance A <code>PP_Instance</code>. + * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID. + * @param[in] enabled A boolean <code>PP_Var</code>. Indicates whether to + * enable loopback mode. + * @param[out] result An integer <code>PP_Var</code>. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called + * upon completion. + * + * @return An error code from <code>pp_errors.h</code>. + */ + [version=0.2] + int32_t SetMulticastLoopbackMode( + [in] PP_Instance instance, + [in] PP_Var socket_id, + [in] PP_Var enabled, + [out] PP_Var result, + [in] PP_CompletionCallback callback); + + /** + * Gets the multicast group addresses the socket is currently joined to. + * + * @param[in] instance A <code>PP_Instance</code>. + * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID. + * @param[out] groups An array <code>PP_Var</code> of string + * <code>PP_Var</code>s. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called + * upon completion. + * + * @return An error code from <code>pp_errors.h</code>. + */ + [version=0.2] + int32_t GetJoinedGroups( + [in] PP_Instance instance, + [in] PP_Var socket_id, + [out] PP_Var groups, + [in] PP_CompletionCallback callback); }; diff --git a/ppapi/c/extensions/dev/ppb_ext_socket_dev.h b/ppapi/c/extensions/dev/ppb_ext_socket_dev.h index b24e129..61bddd1 100644 --- a/ppapi/c/extensions/dev/ppb_ext_socket_dev.h +++ b/ppapi/c/extensions/dev/ppb_ext_socket_dev.h @@ -4,7 +4,7 @@ */ /* From extensions/dev/ppb_ext_socket_dev.idl, - * modified Tue Apr 02 16:04:00 2013. + * modified Tue May 21 16:00:11 2013. */ #ifndef PPAPI_C_EXTENSIONS_DEV_PPB_EXT_SOCKET_DEV_H_ @@ -18,7 +18,8 @@ #include "ppapi/c/pp_var.h" #define PPB_EXT_SOCKET_DEV_INTERFACE_0_1 "PPB_Ext_Socket(Dev);0.1" -#define PPB_EXT_SOCKET_DEV_INTERFACE PPB_EXT_SOCKET_DEV_INTERFACE_0_1 +#define PPB_EXT_SOCKET_DEV_INTERFACE_0_2 "PPB_Ext_Socket(Dev);0.2" +#define PPB_EXT_SOCKET_DEV_INTERFACE PPB_EXT_SOCKET_DEV_INTERFACE_0_2 /** * @file @@ -137,7 +138,7 @@ typedef struct PP_Var PP_Ext_Socket_NetworkInterface_Dev_Array; * @addtogroup Interfaces * @{ */ -struct PPB_Ext_Socket_Dev_0_1 { +struct PPB_Ext_Socket_Dev_0_2 { /** * Creates a socket of the specified type that will connect to the specified * remote machine. @@ -409,9 +410,191 @@ struct PPB_Ext_Socket_Dev_0_1 { int32_t (*GetNetworkList)(PP_Instance instance, PP_Ext_Socket_NetworkInterface_Dev_Array* result, struct PP_CompletionCallback callback); + /** + * Joins the multicast group and starts to receive packets from that group. + * The socket must be of UDP type and must be bound to a local port before + * calling this method. + * + * @param[in] instance A <code>PP_Instance</code>. + * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID. + * @param[in] address A string <code>PP_Var</code>. The group address to join. + * Domain names are not supported. + * @param[out] result An integer <code>PP_Var</code>. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called + * upon completion. + * + * @return An error code from <code>pp_errors.h</code>. + */ + int32_t (*JoinGroup)(PP_Instance instance, + struct PP_Var socket_id, + struct PP_Var address, + struct PP_Var* result, + struct PP_CompletionCallback callback); + /** + * Leaves the multicast group previously joined using <code>JoinGroup</code>. + * It's not necessary to leave the multicast group before destroying the + * socket or exiting. This is automatically called by the OS. + * + * Leaving the group will prevent the router from sending multicast datagrams + * to the local host, presuming no other process on the host is still joined + * to the group. + * + * @param[in] instance A <code>PP_Instance</code>. + * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID. + * @param[in] address A string <code>PP_Var</code>. The group address to + * leave. Domain names are not supported. + * @param[out] result An integer <code>PP_Var</code>. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called + * upon completion. + * + * @return An error code from <code>pp_errors.h</code>. + */ + int32_t (*LeaveGroup)(PP_Instance instance, + struct PP_Var socket_id, + struct PP_Var address, + struct PP_Var* result, + struct PP_CompletionCallback callback); + /** + * Sets the time-to-live of multicast packets sent to the multicast group. + * + * Calling this method does not require multicast permissions. + * + * @param[in] instance A <code>PP_Instance</code>. + * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID. + * @param[in] ttl An integer <code>PP_Var</code>. The time-to-live value. + * @param[out] result An integer <code>PP_Var</code>. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called + * upon completion. + * + * @return An error code from <code>pp_errors.h</code>. + */ + int32_t (*SetMulticastTimeToLive)(PP_Instance instance, + struct PP_Var socket_id, + struct PP_Var ttl, + struct PP_Var* result, + struct PP_CompletionCallback callback); + /** + * Sets whether multicast packets sent from the host to the multicast group + * will be looped back to the host. + * + * Note: the behavior of <code>SetMulticastLoopbackMode</code> is slightly + * different between Windows and Unix-like systems. The inconsistency + * happens only when there is more than one application on the same host + * joined to the same multicast group while having different settings on + * multicast loopback mode. On Windows, the applications with loopback off + * will not RECEIVE the loopback packets; while on Unix-like systems, the + * applications with loopback off will not SEND the loopback packets to + * other applications on the same host. See MSDN: http://goo.gl/6vqbj + * + * Calling this method does not require multicast permissions. + * + * @param[in] instance A <code>PP_Instance</code>. + * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID. + * @param[in] enabled A boolean <code>PP_Var</code>. Indicates whether to + * enable loopback mode. + * @param[out] result An integer <code>PP_Var</code>. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called + * upon completion. + * + * @return An error code from <code>pp_errors.h</code>. + */ + int32_t (*SetMulticastLoopbackMode)(PP_Instance instance, + struct PP_Var socket_id, + struct PP_Var enabled, + struct PP_Var* result, + struct PP_CompletionCallback callback); + /** + * Gets the multicast group addresses the socket is currently joined to. + * + * @param[in] instance A <code>PP_Instance</code>. + * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID. + * @param[out] groups An array <code>PP_Var</code> of string + * <code>PP_Var</code>s. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called + * upon completion. + * + * @return An error code from <code>pp_errors.h</code>. + */ + int32_t (*GetJoinedGroups)(PP_Instance instance, + struct PP_Var socket_id, + struct PP_Var* groups, + struct PP_CompletionCallback callback); }; -typedef struct PPB_Ext_Socket_Dev_0_1 PPB_Ext_Socket_Dev; +typedef struct PPB_Ext_Socket_Dev_0_2 PPB_Ext_Socket_Dev; + +struct PPB_Ext_Socket_Dev_0_1 { + int32_t (*Create)(PP_Instance instance, + PP_Ext_Socket_SocketType_Dev type, + PP_Ext_Socket_CreateOptions_Dev options, + PP_Ext_Socket_CreateInfo_Dev* create_info, + struct PP_CompletionCallback callback); + void (*Destroy)(PP_Instance instance, struct PP_Var socket_id); + int32_t (*Connect)(PP_Instance instance, + struct PP_Var socket_id, + struct PP_Var hostname, + struct PP_Var port, + struct PP_Var* result, + struct PP_CompletionCallback callback); + int32_t (*Bind)(PP_Instance instance, + struct PP_Var socket_id, + struct PP_Var address, + struct PP_Var port, + struct PP_Var* result, + struct PP_CompletionCallback callback); + void (*Disconnect)(PP_Instance instance, struct PP_Var socket_id); + int32_t (*Read)(PP_Instance instance, + struct PP_Var socket_id, + struct PP_Var buffer_size, + PP_Ext_Socket_ReadInfo_Dev* read_info, + struct PP_CompletionCallback callback); + int32_t (*Write)(PP_Instance instance, + struct PP_Var socket_id, + struct PP_Var data, + PP_Ext_Socket_WriteInfo_Dev* write_info, + struct PP_CompletionCallback callback); + int32_t (*RecvFrom)(PP_Instance instance, + struct PP_Var socket_id, + struct PP_Var buffer_size, + PP_Ext_Socket_RecvFromInfo_Dev* recv_from_info, + struct PP_CompletionCallback callback); + int32_t (*SendTo)(PP_Instance instance, + struct PP_Var socket_id, + struct PP_Var data, + struct PP_Var address, + struct PP_Var port, + PP_Ext_Socket_WriteInfo_Dev* write_info, + struct PP_CompletionCallback callback); + int32_t (*Listen)(PP_Instance instance, + struct PP_Var socket_id, + struct PP_Var address, + struct PP_Var port, + struct PP_Var backlog, + struct PP_Var* result, + struct PP_CompletionCallback callback); + int32_t (*Accept)(PP_Instance instance, + struct PP_Var socket_id, + PP_Ext_Socket_AcceptInfo_Dev* accept_info, + struct PP_CompletionCallback callback); + int32_t (*SetKeepAlive)(PP_Instance instance, + struct PP_Var socket_id, + struct PP_Var enable, + struct PP_Var delay, + struct PP_Var* result, + struct PP_CompletionCallback callback); + int32_t (*SetNoDelay)(PP_Instance instance, + struct PP_Var socket_id, + struct PP_Var no_delay, + struct PP_Var* result, + struct PP_CompletionCallback callback); + int32_t (*GetInfo)(PP_Instance instance, + struct PP_Var socket_id, + PP_Ext_Socket_SocketInfo_Dev* result, + struct PP_CompletionCallback callback); + int32_t (*GetNetworkList)(PP_Instance instance, + PP_Ext_Socket_NetworkInterface_Dev_Array* result, + struct PP_CompletionCallback callback); +}; /** * @} */ diff --git a/ppapi/c/pp_macros.h b/ppapi/c/pp_macros.h index 6179380..c56d95b 100644 --- a/ppapi/c/pp_macros.h +++ b/ppapi/c/pp_macros.h @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -/* From pp_macros.idl modified Tue Mar 19 12:29:49 2013. */ +/* From pp_macros.idl modified Thu Mar 14 13:24:42 2013. */ #ifndef PPAPI_C_PP_MACROS_H_ #define PPAPI_C_PP_MACROS_H_ -#define PPAPI_RELEASE 28 +#define PPAPI_RELEASE 29 /** * @file diff --git a/ppapi/cpp/extensions/dev/socket_dev.cc b/ppapi/cpp/extensions/dev/socket_dev.cc index fb493ba..558f01e 100644 --- a/ppapi/cpp/extensions/dev/socket_dev.cc +++ b/ppapi/cpp/extensions/dev/socket_dev.cc @@ -14,8 +14,8 @@ namespace pp { namespace { -template <> const char* interface_name<PPB_Ext_Socket_Dev_0_1>() { - return PPB_EXT_SOCKET_DEV_INTERFACE_0_1; +template <> const char* interface_name<PPB_Ext_Socket_Dev_0_2>() { + return PPB_EXT_SOCKET_DEV_INTERFACE_0_2; } } // namespace @@ -317,13 +317,13 @@ Socket_Dev::~Socket_Dev() { int32_t Socket_Dev::Create(const SocketType_Dev& type, const Optional<CreateOptions_Dev>& options, const CreateCallback& callback) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return callback.MayForce(PP_ERROR_NOINTERFACE); internal::ToVarConverter<SocketType_Dev> type_var(type); internal::ToVarConverter<Optional<CreateOptions_Dev> > options_var(options); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->Create( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->Create( instance_.pp_instance(), type_var.pp_var(), options_var.pp_var(), @@ -332,12 +332,12 @@ int32_t Socket_Dev::Create(const SocketType_Dev& type, } void Socket_Dev::Destroy(int32_t socket_id) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return; internal::ToVarConverter<int32_t> socket_id_var(socket_id); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->Destroy( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->Destroy( instance_.pp_instance(), socket_id_var.pp_var()); } @@ -346,14 +346,14 @@ int32_t Socket_Dev::Connect(int32_t socket_id, const std::string& hostname, int32_t port, const ConnectCallback& callback) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return callback.MayForce(PP_ERROR_NOINTERFACE); internal::ToVarConverter<int32_t> socket_id_var(socket_id); internal::ToVarConverter<std::string> hostname_var(hostname); internal::ToVarConverter<int32_t> port_var(port); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->Connect( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->Connect( instance_.pp_instance(), socket_id_var.pp_var(), hostname_var.pp_var(), @@ -366,14 +366,14 @@ int32_t Socket_Dev::Bind(int32_t socket_id, const std::string& address, int32_t port, const BindCallback& callback) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return callback.MayForce(PP_ERROR_NOINTERFACE); internal::ToVarConverter<int32_t> socket_id_var(socket_id); internal::ToVarConverter<std::string> address_var(address); internal::ToVarConverter<int32_t> port_var(port); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->Bind( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->Bind( instance_.pp_instance(), socket_id_var.pp_var(), address_var.pp_var(), @@ -383,12 +383,12 @@ int32_t Socket_Dev::Bind(int32_t socket_id, } void Socket_Dev::Disconnect(int32_t socket_id) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return; internal::ToVarConverter<int32_t> socket_id_var(socket_id); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->Disconnect( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->Disconnect( instance_.pp_instance(), socket_id_var.pp_var()); } @@ -396,13 +396,13 @@ void Socket_Dev::Disconnect(int32_t socket_id) { int32_t Socket_Dev::Read(int32_t socket_id, const Optional<int32_t>& buffer_size, const ReadCallback& callback) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return callback.MayForce(PP_ERROR_NOINTERFACE); internal::ToVarConverter<int32_t> socket_id_var(socket_id); internal::ToVarConverter<Optional<int32_t> > buffer_size_var(buffer_size); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->Read( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->Read( instance_.pp_instance(), socket_id_var.pp_var(), buffer_size_var.pp_var(), @@ -413,13 +413,13 @@ int32_t Socket_Dev::Read(int32_t socket_id, int32_t Socket_Dev::Write(int32_t socket_id, const VarArrayBuffer& data, const WriteCallback& callback) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return callback.MayForce(PP_ERROR_NOINTERFACE); internal::ToVarConverter<int32_t> socket_id_var(socket_id); internal::ToVarConverter<Var> data_var(data); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->Write( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->Write( instance_.pp_instance(), socket_id_var.pp_var(), data_var.pp_var(), @@ -430,13 +430,13 @@ int32_t Socket_Dev::Write(int32_t socket_id, int32_t Socket_Dev::RecvFrom(int32_t socket_id, const Optional<int32_t>& buffer_size, const RecvFromCallback& callback) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return callback.MayForce(PP_ERROR_NOINTERFACE); internal::ToVarConverter<int32_t> socket_id_var(socket_id); internal::ToVarConverter<Optional<int32_t> > buffer_size_var(buffer_size); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->RecvFrom( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->RecvFrom( instance_.pp_instance(), socket_id_var.pp_var(), buffer_size_var.pp_var(), @@ -449,7 +449,7 @@ int32_t Socket_Dev::SendTo(int32_t socket_id, const std::string& address, int32_t port, const SendToCallback& callback) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return callback.MayForce(PP_ERROR_NOINTERFACE); internal::ToVarConverter<int32_t> socket_id_var(socket_id); @@ -457,7 +457,7 @@ int32_t Socket_Dev::SendTo(int32_t socket_id, internal::ToVarConverter<std::string> address_var(address); internal::ToVarConverter<int32_t> port_var(port); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->SendTo( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->SendTo( instance_.pp_instance(), socket_id_var.pp_var(), data_var.pp_var(), @@ -472,7 +472,7 @@ int32_t Socket_Dev::Listen(int32_t socket_id, int32_t port, const Optional<int32_t>& backlog, const ListenCallback& callback) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return callback.MayForce(PP_ERROR_NOINTERFACE); internal::ToVarConverter<int32_t> socket_id_var(socket_id); @@ -480,7 +480,7 @@ int32_t Socket_Dev::Listen(int32_t socket_id, internal::ToVarConverter<int32_t> port_var(port); internal::ToVarConverter<Optional<int32_t> > backlog_var(backlog); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->Listen( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->Listen( instance_.pp_instance(), socket_id_var.pp_var(), address_var.pp_var(), @@ -492,12 +492,12 @@ int32_t Socket_Dev::Listen(int32_t socket_id, int32_t Socket_Dev::Accept(int32_t socket_id, const AcceptCallback& callback) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return callback.MayForce(PP_ERROR_NOINTERFACE); internal::ToVarConverter<int32_t> socket_id_var(socket_id); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->Accept( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->Accept( instance_.pp_instance(), socket_id_var.pp_var(), callback.output(), @@ -508,14 +508,14 @@ int32_t Socket_Dev::SetKeepAlive(int32_t socket_id, bool enable, const Optional<int32_t>& delay, const SetKeepAliveCallback& callback) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return callback.MayForce(PP_ERROR_NOINTERFACE); internal::ToVarConverter<int32_t> socket_id_var(socket_id); internal::ToVarConverter<bool> enable_var(enable); internal::ToVarConverter<Optional<int32_t> > delay_var(delay); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->SetKeepAlive( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->SetKeepAlive( instance_.pp_instance(), socket_id_var.pp_var(), enable_var.pp_var(), @@ -527,13 +527,13 @@ int32_t Socket_Dev::SetKeepAlive(int32_t socket_id, int32_t Socket_Dev::SetNoDelay(int32_t socket_id, bool no_delay, const SetNoDelayCallback& callback) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return callback.MayForce(PP_ERROR_NOINTERFACE); internal::ToVarConverter<int32_t> socket_id_var(socket_id); internal::ToVarConverter<bool> no_delay_var(no_delay); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->SetNoDelay( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->SetNoDelay( instance_.pp_instance(), socket_id_var.pp_var(), no_delay_var.pp_var(), @@ -543,12 +543,12 @@ int32_t Socket_Dev::SetNoDelay(int32_t socket_id, int32_t Socket_Dev::GetInfo(int32_t socket_id, const GetInfoCallback& callback) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return callback.MayForce(PP_ERROR_NOINTERFACE); internal::ToVarConverter<int32_t> socket_id_var(socket_id); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->GetInfo( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->GetInfo( instance_.pp_instance(), socket_id_var.pp_var(), callback.output(), @@ -556,15 +556,99 @@ int32_t Socket_Dev::GetInfo(int32_t socket_id, } int32_t Socket_Dev::GetNetworkList(const GetNetworkListCallback& callback) { - if (!has_interface<PPB_Ext_Socket_Dev_0_1>()) + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) return callback.MayForce(PP_ERROR_NOINTERFACE); - return get_interface<PPB_Ext_Socket_Dev_0_1>()->GetNetworkList( + return get_interface<PPB_Ext_Socket_Dev_0_2>()->GetNetworkList( instance_.pp_instance(), callback.output(), callback.pp_completion_callback()); } +int32_t Socket_Dev::JoinGroup(int32_t socket_id, + const std::string& address, + const JoinGroupCallback& callback) { + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + internal::ToVarConverter<int32_t> socket_id_var(socket_id); + internal::ToVarConverter<std::string> address_var(address); + + return get_interface<PPB_Ext_Socket_Dev_0_2>()->JoinGroup( + instance_.pp_instance(), + socket_id_var.pp_var(), + address_var.pp_var(), + callback.output(), + callback.pp_completion_callback()); +} + +int32_t Socket_Dev::LeaveGroup(int32_t socket_id, + const std::string& address, + const LeaveGroupCallback& callback) { + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + internal::ToVarConverter<int32_t> socket_id_var(socket_id); + internal::ToVarConverter<std::string> address_var(address); + + return get_interface<PPB_Ext_Socket_Dev_0_2>()->LeaveGroup( + instance_.pp_instance(), + socket_id_var.pp_var(), + address_var.pp_var(), + callback.output(), + callback.pp_completion_callback()); +} + +int32_t Socket_Dev::SetMulticastTimeToLive( + int32_t socket_id, + int32_t ttl, + const SetMulticastTimeToLiveCallback& callback) { + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + internal::ToVarConverter<int32_t> socket_id_var(socket_id); + internal::ToVarConverter<int32_t> ttl_var(ttl); + + return get_interface<PPB_Ext_Socket_Dev_0_2>()->SetMulticastTimeToLive( + instance_.pp_instance(), + socket_id_var.pp_var(), + ttl_var.pp_var(), + callback.output(), + callback.pp_completion_callback()); +} + +int32_t Socket_Dev::SetMulticastLoopbackMode( + int32_t socket_id, + bool enabled, + const SetMulticastLoopbackModeCallback& callback) { + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + internal::ToVarConverter<int32_t> socket_id_var(socket_id); + internal::ToVarConverter<bool> enabled_var(enabled); + + return get_interface<PPB_Ext_Socket_Dev_0_2>()->SetMulticastLoopbackMode( + instance_.pp_instance(), + socket_id_var.pp_var(), + enabled_var.pp_var(), + callback.output(), + callback.pp_completion_callback()); +} + +int32_t Socket_Dev::GetJoinedGroups(int32_t socket_id, + const GetJoinedGroupsCallback& callback) { + if (!has_interface<PPB_Ext_Socket_Dev_0_2>()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + internal::ToVarConverter<int32_t> socket_id_var(socket_id); + + return get_interface<PPB_Ext_Socket_Dev_0_2>()->GetJoinedGroups( + instance_.pp_instance(), + socket_id_var.pp_var(), + callback.output(), + callback.pp_completion_callback()); +} + } // namespace socket } // namespace ext } // namespace pp diff --git a/ppapi/cpp/extensions/dev/socket_dev.h b/ppapi/cpp/extensions/dev/socket_dev.h index c51b6cc..95e78d3 100644 --- a/ppapi/cpp/extensions/dev/socket_dev.h +++ b/ppapi/cpp/extensions/dev/socket_dev.h @@ -250,6 +250,35 @@ class Socket_Dev { GetNetworkListCallback; int32_t GetNetworkList(const GetNetworkListCallback& callback); + typedef ExtCompletionCallbackWithOutput<int32_t> JoinGroupCallback; + int32_t JoinGroup(int32_t socket_id, + const std::string& address, + const JoinGroupCallback& callback); + + typedef ExtCompletionCallbackWithOutput<int32_t> LeaveGroupCallback; + int32_t LeaveGroup(int32_t socket_id, + const std::string& address, + const LeaveGroupCallback& callback); + + typedef ExtCompletionCallbackWithOutput<int32_t> + SetMulticastTimeToLiveCallback; + int32_t SetMulticastTimeToLive( + int32_t socket_id, + int32_t ttl, + const SetMulticastTimeToLiveCallback& callback); + + typedef ExtCompletionCallbackWithOutput<int32_t> + SetMulticastLoopbackModeCallback; + int32_t SetMulticastLoopbackMode( + int32_t socket_id, + bool enabled, + const SetMulticastLoopbackModeCallback& callback); + + typedef ExtCompletionCallbackWithOutput<std::vector<std::string> > + GetJoinedGroupsCallback; + int32_t GetJoinedGroups(int32_t socket_id, + const GetJoinedGroupsCallback& callback); + private: InstanceHandle instance_; }; 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 7d93dda57..bd3b848 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 @@ -281,6 +281,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Instance_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Alarms_Dev_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Events_Dev_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2; /* END Declarations for all Wrapper Infos. */ /* Not generating wrapper methods for PPB_Audio_1_0 */ @@ -3653,6 +3654,110 @@ static int32_t Pnacl_M28_PPB_Ext_Socket_Dev_GetNetworkList(PP_Instance instance, /* End wrapper methods for PPB_Ext_Socket_Dev_0_1 */ +/* Begin wrapper methods for PPB_Ext_Socket_Dev_0_2 */ + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_Create(PP_Instance instance, PP_Ext_Socket_SocketType_Dev type, PP_Ext_Socket_CreateOptions_Dev options, PP_Ext_Socket_CreateInfo_Dev* create_info, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->Create(instance, type, options, create_info, *callback); +} + +static void Pnacl_M29_PPB_Ext_Socket_Dev_Destroy(PP_Instance instance, struct PP_Var* socket_id) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + iface->Destroy(instance, *socket_id); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_Connect(PP_Instance instance, struct PP_Var* socket_id, struct PP_Var* hostname, struct PP_Var* port, struct PP_Var* result, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->Connect(instance, *socket_id, *hostname, *port, result, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_Bind(PP_Instance instance, struct PP_Var* socket_id, struct PP_Var* address, struct PP_Var* port, struct PP_Var* result, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->Bind(instance, *socket_id, *address, *port, result, *callback); +} + +static void Pnacl_M29_PPB_Ext_Socket_Dev_Disconnect(PP_Instance instance, struct PP_Var* socket_id) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + iface->Disconnect(instance, *socket_id); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_Read(PP_Instance instance, struct PP_Var* socket_id, struct PP_Var* buffer_size, PP_Ext_Socket_ReadInfo_Dev* read_info, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->Read(instance, *socket_id, *buffer_size, read_info, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_Write(PP_Instance instance, struct PP_Var* socket_id, struct PP_Var* data, PP_Ext_Socket_WriteInfo_Dev* write_info, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->Write(instance, *socket_id, *data, write_info, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_RecvFrom(PP_Instance instance, struct PP_Var* socket_id, struct PP_Var* buffer_size, PP_Ext_Socket_RecvFromInfo_Dev* recv_from_info, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->RecvFrom(instance, *socket_id, *buffer_size, recv_from_info, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_SendTo(PP_Instance instance, struct PP_Var* socket_id, struct PP_Var* data, struct PP_Var* address, struct PP_Var* port, PP_Ext_Socket_WriteInfo_Dev* write_info, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->SendTo(instance, *socket_id, *data, *address, *port, write_info, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_Listen(PP_Instance instance, struct PP_Var* socket_id, struct PP_Var* address, struct PP_Var* port, struct PP_Var* backlog, struct PP_Var* result, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->Listen(instance, *socket_id, *address, *port, *backlog, result, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_Accept(PP_Instance instance, struct PP_Var* socket_id, PP_Ext_Socket_AcceptInfo_Dev* accept_info, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->Accept(instance, *socket_id, accept_info, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_SetKeepAlive(PP_Instance instance, struct PP_Var* socket_id, struct PP_Var* enable, struct PP_Var* delay, struct PP_Var* result, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->SetKeepAlive(instance, *socket_id, *enable, *delay, result, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_SetNoDelay(PP_Instance instance, struct PP_Var* socket_id, struct PP_Var* no_delay, struct PP_Var* result, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->SetNoDelay(instance, *socket_id, *no_delay, result, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_GetInfo(PP_Instance instance, struct PP_Var* socket_id, PP_Ext_Socket_SocketInfo_Dev* result, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->GetInfo(instance, *socket_id, result, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_GetNetworkList(PP_Instance instance, PP_Ext_Socket_NetworkInterface_Dev_Array* result, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->GetNetworkList(instance, result, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_JoinGroup(PP_Instance instance, struct PP_Var* socket_id, struct PP_Var* address, struct PP_Var* result, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->JoinGroup(instance, *socket_id, *address, result, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_LeaveGroup(PP_Instance instance, struct PP_Var* socket_id, struct PP_Var* address, struct PP_Var* result, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->LeaveGroup(instance, *socket_id, *address, result, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_SetMulticastTimeToLive(PP_Instance instance, struct PP_Var* socket_id, struct PP_Var* ttl, struct PP_Var* result, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->SetMulticastTimeToLive(instance, *socket_id, *ttl, result, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_SetMulticastLoopbackMode(PP_Instance instance, struct PP_Var* socket_id, struct PP_Var* enabled, struct PP_Var* result, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->SetMulticastLoopbackMode(instance, *socket_id, *enabled, result, *callback); +} + +static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_GetJoinedGroups(PP_Instance instance, struct PP_Var* socket_id, struct PP_Var* groups, struct PP_CompletionCallback* callback) { + const struct PPB_Ext_Socket_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2.real_iface; + return iface->GetJoinedGroups(instance, *socket_id, groups, *callback); +} + +/* End wrapper methods for PPB_Ext_Socket_Dev_0_2 */ + /* Not generating wrapper interface for PPB_Audio_1_0 */ /* Not generating wrapper interface for PPB_AudioConfig_1_0 */ @@ -4616,6 +4721,29 @@ struct PPB_Ext_Socket_Dev_0_1 Pnacl_Wrappers_PPB_Ext_Socket_Dev_0_1 = { .GetNetworkList = (int32_t (*)(PP_Instance instance, PP_Ext_Socket_NetworkInterface_Dev_Array* result, struct PP_CompletionCallback callback))&Pnacl_M28_PPB_Ext_Socket_Dev_GetNetworkList }; +struct PPB_Ext_Socket_Dev_0_2 Pnacl_Wrappers_PPB_Ext_Socket_Dev_0_2 = { + .Create = (int32_t (*)(PP_Instance instance, PP_Ext_Socket_SocketType_Dev type, PP_Ext_Socket_CreateOptions_Dev options, PP_Ext_Socket_CreateInfo_Dev* create_info, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_Create, + .Destroy = (void (*)(PP_Instance instance, struct PP_Var socket_id))&Pnacl_M29_PPB_Ext_Socket_Dev_Destroy, + .Connect = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, struct PP_Var hostname, struct PP_Var port, struct PP_Var* result, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_Connect, + .Bind = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, struct PP_Var address, struct PP_Var port, struct PP_Var* result, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_Bind, + .Disconnect = (void (*)(PP_Instance instance, struct PP_Var socket_id))&Pnacl_M29_PPB_Ext_Socket_Dev_Disconnect, + .Read = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, struct PP_Var buffer_size, PP_Ext_Socket_ReadInfo_Dev* read_info, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_Read, + .Write = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, struct PP_Var data, PP_Ext_Socket_WriteInfo_Dev* write_info, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_Write, + .RecvFrom = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, struct PP_Var buffer_size, PP_Ext_Socket_RecvFromInfo_Dev* recv_from_info, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_RecvFrom, + .SendTo = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, struct PP_Var data, struct PP_Var address, struct PP_Var port, PP_Ext_Socket_WriteInfo_Dev* write_info, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_SendTo, + .Listen = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, struct PP_Var address, struct PP_Var port, struct PP_Var backlog, struct PP_Var* result, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_Listen, + .Accept = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, PP_Ext_Socket_AcceptInfo_Dev* accept_info, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_Accept, + .SetKeepAlive = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, struct PP_Var enable, struct PP_Var delay, struct PP_Var* result, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_SetKeepAlive, + .SetNoDelay = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, struct PP_Var no_delay, struct PP_Var* result, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_SetNoDelay, + .GetInfo = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, PP_Ext_Socket_SocketInfo_Dev* result, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_GetInfo, + .GetNetworkList = (int32_t (*)(PP_Instance instance, PP_Ext_Socket_NetworkInterface_Dev_Array* result, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_GetNetworkList, + .JoinGroup = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, struct PP_Var address, struct PP_Var* result, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_JoinGroup, + .LeaveGroup = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, struct PP_Var address, struct PP_Var* result, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_LeaveGroup, + .SetMulticastTimeToLive = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, struct PP_Var ttl, struct PP_Var* result, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_SetMulticastTimeToLive, + .SetMulticastLoopbackMode = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, struct PP_Var enabled, struct PP_Var* result, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_SetMulticastLoopbackMode, + .GetJoinedGroups = (int32_t (*)(PP_Instance instance, struct PP_Var socket_id, struct PP_Var* groups, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_Ext_Socket_Dev_GetJoinedGroups +}; + static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Audio_1_0 = { .iface_macro = PPB_AUDIO_INTERFACE_1_0, .wrapped_iface = NULL /* Still need slot for real_iface */, @@ -5516,6 +5644,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1 = { .real_iface = NULL }; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2 = { + .iface_macro = PPB_EXT_SOCKET_DEV_INTERFACE_0_2, + .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_Ext_Socket_Dev_0_2, + .real_iface = NULL +}; + static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_Audio_1_0, &Pnacl_WrapperInfo_PPB_AudioConfig_1_0, @@ -5644,6 +5778,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_Ext_Alarms_Dev_0_1, &Pnacl_WrapperInfo_PPB_Ext_Events_Dev_0_1, &Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1, + &Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2, NULL }; diff --git a/ppapi/proxy/extensions_common_resource.cc b/ppapi/proxy/extensions_common_resource.cc index 0393b12..40d03f9 100644 --- a/ppapi/proxy/extensions_common_resource.cc +++ b/ppapi/proxy/extensions_common_resource.cc @@ -109,21 +109,26 @@ void ExtensionsCommonResource::OnPluginMsgCallReply( return; int32_t result = params.result(); - if (result == PP_OK) { - // If the size doesn't match, something must be really wrong. - CHECK_EQ(output_args.size(), output.GetSize()); - - std::vector<PP_Var> output_vars; - if (CreateVarVectorFromListValue(output, &output_vars)) { - DCHECK_EQ(output_args.size(), output_vars.size()); - std::vector<PP_Var>::const_iterator src_iter = output_vars.begin(); - std::vector<PP_Var*>::const_iterator dest_iter = output_args.begin(); - for (; src_iter != output_vars.end() && dest_iter != output_args.end(); - ++src_iter, ++dest_iter) { - **dest_iter = *src_iter; - } - } else { - result = PP_ERROR_FAILED; + + // If the size doesn't match, something must be really wrong. + CHECK_EQ(output_args.size(), output.GetSize()); + + std::vector<PP_Var> output_vars; + if (CreateVarVectorFromListValue(output, &output_vars)) { + DCHECK_EQ(output_args.size(), output_vars.size()); + std::vector<PP_Var>::const_iterator src_iter = output_vars.begin(); + std::vector<PP_Var*>::const_iterator dest_iter = output_args.begin(); + for (; src_iter != output_vars.end() && dest_iter != output_args.end(); + ++src_iter, ++dest_iter) { + **dest_iter = *src_iter; + } + } else { + NOTREACHED(); + result = PP_ERROR_FAILED; + for (std::vector<PP_Var*>::const_iterator dest_iter = output_args.begin(); + dest_iter != output_args.end(); + ++dest_iter) { + **dest_iter = PP_MakeUndefined(); } } diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h index 707e0e5..ea8fccb 100644 --- a/ppapi/thunk/interfaces_ppb_public_dev.h +++ b/ppapi/thunk/interfaces_ppb_public_dev.h @@ -16,6 +16,8 @@ PROXIED_IFACE(NoAPIName, PPB_EXT_ALARMS_DEV_INTERFACE_0_1, PPB_Ext_Alarms_Dev_0_1) PROXIED_IFACE(NoAPIName, PPB_EXT_SOCKET_DEV_INTERFACE_0_1, PPB_Ext_Socket_Dev_0_1) +PROXIED_IFACE(NoAPIName, PPB_EXT_SOCKET_DEV_INTERFACE_0_2, + PPB_Ext_Socket_Dev_0_2) PROXIED_IFACE(NoAPIName, PPB_FILECHOOSER_DEV_INTERFACE_0_5, PPB_FileChooser_Dev_0_5) PROXIED_IFACE(NoAPIName, PPB_FILECHOOSER_DEV_INTERFACE_0_6, diff --git a/ppapi/thunk/ppb_ext_socket_thunk.cc b/ppapi/thunk/ppb_ext_socket_thunk.cc index 095f697..e0afd66 100644 --- a/ppapi/thunk/ppb_ext_socket_thunk.cc +++ b/ppapi/thunk/ppb_ext_socket_thunk.cc @@ -275,6 +275,96 @@ int32_t GetNetworkList(PP_Instance instance, "socket.getNetworkList", input_args, output_args, enter.callback())); } +int32_t JoinGroup(PP_Instance instance, + PP_Var socket_id, + PP_Var address, + PP_Var* result, + PP_CompletionCallback callback) { + EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); + if (enter.failed()) + return enter.retval(); + + std::vector<PP_Var> input_args; + std::vector<PP_Var*> output_args; + input_args.push_back(socket_id); + input_args.push_back(address); + output_args.push_back(result); + return enter.SetResult(enter.functions()->CallBrowser( + "socket.joinGroup", input_args, output_args, enter.callback())); +} + +int32_t LeaveGroup(PP_Instance instance, + PP_Var socket_id, + PP_Var address, + PP_Var* result, + PP_CompletionCallback callback) { + EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); + if (enter.failed()) + return enter.retval(); + + std::vector<PP_Var> input_args; + std::vector<PP_Var*> output_args; + input_args.push_back(socket_id); + input_args.push_back(address); + output_args.push_back(result); + return enter.SetResult(enter.functions()->CallBrowser( + "socket.leaveGroup", input_args, output_args, enter.callback())); +} + +int32_t SetMulticastTimeToLive(PP_Instance instance, + PP_Var socket_id, + PP_Var ttl, + PP_Var* result, + PP_CompletionCallback callback) { + EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); + if (enter.failed()) + return enter.retval(); + + std::vector<PP_Var> input_args; + std::vector<PP_Var*> output_args; + input_args.push_back(socket_id); + input_args.push_back(ttl); + output_args.push_back(result); + return enter.SetResult(enter.functions()->CallBrowser( + "socket.setMulticastTimeToLive", input_args, output_args, + enter.callback())); +} + +int32_t SetMulticastLoopbackMode(PP_Instance instance, + PP_Var socket_id, + PP_Var enabled, + PP_Var* result, + PP_CompletionCallback callback) { + EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); + if (enter.failed()) + return enter.retval(); + + std::vector<PP_Var> input_args; + std::vector<PP_Var*> output_args; + input_args.push_back(socket_id); + input_args.push_back(enabled); + output_args.push_back(result); + return enter.SetResult(enter.functions()->CallBrowser( + "socket.setMulticastLoopbackMode", input_args, output_args, + enter.callback())); +} + +int32_t GetJoinedGroups(PP_Instance instance, + PP_Var socket_id, + PP_Var* groups, + PP_CompletionCallback callback) { + EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); + if (enter.failed()) + return enter.retval(); + + std::vector<PP_Var> input_args; + std::vector<PP_Var*> output_args; + input_args.push_back(socket_id); + output_args.push_back(groups); + return enter.SetResult(enter.functions()->CallBrowser( + "socket.getJoinedGroups", input_args, output_args, enter.callback())); +} + const PPB_Ext_Socket_Dev_0_1 g_ppb_ext_socket_dev_0_1_thunk = { &Create, &Destroy, @@ -293,11 +383,37 @@ const PPB_Ext_Socket_Dev_0_1 g_ppb_ext_socket_dev_0_1_thunk = { &GetNetworkList }; +const PPB_Ext_Socket_Dev_0_2 g_ppb_ext_socket_dev_0_2_thunk = { + &Create, + &Destroy, + &Connect, + &Bind, + &Disconnect, + &Read, + &Write, + &RecvFrom, + &SendTo, + &Listen, + &Accept, + &SetKeepAlive, + &SetNoDelay, + &GetInfo, + &GetNetworkList, + &JoinGroup, + &LeaveGroup, + &SetMulticastTimeToLive, + &SetMulticastLoopbackMode, + &GetJoinedGroups +}; } // namespace const PPB_Ext_Socket_Dev_0_1* GetPPB_Ext_Socket_Dev_0_1_Thunk() { return &g_ppb_ext_socket_dev_0_1_thunk; } +const PPB_Ext_Socket_Dev_0_2* GetPPB_Ext_Socket_Dev_0_2_Thunk() { + return &g_ppb_ext_socket_dev_0_2_thunk; +} + } // namespace thunk } // namespace ppapi |