summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-08 21:17:07 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-08 21:17:07 +0000
commitb5e916abb514bdb1a37c616da15aa2e8f725af7c (patch)
tree258f490eae56d7fc590b613b84fa1f6c7fd8bd51
parent82ce8a41cfb0bff9902bce4aa3adc726c1f0a2cf (diff)
downloadchromium_src-b5e916abb514bdb1a37c616da15aa2e8f725af7c.zip
chromium_src-b5e916abb514bdb1a37c616da15aa2e8f725af7c.tar.gz
chromium_src-b5e916abb514bdb1a37c616da15aa2e8f725af7c.tar.bz2
Apps v2 in Pepper: Add C/C++ definition for chrome.socket.
BUG=226303 TEST=None Review URL: https://chromiumcodereview.appspot.com/13490003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192897 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ppapi/PRESUBMIT.py2
-rw-r--r--ppapi/api/extensions/dev/ppb_ext_socket_dev.idl417
-rw-r--r--ppapi/c/extensions/dev/ppb_ext_socket_dev.h420
-rw-r--r--ppapi/cpp/extensions/dev/socket_dev.cc479
-rw-r--r--ppapi/cpp/extensions/dev/socket_dev.h243
-rw-r--r--ppapi/cpp/extensions/from_var_converter.h98
-rw-r--r--ppapi/cpp/extensions/to_var_converter.h67
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c121
-rw-r--r--ppapi/ppapi_sources.gypi3
-rw-r--r--ppapi/tests/all_c_includes.h1
-rw-r--r--ppapi/tests/all_cpp_includes.h1
11 files changed, 1848 insertions, 4 deletions
diff --git a/ppapi/PRESUBMIT.py b/ppapi/PRESUBMIT.py
index 1a95003..72672e9 100644
--- a/ppapi/PRESUBMIT.py
+++ b/ppapi/PRESUBMIT.py
@@ -65,6 +65,8 @@ def CheckTODO(input_api, output_api):
# Only examine public stable interfaces.
if name_parts[2] in ['dev', 'private', 'trusted']:
continue
+ if name_parts[2] == 'extensions' and name_parts[3] == 'dev':
+ continue
filepath = os.path.join('..', filename)
if RE_TODO.search(open(filepath, 'rb').read()):
diff --git a/ppapi/api/extensions/dev/ppb_ext_socket_dev.idl b/ppapi/api/extensions/dev/ppb_ext_socket_dev.idl
new file mode 100644
index 0000000..10051d7
--- /dev/null
+++ b/ppapi/api/extensions/dev/ppb_ext_socket_dev.idl
@@ -0,0 +1,417 @@
+/* Copyright (c) 2013 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * This file defines the Pepper equivalent of the <code>chrome.socket</code>
+ * extension API.
+ */
+
+label Chrome {
+ M28 = 0.1
+};
+
+/**
+ * A string <code>PP_Var</code> which has one of the following values:
+ * - "tcp"
+ * - "udp"
+ */
+typedef PP_Var PP_Ext_Socket_SocketType_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code>.
+ */
+typedef PP_Var PP_Ext_Socket_CreateOptions_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code> which contains
+ * - "socketId" : integer <code>PP_Var</code>
+ * The id of the newly created socket.
+ */
+typedef PP_Var PP_Ext_Socket_CreateInfo_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code> which contains
+ * - "resultCode" : integer <code>PP_Var</code>
+ * - "socketId" : integer or undefined <code>PP_Var</code>
+ * The id of the accepted socket.
+ */
+typedef PP_Var PP_Ext_Socket_AcceptInfo_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code> which contains
+ * - "resultCode" : integer <code>PP_Var</code>
+ * The resultCode returned from the underlying read() call.
+ * - "data" : array buffer <code>PP_Var</code>
+ */
+typedef PP_Var PP_Ext_Socket_ReadInfo_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code> which contains
+ * - "bytesWritten" : integer <code>PP_Var</code>
+ * The number of bytes sent, or a negative error code.
+ */
+typedef PP_Var PP_Ext_Socket_WriteInfo_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code> which contains
+ * - "resultCode" : integer <code>PP_Var</code>
+ * The resultCode returned from the underlying recvfrom() call.
+ * - "data": array buffer <code>PP_Var</code>
+ * - "address": string <code>PP_Var</code>
+ * The address of the remote machine.
+ * - "port": integer <code>PP_Var</code>
+ */
+typedef PP_Var PP_Ext_Socket_RecvFromInfo_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code> which contains
+ * - "socketType" : string <code>PP_Var</code> which matches the description of
+ * <code>PP_Ext_Socket_SocketType_Dev</code>
+ * The type of the passed socket. This will be <code>tcp</code> or
+ * <code>udp</code>.
+ * - "connected" : boolean <code>PP_Var</code>
+ * Whether or not the underlying socket is connected.
+ *
+ * For <code>tcp</code> sockets, this will remain true even if the remote peer
+ * has disconnected. Reading or writing to the socket may then result in an
+ * error, hinting that this socket should be disconnected via
+ * <code>Disconnect()</code>.
+ *
+ * For <code>udp</code> sockets, this just represents whether a default remote
+ * address has been specified for reading and writing packets.
+ * - "peerAddress" : string or undefined <code>PP_Var</code>
+ * If the underlying socket is connected, contains the IPv4/6 address of the
+ * peer.
+ * - "peerPort" : integer or undefined <code>PP_Var</code>
+ * If the underlying socket is connected, contains the port of the connected
+ * peer.
+ * - "localAddress" : string or undefined <code>PP_Var</code>
+ * If the underlying socket is bound or connected, contains its local IPv4/6
+ * address.
+ * - "localPort" : integer or undefined <code>PP_Var</code>
+ * If the underlying socket is bound or connected, contains its local port.
+ */
+typedef PP_Var PP_Ext_Socket_SocketInfo_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code> which contains
+ * - "name" : string <code>PP_Var</code>
+ * The underlying name of the adapter. On *nix, this will typically be "eth0",
+ * "lo", etc.
+ * - "address": string <code>PP_Var</code>
+ * The available IPv4/6 address.
+ */
+typedef PP_Var PP_Ext_Socket_NetworkInterface_Dev;
+
+/**
+ * An array <code>PP_Var</code> which contains elements of
+ * <code>PP_Ext_Socket_NetworkInterface_Dev</code>.
+ */
+typedef PP_Var PP_Ext_Socket_NetworkInterface_Dev_Array;
+
+interface PPB_Ext_Socket_Dev {
+ /**
+ * Creates a socket of the specified type that will connect to the specified
+ * remote machine.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] type A <code>PP_Ext_Socket_SocketType_Dev</code>. The type of
+ * socket to create. Must be <code>tcp</code> or <code>udp</code>.
+ * @param[in] options An undefined <code>PP_Var</code> or
+ * <code>PP_Ext_Socket_CreateOptions_Dev</code>. The socket options.
+ * @param[out] create_info A <code>PP_Ext_Socket_CreateInfo_Dev</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 Create(
+ [in] PP_Instance instance,
+ [in] PP_Ext_Socket_SocketType_Dev type,
+ [in] PP_Ext_Socket_CreateOptions_Dev options,
+ [out] PP_Ext_Socket_CreateInfo_Dev create_info,
+ [in] PP_CompletionCallback callback);
+
+ /**
+ * Destroys the socket. Each socket created should be destroyed after use.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ */
+ void Destroy(
+ [in] PP_Instance instance,
+ [in] PP_Var socket_id);
+
+ /**
+ * Connects the socket to the remote machine (for a <code>tcp</code> socket).
+ * For a <code>udp</code> socket, this sets the default address which packets
+ * are sent to and read from for <code>Read()</code> and <code>Write()</code>
+ * calls.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[in] hostname A string <code>PP_Var</code>. The hostname or IP
+ * address of the remote machine.
+ * @param[in] port An integer <code>PP_Var</code>. The port of the remote
+ * machine.
+ * @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 Connect(
+ [in] PP_Instance instance,
+ [in] PP_Var socket_id,
+ [in] PP_Var hostname,
+ [in] PP_Var port,
+ [out] PP_Var result,
+ [in] PP_CompletionCallback callback);
+
+ /**
+ * Binds the local address for socket. Currently, it does not support TCP
+ * socket.
+ *
+ * @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 address of the local
+ * machine.
+ * @param[in] port An integer <code>PP_Var</code>. The port of the local
+ * machine.
+ * @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 Bind(
+ [in] PP_Instance instance,
+ [in] PP_Var socket_id,
+ [in] PP_Var address,
+ [in] PP_Var port,
+ [out] PP_Var result,
+ [in] PP_CompletionCallback callback);
+
+ /**
+ * Disconnects the socket. For UDP sockets, <code>Disconnect</code> is a
+ * non-operation but is safe to call.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ */
+ void Disconnect(
+ [in] PP_Instance instance,
+ [in] PP_Var socket_id);
+
+ /**
+ * Reads data from the given connected socket.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[in] buffer_size An undefined or integer <code>PP_Var</code>. The
+ * read buffer size.
+ * @param[out] read_info A <code>PP_Ext_Socket_ReadInfo_Dev</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 Read(
+ [in] PP_Instance instance,
+ [in] PP_Var socket_id,
+ [in] PP_Var buffer_size,
+ [out] PP_Ext_Socket_ReadInfo_Dev read_info,
+ [in] PP_CompletionCallback callback);
+
+ /**
+ * Writes data on the given connected socket.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[in] data An array buffer <code>PP_Var</code>. The data to write.
+ * @param[out] write_info A <code>PP_Ext_Socket_WriteInfo_Dev</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 Write(
+ [in] PP_Instance instance,
+ [in] PP_Var socket_id,
+ [in] PP_Var data,
+ [out] PP_Ext_Socket_WriteInfo_Dev write_info,
+ [in] PP_CompletionCallback callback);
+
+ /**
+ * Receives data from the given UDP socket.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[in] buffer_size An undefined or integer <code>PP_Var</code>. The
+ * receive buffer size.
+ * @param[out] recv_from_info A <code>PP_Ext_Socket_RecvFromInfo_Dev</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 RecvFrom(
+ [in] PP_Instance instance,
+ [in] PP_Var socket_id,
+ [in] PP_Var buffer_size,
+ [out] PP_Ext_Socket_RecvFromInfo_Dev recv_from_info,
+ [in] PP_CompletionCallback callback);
+
+ /**
+ * Sends data on the given UDP socket to the given address and port.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[in] data An array buffer <code>PP_Var</code>.
+ * @param[in] address A string <code>PP_Var</code>. The address of the remote
+ * machine.
+ * @param[in] port An integer <code>PP_Var</code>. The port of the remote
+ * machine.
+ * @param[out] write_info A <code>PP_Ext_Socket_WriteInfo_Dev</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 SendTo(
+ [in] PP_Instance instance,
+ [in] PP_Var socket_id,
+ [in] PP_Var data,
+ [in] PP_Var address,
+ [in] PP_Var port,
+ [out] PP_Ext_Socket_WriteInfo_Dev write_info,
+ [in] PP_CompletionCallback callback);
+
+ /**
+ * This method applies to TCP sockets only.
+ * Listens for connections on the specified port and address. This effectively
+ * makes this a server socket, and client socket functions (Connect, Read,
+ * Write) can no longer be used on this socket.
+ *
+ * @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 address of the local
+ * machine.
+ * @param[in] port An integer <code>PP_Var</code>. The port of the local
+ * machine.
+ * @param[in] backlog An undefined or integer <code>PP_Var</code>. Length of
+ * the socket's listen queue.
+ * @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 Listen(
+ [in] PP_Instance instance,
+ [in] PP_Var socket_id,
+ [in] PP_Var address,
+ [in] PP_Var port,
+ [in] PP_Var backlog,
+ [out] PP_Var result,
+ [in] PP_CompletionCallback callback);
+
+ /**
+ * This method applies to TCP sockets only.
+ * Registers a callback function to be called when a connection is accepted on
+ * this listening server socket. Listen must be called first.
+ * If there is already an active accept callback, this callback will be
+ * invoked immediately with an error as the resultCode.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[out] accept_info A <code>PP_Ext_Socket_AcceptInfo_Dev</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 Accept(
+ [in] PP_Instance instance,
+ [in] PP_Var socket_id,
+ [out] PP_Ext_Socket_AcceptInfo_Dev accept_info,
+ [in] PP_CompletionCallback callback);
+
+ /**
+ * Enables or disables the keep-alive functionality for a TCP connection.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[in] enable A boolean <code>PP_Var</code>. If true, enable keep-alive
+ * functionality.
+ * @param[in] delay An undefined or integer <code>PP_Var</code>. Set the delay
+ * seconds between the last data packet received and the first keepalive
+ * probe. Default is 0.
+ * @param[out] result A boolean <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 SetKeepAlive(
+ [in] PP_Instance instance,
+ [in] PP_Var socket_id,
+ [in] PP_Var enable,
+ [in] PP_Var delay,
+ [out] PP_Var result,
+ [in] PP_CompletionCallback callback);
+
+ /**
+ * Sets or clears <code>TCP_NODELAY</code> for a TCP connection. Nagle's
+ * algorithm will be disabled when <code>TCP_NODELAY</code> is set.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[in] no_delay A boolean <code>PP_Var</code>.
+ * @param[out] result A boolean <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 SetNoDelay(
+ [in] PP_Instance instance,
+ [in] PP_Var socket_id,
+ [in] PP_Var no_delay,
+ [out] PP_Var result,
+ [in] PP_CompletionCallback callback);
+
+ /**
+ * Retrieves the state of the given socket.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[out] result A <code>PP_Ext_Socket_SocketInfo_Dev</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 GetInfo(
+ [in] PP_Instance instance,
+ [in] PP_Var socket_id,
+ [out] PP_Ext_Socket_SocketInfo_Dev result,
+ [in] PP_CompletionCallback callback);
+
+ /**
+ * Retrieves information about local adapters on this system.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[out] result A <code>PP_Ext_Socket_NetworkInterface_Dev_Array</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 GetNetworkList(
+ [in] PP_Instance instance,
+ [out] PP_Ext_Socket_NetworkInterface_Dev_Array result,
+ [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
new file mode 100644
index 0000000..b24e129
--- /dev/null
+++ b/ppapi/c/extensions/dev/ppb_ext_socket_dev.h
@@ -0,0 +1,420 @@
+/* Copyright (c) 2013 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* From extensions/dev/ppb_ext_socket_dev.idl,
+ * modified Tue Apr 02 16:04:00 2013.
+ */
+
+#ifndef PPAPI_C_EXTENSIONS_DEV_PPB_EXT_SOCKET_DEV_H_
+#define PPAPI_C_EXTENSIONS_DEV_PPB_EXT_SOCKET_DEV_H_
+
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_macros.h"
+#include "ppapi/c/pp_stdint.h"
+#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
+
+/**
+ * @file
+ * This file defines the Pepper equivalent of the <code>chrome.socket</code>
+ * extension API.
+ */
+
+
+/**
+ * @addtogroup Typedefs
+ * @{
+ */
+/**
+ * A string <code>PP_Var</code> which has one of the following values:
+ * - "tcp"
+ * - "udp"
+ */
+typedef struct PP_Var PP_Ext_Socket_SocketType_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code>.
+ */
+typedef struct PP_Var PP_Ext_Socket_CreateOptions_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code> which contains
+ * - "socketId" : integer <code>PP_Var</code>
+ * The id of the newly created socket.
+ */
+typedef struct PP_Var PP_Ext_Socket_CreateInfo_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code> which contains
+ * - "resultCode" : integer <code>PP_Var</code>
+ * - "socketId" : integer or undefined <code>PP_Var</code>
+ * The id of the accepted socket.
+ */
+typedef struct PP_Var PP_Ext_Socket_AcceptInfo_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code> which contains
+ * - "resultCode" : integer <code>PP_Var</code>
+ * The resultCode returned from the underlying read() call.
+ * - "data" : array buffer <code>PP_Var</code>
+ */
+typedef struct PP_Var PP_Ext_Socket_ReadInfo_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code> which contains
+ * - "bytesWritten" : integer <code>PP_Var</code>
+ * The number of bytes sent, or a negative error code.
+ */
+typedef struct PP_Var PP_Ext_Socket_WriteInfo_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code> which contains
+ * - "resultCode" : integer <code>PP_Var</code>
+ * The resultCode returned from the underlying recvfrom() call.
+ * - "data": array buffer <code>PP_Var</code>
+ * - "address": string <code>PP_Var</code>
+ * The address of the remote machine.
+ * - "port": integer <code>PP_Var</code>
+ */
+typedef struct PP_Var PP_Ext_Socket_RecvFromInfo_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code> which contains
+ * - "socketType" : string <code>PP_Var</code> which matches the description of
+ * <code>PP_Ext_Socket_SocketType_Dev</code>
+ * The type of the passed socket. This will be <code>tcp</code> or
+ * <code>udp</code>.
+ * - "connected" : boolean <code>PP_Var</code>
+ * Whether or not the underlying socket is connected.
+ *
+ * For <code>tcp</code> sockets, this will remain true even if the remote peer
+ * has disconnected. Reading or writing to the socket may then result in an
+ * error, hinting that this socket should be disconnected via
+ * <code>Disconnect()</code>.
+ *
+ * For <code>udp</code> sockets, this just represents whether a default remote
+ * address has been specified for reading and writing packets.
+ * - "peerAddress" : string or undefined <code>PP_Var</code>
+ * If the underlying socket is connected, contains the IPv4/6 address of the
+ * peer.
+ * - "peerPort" : integer or undefined <code>PP_Var</code>
+ * If the underlying socket is connected, contains the port of the connected
+ * peer.
+ * - "localAddress" : string or undefined <code>PP_Var</code>
+ * If the underlying socket is bound or connected, contains its local IPv4/6
+ * address.
+ * - "localPort" : integer or undefined <code>PP_Var</code>
+ * If the underlying socket is bound or connected, contains its local port.
+ */
+typedef struct PP_Var PP_Ext_Socket_SocketInfo_Dev;
+
+/**
+ * A dictionary <code>PP_Var</code> which contains
+ * - "name" : string <code>PP_Var</code>
+ * The underlying name of the adapter. On *nix, this will typically be "eth0",
+ * "lo", etc.
+ * - "address": string <code>PP_Var</code>
+ * The available IPv4/6 address.
+ */
+typedef struct PP_Var PP_Ext_Socket_NetworkInterface_Dev;
+
+/**
+ * An array <code>PP_Var</code> which contains elements of
+ * <code>PP_Ext_Socket_NetworkInterface_Dev</code>.
+ */
+typedef struct PP_Var PP_Ext_Socket_NetworkInterface_Dev_Array;
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup Interfaces
+ * @{
+ */
+struct PPB_Ext_Socket_Dev_0_1 {
+ /**
+ * Creates a socket of the specified type that will connect to the specified
+ * remote machine.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] type A <code>PP_Ext_Socket_SocketType_Dev</code>. The type of
+ * socket to create. Must be <code>tcp</code> or <code>udp</code>.
+ * @param[in] options An undefined <code>PP_Var</code> or
+ * <code>PP_Ext_Socket_CreateOptions_Dev</code>. The socket options.
+ * @param[out] create_info A <code>PP_Ext_Socket_CreateInfo_Dev</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 (*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);
+ /**
+ * Destroys the socket. Each socket created should be destroyed after use.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ */
+ void (*Destroy)(PP_Instance instance, struct PP_Var socket_id);
+ /**
+ * Connects the socket to the remote machine (for a <code>tcp</code> socket).
+ * For a <code>udp</code> socket, this sets the default address which packets
+ * are sent to and read from for <code>Read()</code> and <code>Write()</code>
+ * calls.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[in] hostname A string <code>PP_Var</code>. The hostname or IP
+ * address of the remote machine.
+ * @param[in] port An integer <code>PP_Var</code>. The port of the remote
+ * machine.
+ * @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 (*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);
+ /**
+ * Binds the local address for socket. Currently, it does not support TCP
+ * socket.
+ *
+ * @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 address of the local
+ * machine.
+ * @param[in] port An integer <code>PP_Var</code>. The port of the local
+ * machine.
+ * @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 (*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);
+ /**
+ * Disconnects the socket. For UDP sockets, <code>Disconnect</code> is a
+ * non-operation but is safe to call.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ */
+ void (*Disconnect)(PP_Instance instance, struct PP_Var socket_id);
+ /**
+ * Reads data from the given connected socket.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[in] buffer_size An undefined or integer <code>PP_Var</code>. The
+ * read buffer size.
+ * @param[out] read_info A <code>PP_Ext_Socket_ReadInfo_Dev</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 (*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);
+ /**
+ * Writes data on the given connected socket.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[in] data An array buffer <code>PP_Var</code>. The data to write.
+ * @param[out] write_info A <code>PP_Ext_Socket_WriteInfo_Dev</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 (*Write)(PP_Instance instance,
+ struct PP_Var socket_id,
+ struct PP_Var data,
+ PP_Ext_Socket_WriteInfo_Dev* write_info,
+ struct PP_CompletionCallback callback);
+ /**
+ * Receives data from the given UDP socket.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[in] buffer_size An undefined or integer <code>PP_Var</code>. The
+ * receive buffer size.
+ * @param[out] recv_from_info A <code>PP_Ext_Socket_RecvFromInfo_Dev</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 (*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);
+ /**
+ * Sends data on the given UDP socket to the given address and port.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[in] data An array buffer <code>PP_Var</code>.
+ * @param[in] address A string <code>PP_Var</code>. The address of the remote
+ * machine.
+ * @param[in] port An integer <code>PP_Var</code>. The port of the remote
+ * machine.
+ * @param[out] write_info A <code>PP_Ext_Socket_WriteInfo_Dev</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 (*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);
+ /**
+ * This method applies to TCP sockets only.
+ * Listens for connections on the specified port and address. This effectively
+ * makes this a server socket, and client socket functions (Connect, Read,
+ * Write) can no longer be used on this socket.
+ *
+ * @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 address of the local
+ * machine.
+ * @param[in] port An integer <code>PP_Var</code>. The port of the local
+ * machine.
+ * @param[in] backlog An undefined or integer <code>PP_Var</code>. Length of
+ * the socket's listen queue.
+ * @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 (*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);
+ /**
+ * This method applies to TCP sockets only.
+ * Registers a callback function to be called when a connection is accepted on
+ * this listening server socket. Listen must be called first.
+ * If there is already an active accept callback, this callback will be
+ * invoked immediately with an error as the resultCode.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[out] accept_info A <code>PP_Ext_Socket_AcceptInfo_Dev</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 (*Accept)(PP_Instance instance,
+ struct PP_Var socket_id,
+ PP_Ext_Socket_AcceptInfo_Dev* accept_info,
+ struct PP_CompletionCallback callback);
+ /**
+ * Enables or disables the keep-alive functionality for a TCP connection.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[in] enable A boolean <code>PP_Var</code>. If true, enable keep-alive
+ * functionality.
+ * @param[in] delay An undefined or integer <code>PP_Var</code>. Set the delay
+ * seconds between the last data packet received and the first keepalive
+ * probe. Default is 0.
+ * @param[out] result A boolean <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 (*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);
+ /**
+ * Sets or clears <code>TCP_NODELAY</code> for a TCP connection. Nagle's
+ * algorithm will be disabled when <code>TCP_NODELAY</code> is set.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[in] no_delay A boolean <code>PP_Var</code>.
+ * @param[out] result A boolean <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 (*SetNoDelay)(PP_Instance instance,
+ struct PP_Var socket_id,
+ struct PP_Var no_delay,
+ struct PP_Var* result,
+ struct PP_CompletionCallback callback);
+ /**
+ * Retrieves the state of the given socket.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
+ * @param[out] result A <code>PP_Ext_Socket_SocketInfo_Dev</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 (*GetInfo)(PP_Instance instance,
+ struct PP_Var socket_id,
+ PP_Ext_Socket_SocketInfo_Dev* result,
+ struct PP_CompletionCallback callback);
+ /**
+ * Retrieves information about local adapters on this system.
+ *
+ * @param[in] instance A <code>PP_Instance</code>.
+ * @param[out] result A <code>PP_Ext_Socket_NetworkInterface_Dev_Array</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 (*GetNetworkList)(PP_Instance instance,
+ PP_Ext_Socket_NetworkInterface_Dev_Array* result,
+ struct PP_CompletionCallback callback);
+};
+
+typedef struct PPB_Ext_Socket_Dev_0_1 PPB_Ext_Socket_Dev;
+/**
+ * @}
+ */
+
+#endif /* PPAPI_C_EXTENSIONS_DEV_PPB_EXT_SOCKET_DEV_H_ */
+
diff --git a/ppapi/cpp/extensions/dev/socket_dev.cc b/ppapi/cpp/extensions/dev/socket_dev.cc
new file mode 100644
index 0000000..a2e8830
--- /dev/null
+++ b/ppapi/cpp/extensions/dev/socket_dev.cc
@@ -0,0 +1,479 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/extensions/dev/socket_dev.h"
+
+#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/extensions/optional.h"
+#include "ppapi/cpp/extensions/to_var_converter.h"
+#include "ppapi/cpp/logging.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_Ext_Socket_Dev_0_1>() {
+ return PPB_EXT_SOCKET_DEV_INTERFACE_0_1;
+}
+
+} // namespace
+
+namespace ext {
+namespace socket {
+
+const char* const SocketType_Dev::kTcp = "tcp";
+const char* const SocketType_Dev::kUdp = "udp";
+
+SocketType_Dev::SocketType_Dev() : value(NONE) {
+}
+
+SocketType_Dev::SocketType_Dev(ValueType in_value) : value(in_value) {
+}
+
+SocketType_Dev::~SocketType_Dev() {
+}
+
+bool SocketType_Dev::Populate(const PP_Var& var_value) {
+ if (var_value.type != PP_VARTYPE_STRING)
+ return false;
+
+ std::string string_value = Var(var_value).AsString();
+ if (string_value == kTcp) {
+ value = TCP;
+ } else if (string_value == kUdp) {
+ value = UDP;
+ } else {
+ value = NONE;
+ return false;
+ }
+ return true;
+}
+
+Var SocketType_Dev::CreateVar() const {
+ switch (value) {
+ case TCP:
+ return Var(kTcp);
+ case UDP:
+ return Var(kUdp);
+ default:
+ PP_NOTREACHED();
+ return Var(std::string());
+ }
+}
+
+const char* const CreateInfo_Dev::kSocketId = "socketId";
+
+CreateInfo_Dev::CreateInfo_Dev()
+ : socket_id(kSocketId) {
+}
+
+CreateInfo_Dev::~CreateInfo_Dev() {
+}
+
+bool CreateInfo_Dev::Populate(const PP_Ext_Socket_CreateInfo_Dev& value) {
+ if (value.type != PP_VARTYPE_DICTIONARY)
+ return false;
+
+ VarDictionary_Dev dict(value);
+ bool result = socket_id.Populate(dict);
+
+ return result;
+}
+
+Var CreateInfo_Dev::CreateVar() const {
+ VarDictionary_Dev dict;
+
+ bool result = socket_id.AddTo(&dict);
+ // Suppress unused variable warnings.
+ static_cast<void>(result);
+ PP_DCHECK(result);
+
+ return dict;
+}
+
+const char* const AcceptInfo_Dev::kResultCode = "resultCode";
+const char* const AcceptInfo_Dev::kSocketId = "socketId";
+
+AcceptInfo_Dev::AcceptInfo_Dev()
+ : result_code(kResultCode),
+ socket_id(kSocketId) {
+}
+
+AcceptInfo_Dev::~AcceptInfo_Dev() {
+}
+
+bool AcceptInfo_Dev::Populate(const PP_Ext_Socket_AcceptInfo_Dev& value) {
+ if (value.type != PP_VARTYPE_DICTIONARY)
+ return false;
+
+ VarDictionary_Dev dict(value);
+ bool result = result_code.Populate(dict);
+ result = socket_id.Populate(dict) && result;
+
+ return result;
+}
+
+Var AcceptInfo_Dev::CreateVar() const {
+ VarDictionary_Dev dict;
+
+ bool result = result_code.AddTo(&dict);
+ result = socket_id.MayAddTo(&dict) && result;
+ PP_DCHECK(result);
+
+ return dict;
+}
+
+const char* const ReadInfo_Dev::kResultCode = "resultCode";
+const char* const ReadInfo_Dev::kData = "data";
+
+ReadInfo_Dev::ReadInfo_Dev()
+ : result_code(kResultCode),
+ data(kData) {
+}
+
+ReadInfo_Dev::~ReadInfo_Dev() {
+}
+
+bool ReadInfo_Dev::Populate(const PP_Ext_Socket_ReadInfo_Dev& value) {
+ if (value.type != PP_VARTYPE_DICTIONARY)
+ return false;
+
+ VarDictionary_Dev dict(value);
+ bool result = result_code.Populate(dict);
+ result = data.Populate(dict) && result;
+
+ return result;
+}
+
+Var ReadInfo_Dev::CreateVar() const {
+ VarDictionary_Dev dict;
+
+ bool result = result_code.AddTo(&dict);
+ result = data.AddTo(&dict) && result;
+ PP_DCHECK(result);
+
+ return dict;
+}
+
+const char* const WriteInfo_Dev::kBytesWritten = "bytesWritten";
+
+WriteInfo_Dev::WriteInfo_Dev()
+ : bytes_written(kBytesWritten) {
+}
+
+WriteInfo_Dev::~WriteInfo_Dev() {
+}
+
+bool WriteInfo_Dev::Populate(const PP_Ext_Socket_WriteInfo_Dev& value) {
+ if (value.type != PP_VARTYPE_DICTIONARY)
+ return false;
+
+ VarDictionary_Dev dict(value);
+ bool result = bytes_written.Populate(dict);
+
+ return result;
+}
+
+Var WriteInfo_Dev::CreateVar() const {
+ VarDictionary_Dev dict;
+
+ bool result = bytes_written.AddTo(&dict);
+ // Suppress unused variable warnings.
+ static_cast<void>(result);
+ PP_DCHECK(result);
+
+ return dict;
+}
+
+const char* const RecvFromInfo_Dev::kResultCode = "resultCode";
+const char* const RecvFromInfo_Dev::kData = "data";
+const char* const RecvFromInfo_Dev::kAddress = "address";
+const char* const RecvFromInfo_Dev::kPort = "port";
+
+RecvFromInfo_Dev::RecvFromInfo_Dev()
+ : result_code(kResultCode),
+ data(kData),
+ address(kAddress),
+ port(kPort) {
+}
+
+RecvFromInfo_Dev::~RecvFromInfo_Dev() {
+}
+
+bool RecvFromInfo_Dev::Populate(const PP_Ext_Socket_RecvFromInfo_Dev& value) {
+ if (value.type != PP_VARTYPE_DICTIONARY)
+ return false;
+
+ VarDictionary_Dev dict(value);
+ bool result = result_code.Populate(dict);
+ result = data.Populate(dict) && result;
+ result = address.Populate(dict) && result;
+ result = port.Populate(dict) && result;
+
+ return result;
+}
+
+Var RecvFromInfo_Dev::CreateVar() const {
+ VarDictionary_Dev dict;
+
+ bool result = result_code.AddTo(&dict);
+ result = data.AddTo(&dict) && result;
+ result = address.AddTo(&dict) && result;
+ result = port.AddTo(&dict) && result;
+ PP_DCHECK(result);
+
+ return dict;
+}
+
+const char* const SocketInfo_Dev::kSocketType = "socketType";
+const char* const SocketInfo_Dev::kConnected = "connected";
+const char* const SocketInfo_Dev::kPeerAddress = "peerAddress";
+const char* const SocketInfo_Dev::kPeerPort = "peerPort";
+const char* const SocketInfo_Dev::kLocalAddress = "localAddress";
+const char* const SocketInfo_Dev::kLocalPort = "localPort";
+
+SocketInfo_Dev::SocketInfo_Dev()
+ : socket_type(kSocketType),
+ connected(kConnected),
+ peer_address(kPeerAddress),
+ peer_port(kPeerPort),
+ local_address(kLocalAddress),
+ local_port(kLocalPort) {
+}
+
+SocketInfo_Dev::~SocketInfo_Dev() {
+}
+
+bool SocketInfo_Dev::Populate(const PP_Ext_Socket_SocketInfo_Dev& value) {
+ if (value.type != PP_VARTYPE_DICTIONARY)
+ return false;
+
+ VarDictionary_Dev dict(value);
+ bool result = socket_type.Populate(dict);
+ result = connected.Populate(dict) && result;
+ result = peer_address.Populate(dict) && result;
+ result = peer_port.Populate(dict) && result;
+ result = local_address.Populate(dict) && result;
+ result = local_port.Populate(dict) && result;
+
+ return result;
+}
+
+Var SocketInfo_Dev::CreateVar() const {
+ VarDictionary_Dev dict;
+
+ bool result = socket_type.AddTo(&dict);
+ result = connected.AddTo(&dict) && result;
+ result = peer_address.MayAddTo(&dict) && result;
+ result = peer_port.MayAddTo(&dict) && result;
+ result = local_address.MayAddTo(&dict) && result;
+ result = local_port.MayAddTo(&dict) && result;
+ PP_DCHECK(result);
+
+ return dict;
+}
+
+const char* const NetworkInterface_Dev::kName = "name";
+const char* const NetworkInterface_Dev::kAddress = "address";
+
+NetworkInterface_Dev::NetworkInterface_Dev()
+ : name(kName),
+ address(kAddress) {
+}
+
+NetworkInterface_Dev::~NetworkInterface_Dev() {
+}
+
+bool NetworkInterface_Dev::Populate(
+ const PP_Ext_Socket_NetworkInterface_Dev& value) {
+ if (value.type != PP_VARTYPE_DICTIONARY)
+ return false;
+
+ VarDictionary_Dev dict(value);
+ bool result = name.Populate(dict);
+ result = address.Populate(dict) && result;
+
+ return result;
+}
+
+Var NetworkInterface_Dev::CreateVar() const {
+ VarDictionary_Dev dict;
+
+ bool result = name.AddTo(&dict);
+ result = address.AddTo(&dict) && result;
+ PP_DCHECK(result);
+
+ return dict;
+}
+
+Socket_Dev::Socket_Dev(const InstanceHandle& instance) : instance_(instance) {
+}
+
+Socket_Dev::~Socket_Dev() {
+}
+
+int32_t Socket_Dev::Create(
+ const SocketType_Dev& type,
+ const Optional<CreateOptions_Dev>& options,
+ const CompletionCallbackWithOutput<CreateInfo_Dev>& callback) {
+ if (!has_interface<PPB_Ext_Socket_Dev_0_1>())
+ 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(
+ instance_.pp_instance(),
+ type_var.pp_var(),
+ options_var.pp_var(),
+ callback.output(),
+ callback.pp_completion_callback());
+}
+
+void Socket_Dev::Destroy(int32_t socket_id) {
+ if (!has_interface<PPB_Ext_Socket_Dev_0_1>())
+ return;
+
+ internal::ToVarConverter<int32_t> socket_id_var(socket_id);
+
+ return get_interface<PPB_Ext_Socket_Dev_0_1>()->Destroy(
+ instance_.pp_instance(),
+ socket_id_var.pp_var());
+}
+
+void Socket_Dev::Disconnect(int32_t socket_id) {
+ if (!has_interface<PPB_Ext_Socket_Dev_0_1>())
+ return;
+
+ internal::ToVarConverter<int32_t> socket_id_var(socket_id);
+
+ return get_interface<PPB_Ext_Socket_Dev_0_1>()->Disconnect(
+ instance_.pp_instance(),
+ socket_id_var.pp_var());
+}
+
+int32_t Socket_Dev::Read(
+ int32_t socket_id,
+ const Optional<int32_t>& buffer_size,
+ const CompletionCallbackWithOutput<ReadInfo_Dev>& callback) {
+ if (!has_interface<PPB_Ext_Socket_Dev_0_1>())
+ 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(
+ instance_.pp_instance(),
+ socket_id_var.pp_var(),
+ buffer_size_var.pp_var(),
+ callback.output(),
+ callback.pp_completion_callback());
+}
+
+int32_t Socket_Dev::Write(
+ int32_t socket_id,
+ const Var& data,
+ const CompletionCallbackWithOutput<WriteInfo_Dev>& callback) {
+ if (!has_interface<PPB_Ext_Socket_Dev_0_1>())
+ 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(
+ instance_.pp_instance(),
+ socket_id_var.pp_var(),
+ data_var.pp_var(),
+ callback.output(),
+ callback.pp_completion_callback());
+}
+
+int32_t Socket_Dev::RecvFrom(
+ int32_t socket_id,
+ const Optional<int32_t>& buffer_size,
+ const CompletionCallbackWithOutput<RecvFromInfo_Dev>& callback) {
+ if (!has_interface<PPB_Ext_Socket_Dev_0_1>())
+ 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(
+ instance_.pp_instance(),
+ socket_id_var.pp_var(),
+ buffer_size_var.pp_var(),
+ callback.output(),
+ callback.pp_completion_callback());
+}
+
+int32_t Socket_Dev::SendTo(
+ int32_t socket_id,
+ const Var& data,
+ const std::string& address,
+ int32_t port,
+ const CompletionCallbackWithOutput<WriteInfo_Dev>& callback) {
+ if (!has_interface<PPB_Ext_Socket_Dev_0_1>())
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
+
+ internal::ToVarConverter<int32_t> socket_id_var(socket_id);
+ internal::ToVarConverter<Var> data_var(data);
+ internal::ToVarConverter<std::string> address_var(address);
+ internal::ToVarConverter<int32_t> port_var(port);
+
+ return get_interface<PPB_Ext_Socket_Dev_0_1>()->SendTo(
+ instance_.pp_instance(),
+ socket_id_var.pp_var(),
+ data_var.pp_var(),
+ address_var.pp_var(),
+ port_var.pp_var(),
+ callback.output(),
+ callback.pp_completion_callback());
+}
+
+int32_t Socket_Dev::Accept(
+ int32_t socket_id,
+ const CompletionCallbackWithOutput<AcceptInfo_Dev>& callback) {
+ if (!has_interface<PPB_Ext_Socket_Dev_0_1>())
+ 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(
+ instance_.pp_instance(),
+ socket_id_var.pp_var(),
+ callback.output(),
+ callback.pp_completion_callback());
+}
+
+int32_t Socket_Dev::GetInfo(
+ int32_t socket_id,
+ const CompletionCallbackWithOutput<SocketInfo_Dev>& callback) {
+ if (!has_interface<PPB_Ext_Socket_Dev_0_1>())
+ 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(
+ instance_.pp_instance(),
+ socket_id_var.pp_var(),
+ callback.output(),
+ callback.pp_completion_callback());
+}
+
+int32_t Socket_Dev::GetNetworkList(
+ const CompletionCallbackWithOutput<std::vector<NetworkInterface_Dev> >&
+ callback) {
+ if (!has_interface<PPB_Ext_Socket_Dev_0_1>())
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
+
+ return get_interface<PPB_Ext_Socket_Dev_0_1>()->GetNetworkList(
+ instance_.pp_instance(),
+ 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
new file mode 100644
index 0000000..5d2e5be
--- /dev/null
+++ b/ppapi/cpp/extensions/dev/socket_dev.h
@@ -0,0 +1,243 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_EXTENSIONS_DEV_SOCKET_DEV_H_
+#define PPAPI_CPP_EXTENSIONS_DEV_SOCKET_DEV_H_
+
+#include <string>
+#include <vector>
+
+#include "ppapi/c/extensions/dev/ppb_ext_socket_dev.h"
+#include "ppapi/cpp/dev/var_dictionary_dev.h"
+#include "ppapi/cpp/extensions/dict_field.h"
+#include "ppapi/cpp/extensions/ext_output_traits.h"
+#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/cpp/var.h"
+#include "ppapi/cpp/var_array_buffer.h"
+
+namespace pp {
+
+template <class T>
+class CompletionCallbackWithOutput;
+
+namespace ext {
+
+template <class T>
+class Optional;
+
+namespace socket {
+
+// Data types ------------------------------------------------------------------
+class SocketType_Dev {
+ public:
+ enum ValueType {
+ NONE,
+ TCP,
+ UDP
+ };
+
+ SocketType_Dev();
+ SocketType_Dev(ValueType in_value);
+ ~SocketType_Dev();
+
+ bool Populate(const PP_Var& var_value);
+
+ Var CreateVar() const;
+
+ ValueType value;
+
+ static const char* const kTcp;
+ static const char* const kUdp;
+};
+
+typedef VarDictionary_Dev CreateOptions_Dev;
+
+class CreateInfo_Dev : public internal::OutputObjectBase {
+ public:
+ CreateInfo_Dev();
+ ~CreateInfo_Dev();
+
+ bool Populate(const PP_Ext_Socket_CreateInfo_Dev& value);
+
+ Var CreateVar() const;
+
+ static const char* const kSocketId;
+
+ DictField<int32_t> socket_id;
+};
+
+class AcceptInfo_Dev : public internal::OutputObjectBase {
+ public:
+ AcceptInfo_Dev();
+ ~AcceptInfo_Dev();
+
+ bool Populate(const PP_Ext_Socket_AcceptInfo_Dev& value);
+
+ Var CreateVar() const;
+
+ static const char* const kResultCode;
+ static const char* const kSocketId;
+
+ DictField<int32_t> result_code;
+ OptionalDictField<int32_t> socket_id;
+};
+
+class ReadInfo_Dev : public internal::OutputObjectBase {
+ public:
+ ReadInfo_Dev();
+ ~ReadInfo_Dev();
+
+ bool Populate(const PP_Ext_Socket_ReadInfo_Dev& value);
+
+ Var CreateVar() const;
+
+ static const char* const kResultCode;
+ static const char* const kData;
+
+ DictField<int32_t> result_code;
+ // TODO(yzshen): It is more natural to use VarArrayBuffer, but it doesn't have
+ // a default constructor currently.
+ DictField<Var> data;
+};
+
+class WriteInfo_Dev : public internal::OutputObjectBase {
+ public:
+ WriteInfo_Dev();
+ ~WriteInfo_Dev();
+
+ bool Populate(const PP_Ext_Socket_WriteInfo_Dev& value);
+
+ Var CreateVar() const;
+
+ static const char* const kBytesWritten;
+
+ DictField<int32_t> bytes_written;
+};
+
+class RecvFromInfo_Dev : public internal::OutputObjectBase {
+ public:
+ RecvFromInfo_Dev();
+ ~RecvFromInfo_Dev();
+
+ bool Populate(const PP_Ext_Socket_RecvFromInfo_Dev& value);
+
+ Var CreateVar() const;
+
+ static const char* const kResultCode;
+ static const char* const kData;
+ static const char* const kAddress;
+ static const char* const kPort;
+
+ DictField<int32_t> result_code;
+ DictField<Var> data;
+ DictField<std::string> address;
+ DictField<int32_t> port;
+};
+
+class SocketInfo_Dev : public internal::OutputObjectBase {
+ public:
+ SocketInfo_Dev();
+ ~SocketInfo_Dev();
+
+ bool Populate(const PP_Ext_Socket_SocketInfo_Dev& value);
+
+ Var CreateVar() const;
+
+ static const char* const kSocketType;
+ static const char* const kConnected;
+ static const char* const kPeerAddress;
+ static const char* const kPeerPort;
+ static const char* const kLocalAddress;
+ static const char* const kLocalPort;
+
+ DictField<SocketType_Dev> socket_type;
+ DictField<bool> connected;
+ OptionalDictField<std::string> peer_address;
+ OptionalDictField<int32_t> peer_port;
+ OptionalDictField<std::string> local_address;
+ OptionalDictField<int32_t> local_port;
+};
+
+class NetworkInterface_Dev : public internal::OutputObjectBase {
+ public:
+ NetworkInterface_Dev();
+ ~NetworkInterface_Dev();
+
+ bool Populate(const PP_Ext_Socket_NetworkInterface_Dev& value);
+
+ Var CreateVar() const;
+
+ static const char* const kName;
+ static const char* const kAddress;
+
+ DictField<std::string> name;
+ DictField<std::string> address;
+};
+
+// Functions -------------------------------------------------------------------
+class Socket_Dev {
+ public:
+ explicit Socket_Dev(const InstanceHandle& instance);
+ ~Socket_Dev();
+
+ int32_t Create(const SocketType_Dev& type,
+ const Optional<CreateOptions_Dev>& options,
+ const CompletionCallbackWithOutput<CreateInfo_Dev>& callback);
+ void Destroy(int32_t socket_id);
+ // TODO(yzshen): Support more powerful traits.
+ //int32_t Connect(int32_t socket_id,
+ // const std::string& hostname,
+ // int32_t port,
+ // const CompletionCallbackWithOutput<int32_t>& callback);
+ //int32_t Bind(int32_t socket_id,
+ // const std::string& address,
+ // int32_t port,
+ // const CompletionCallbackWithOutput<int32_t>& callback);
+ void Disconnect(int32_t socket_id);
+ int32_t Read(int32_t socket_id,
+ const Optional<int32_t>& buffer_size,
+ const CompletionCallbackWithOutput<ReadInfo_Dev>& callback);
+ int32_t Write(int32_t socket_id,
+ const Var& data,
+ const CompletionCallbackWithOutput<WriteInfo_Dev>& callback);
+ int32_t RecvFrom(
+ int32_t socket_id,
+ const Optional<int32_t>& buffer_size,
+ const CompletionCallbackWithOutput<RecvFromInfo_Dev>& callback);
+ int32_t SendTo(int32_t socket_id,
+ const Var& data,
+ const std::string& address,
+ int32_t port,
+ const CompletionCallbackWithOutput<WriteInfo_Dev>& callback);
+ // TODO(yzshen): Support more powerful traits.
+ //int32_t Listen(int32_t socket_id,
+ // const std::string& address,
+ // int32_t port,
+ // const Optional<int32_t>& backlog,
+ // const CompletionCallbackWithOutput<int32_t>& callback);
+ int32_t Accept(int32_t socket_id,
+ const CompletionCallbackWithOutput<AcceptInfo_Dev>& callback);
+ // TODO(yzshen): Support more powerful traits.
+ //int32_t SetKeepAlive(int32_t socket_id,
+ // bool enable,
+ // const Optional<int32_t>& delay,
+ // const CompletionCallbackWithOutput<bool>& callback);
+ //int32_t SetNoDelay(int32_t socket_id,
+ // bool no_delay,
+ // const CompletionCallbackWithOutput<bool>& callback);
+ int32_t GetInfo(int32_t socket_id,
+ const CompletionCallbackWithOutput<SocketInfo_Dev>& callback);
+ int32_t GetNetworkList(
+ const CompletionCallbackWithOutput<std::vector<NetworkInterface_Dev> >&
+ callback);
+
+ private:
+ InstanceHandle instance_;
+};
+
+} // namespace socket
+} // namespace ext
+} // namespace pp
+
+#endif // PPAPI_CPP_EXTENSIONS_DEV_SOCKET_DEV_H_
diff --git a/ppapi/cpp/extensions/from_var_converter.h b/ppapi/cpp/extensions/from_var_converter.h
index 6fb8a32..ddafe1d 100644
--- a/ppapi/cpp/extensions/from_var_converter.h
+++ b/ppapi/cpp/extensions/from_var_converter.h
@@ -8,6 +8,8 @@
#include <string>
#include "ppapi/c/pp_var.h"
+#include "ppapi/cpp/dev/var_array_dev.h"
+#include "ppapi/cpp/dev/var_dictionary_dev.h"
#include "ppapi/cpp/extensions/optional.h"
#include "ppapi/cpp/logging.h"
#include "ppapi/cpp/var.h"
@@ -80,7 +82,7 @@ class FromVarConverter<Optional<T> >
};
template <>
-class FromVarConverter<std::string> : public FromVarConverterBase<std::string> {
+class FromVarConverter<bool> : public FromVarConverterBase<bool> {
public:
FromVarConverter() {
}
@@ -93,7 +95,25 @@ class FromVarConverter<std::string> : public FromVarConverterBase<std::string> {
}
void Set(const PP_Var& var) {
- FromVarConverterBase<std::string>::value_ = Var(var).AsString();
+ FromVarConverterBase<bool>::value_ = Var(var).AsBool();
+ }
+};
+
+template <>
+class FromVarConverter<int32_t> : public FromVarConverterBase<int32_t> {
+ public:
+ FromVarConverter() {
+ }
+
+ FromVarConverter(const PP_Var& var) {
+ Set(var);
+ }
+
+ ~FromVarConverter() {
+ }
+
+ void Set(const PP_Var& var) {
+ FromVarConverterBase<int32_t>::value_ = Var(var).AsInt();
}
};
@@ -115,6 +135,80 @@ class FromVarConverter<double> : public FromVarConverterBase<double> {
}
};
+template <>
+class FromVarConverter<std::string> : public FromVarConverterBase<std::string> {
+ public:
+ FromVarConverter() {
+ }
+
+ FromVarConverter(const PP_Var& var) {
+ Set(var);
+ }
+
+ ~FromVarConverter() {
+ }
+
+ void Set(const PP_Var& var) {
+ FromVarConverterBase<std::string>::value_ = Var(var).AsString();
+ }
+};
+
+template <>
+class FromVarConverter<Var> : public FromVarConverterBase<Var> {
+ public:
+ FromVarConverter() {
+ }
+
+ FromVarConverter(const PP_Var& var) {
+ Set(var);
+ }
+
+ ~FromVarConverter() {
+ }
+
+ void Set(const PP_Var& var) {
+ FromVarConverterBase<Var>::value_ = Var(var);
+ }
+};
+
+template <>
+class FromVarConverter<VarArray_Dev>
+ : public FromVarConverterBase<VarArray_Dev> {
+ public:
+ FromVarConverter() {
+ }
+
+ FromVarConverter(const PP_Var& var) {
+ Set(var);
+ }
+
+ ~FromVarConverter() {
+ }
+
+ void Set(const PP_Var& var) {
+ FromVarConverterBase<VarArray_Dev>::value_ = Var(var);
+ }
+};
+
+template <>
+class FromVarConverter<VarDictionary_Dev>
+ : public FromVarConverterBase<VarDictionary_Dev> {
+ public:
+ FromVarConverter() {
+ }
+
+ FromVarConverter(const PP_Var& var) {
+ Set(var);
+ }
+
+ ~FromVarConverter() {
+ }
+
+ void Set(const PP_Var& var) {
+ FromVarConverterBase<VarDictionary_Dev>::value_ = Var(var);
+ }
+};
+
} // namespace internal
} // namespace ext
} // namespace pp
diff --git a/ppapi/cpp/extensions/to_var_converter.h b/ppapi/cpp/extensions/to_var_converter.h
index ba05064..5913652 100644
--- a/ppapi/cpp/extensions/to_var_converter.h
+++ b/ppapi/cpp/extensions/to_var_converter.h
@@ -8,8 +8,11 @@
#include <string>
#include "ppapi/c/pp_var.h"
+#include "ppapi/cpp/dev/var_array_dev.h"
+#include "ppapi/cpp/dev/var_dictionary_dev.h"
#include "ppapi/cpp/extensions/optional.h"
#include "ppapi/cpp/var.h"
+#include "ppapi/cpp/var_array_buffer.h"
namespace pp {
namespace ext {
@@ -66,6 +69,36 @@ class ToVarConverter<Optional<T> > : public ToVarConverterBase {
};
template <>
+class ToVarConverter<bool> : public ToVarConverterBase {
+ public:
+ explicit ToVarConverter(bool object) : ToVarConverterBase(Var(object)) {
+ }
+
+ ~ToVarConverter() {
+ }
+};
+
+template <>
+class ToVarConverter<int32_t> : public ToVarConverterBase {
+ public:
+ explicit ToVarConverter(int32_t object) : ToVarConverterBase(Var(object)) {
+ }
+
+ ~ToVarConverter() {
+ }
+};
+
+template <>
+class ToVarConverter<double> : public ToVarConverterBase {
+ public:
+ explicit ToVarConverter(double object) : ToVarConverterBase(Var(object)) {
+ }
+
+ ~ToVarConverter() {
+ }
+};
+
+template <>
class ToVarConverter<std::string> : public ToVarConverterBase {
public:
explicit ToVarConverter(const std::string& object)
@@ -77,9 +110,39 @@ class ToVarConverter<std::string> : public ToVarConverterBase {
};
template <>
-class ToVarConverter<double> : public ToVarConverterBase {
+class ToVarConverter<Var> : public ToVarConverterBase {
public:
- explicit ToVarConverter(double object) : ToVarConverterBase(Var(object)) {
+ explicit ToVarConverter(const Var& object) : ToVarConverterBase(object) {
+ }
+
+ ~ToVarConverter() {
+ }
+};
+
+template <>
+class ToVarConverter<VarArray_Dev> : public ToVarConverterBase {
+ public:
+ explicit ToVarConverter(const Var& object) : ToVarConverterBase(object) {
+ }
+
+ ~ToVarConverter() {
+ }
+};
+
+template <>
+class ToVarConverter<VarDictionary_Dev> : public ToVarConverterBase {
+ public:
+ explicit ToVarConverter(const Var& object) : ToVarConverterBase(object) {
+ }
+
+ ~ToVarConverter() {
+ }
+};
+
+template <>
+class ToVarConverter<VarArrayBuffer> : public ToVarConverterBase {
+ public:
+ explicit ToVarConverter(const Var& object) : ToVarConverterBase(object) {
}
~ToVarConverter() {
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 51a27c4..430156e 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
@@ -46,6 +46,7 @@
#include "ppapi/c/dev/ppp_zoom_dev.h"
#include "ppapi/c/extensions/dev/ppb_ext_alarms_dev.h"
#include "ppapi/c/extensions/dev/ppb_ext_events_dev.h"
+#include "ppapi/c/extensions/dev/ppb_ext_socket_dev.h"
#include "ppapi/c/ppb_audio.h"
#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/c/ppb_console.h"
@@ -280,6 +281,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Flash_BrowserOperations_1
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;
/* END Declarations for all Wrapper Infos. */
/* Not generating wrapper methods for PPB_Audio_1_0 */
@@ -3946,6 +3948,100 @@ void Pnacl_M27_PPB_Ext_Events_Dev_RemoveListener(PP_Instance instance, uint32_t
/* End wrapper methods for PPB_Ext_Events_Dev_0_1 */
+/* Begin wrapper methods for PPB_Ext_Socket_Dev_0_1 */
+
+static __attribute__((pnaclcall))
+int32_t Pnacl_M28_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_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ return iface->Create(instance, type, options, create_info, callback);
+}
+
+static __attribute__((pnaclcall))
+void Pnacl_M28_PPB_Ext_Socket_Dev_Destroy(PP_Instance instance, struct PP_Var socket_id) {
+ const struct PPB_Ext_Socket_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ iface->Destroy(instance, socket_id);
+}
+
+static __attribute__((pnaclcall))
+int32_t Pnacl_M28_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_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ return iface->Connect(instance, socket_id, hostname, port, result, callback);
+}
+
+static __attribute__((pnaclcall))
+int32_t Pnacl_M28_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_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ return iface->Bind(instance, socket_id, address, port, result, callback);
+}
+
+static __attribute__((pnaclcall))
+void Pnacl_M28_PPB_Ext_Socket_Dev_Disconnect(PP_Instance instance, struct PP_Var socket_id) {
+ const struct PPB_Ext_Socket_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ iface->Disconnect(instance, socket_id);
+}
+
+static __attribute__((pnaclcall))
+int32_t Pnacl_M28_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_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ return iface->Read(instance, socket_id, buffer_size, read_info, callback);
+}
+
+static __attribute__((pnaclcall))
+int32_t Pnacl_M28_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_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ return iface->Write(instance, socket_id, data, write_info, callback);
+}
+
+static __attribute__((pnaclcall))
+int32_t Pnacl_M28_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_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ return iface->RecvFrom(instance, socket_id, buffer_size, recv_from_info, callback);
+}
+
+static __attribute__((pnaclcall))
+int32_t Pnacl_M28_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_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ return iface->SendTo(instance, socket_id, data, address, port, write_info, callback);
+}
+
+static __attribute__((pnaclcall))
+int32_t Pnacl_M28_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_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ return iface->Listen(instance, socket_id, address, port, backlog, result, callback);
+}
+
+static __attribute__((pnaclcall))
+int32_t Pnacl_M28_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_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ return iface->Accept(instance, socket_id, accept_info, callback);
+}
+
+static __attribute__((pnaclcall))
+int32_t Pnacl_M28_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_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ return iface->SetKeepAlive(instance, socket_id, enable, delay, result, callback);
+}
+
+static __attribute__((pnaclcall))
+int32_t Pnacl_M28_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_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ return iface->SetNoDelay(instance, socket_id, no_delay, result, callback);
+}
+
+static __attribute__((pnaclcall))
+int32_t Pnacl_M28_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_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ return iface->GetInfo(instance, socket_id, result, callback);
+}
+
+static __attribute__((pnaclcall))
+int32_t Pnacl_M28_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_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1.real_iface;
+ return iface->GetNetworkList(instance, result, callback);
+}
+
+/* End wrapper methods for PPB_Ext_Socket_Dev_0_1 */
+
/* Not generating wrapper interface for PPB_Audio_1_0 */
/* Not generating wrapper interface for PPB_AudioConfig_1_0 */
@@ -4858,6 +4954,24 @@ struct PPB_Ext_Events_Dev_0_1 Pnacl_Wrappers_PPB_Ext_Events_Dev_0_1 = {
.RemoveListener = (void (*)(PP_Instance instance, uint32_t listener_id))&Pnacl_M27_PPB_Ext_Events_Dev_RemoveListener
};
+struct PPB_Ext_Socket_Dev_0_1 Pnacl_Wrappers_PPB_Ext_Socket_Dev_0_1 = {
+ .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_M28_PPB_Ext_Socket_Dev_Create,
+ .Destroy = (void (*)(PP_Instance instance, struct PP_Var socket_id))&Pnacl_M28_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_M28_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_M28_PPB_Ext_Socket_Dev_Bind,
+ .Disconnect = (void (*)(PP_Instance instance, struct PP_Var socket_id))&Pnacl_M28_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_M28_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_M28_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_M28_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_M28_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_M28_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_M28_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_M28_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_M28_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_M28_PPB_Ext_Socket_Dev_GetInfo,
+ .GetNetworkList = (int32_t (*)(PP_Instance instance, PP_Ext_Socket_NetworkInterface_Dev_Array* result, struct PP_CompletionCallback callback))&Pnacl_M28_PPB_Ext_Socket_Dev_GetNetworkList
+};
+
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 */,
@@ -5734,6 +5848,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Events_Dev_0_1 = {
.real_iface = NULL
};
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1 = {
+ .iface_macro = PPB_EXT_SOCKET_DEV_INTERFACE_0_1,
+ .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_Ext_Socket_Dev_0_1,
+ .real_iface = NULL
+};
+
static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
&Pnacl_WrapperInfo_PPB_Audio_1_0,
&Pnacl_WrapperInfo_PPB_AudioConfig_1_0,
@@ -5858,6 +5978,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
&Pnacl_WrapperInfo_PPB_X509Certificate_Private_0_1,
&Pnacl_WrapperInfo_PPB_Ext_Alarms_Dev_0_1,
&Pnacl_WrapperInfo_PPB_Ext_Events_Dev_0_1,
+ &Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_1,
NULL
};
diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi
index b8e9ef5..016bcb4 100644
--- a/ppapi/ppapi_sources.gypi
+++ b/ppapi/ppapi_sources.gypi
@@ -138,6 +138,7 @@
# Extensions dev interfaces.
'c/extensions/dev/ppb_ext_alarms_dev.h',
'c/extensions/dev/ppb_ext_events_dev.h',
+ 'c/extensions/dev/ppb_ext_socket_dev.h',
],
'cpp_source_files': [
'cpp/array_output.cc',
@@ -342,6 +343,8 @@
'cpp/extensions/dev/alarms_dev.h',
'cpp/extensions/dev/events_dev.cc',
'cpp/extensions/dev/events_dev.h',
+ 'cpp/extensions/dev/socket_dev.cc',
+ 'cpp/extensions/dev/socket_dev.h',
# Utility sources.
'utility/completion_callback_factory.h',
diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h
index a48fdb7..9f9757e 100644
--- a/ppapi/tests/all_c_includes.h
+++ b/ppapi/tests/all_c_includes.h
@@ -49,6 +49,7 @@
#include "ppapi/c/dev/ppp_zoom_dev.h"
#include "ppapi/c/extensions/dev/ppb_ext_alarms_dev.h"
#include "ppapi/c/extensions/dev/ppb_ext_events_dev.h"
+#include "ppapi/c/extensions/dev/ppb_ext_socket_dev.h"
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
diff --git a/ppapi/tests/all_cpp_includes.h b/ppapi/tests/all_cpp_includes.h
index 75ea723..c9e0a6b 100644
--- a/ppapi/tests/all_cpp_includes.h
+++ b/ppapi/tests/all_cpp_includes.h
@@ -37,6 +37,7 @@
#include "ppapi/cpp/dev/widget_dev.h"
#include "ppapi/cpp/dev/zoom_dev.h"
#include "ppapi/cpp/extensions/dev/alarms_dev.h"
+#include "ppapi/cpp/extensions/dev/socket_dev.h"
#include "ppapi/cpp/file_io.h"
#include "ppapi/cpp/file_ref.h"
#include "ppapi/cpp/file_system.h"