diff options
Diffstat (limited to 'ppapi/api/dev/ppb_tcp_socket_dev.idl')
-rw-r--r-- | ppapi/api/dev/ppb_tcp_socket_dev.idl | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/ppapi/api/dev/ppb_tcp_socket_dev.idl b/ppapi/api/dev/ppb_tcp_socket_dev.idl new file mode 100644 index 0000000..dfc038a --- /dev/null +++ b/ppapi/api/dev/ppb_tcp_socket_dev.idl @@ -0,0 +1,115 @@ +/* Copyright 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 <code>PPB_TCPSocket_Dev</code> interface. + */ + +[generate_thunk] + +label Chrome { + M29 = 0.1 +}; + +[assert_size(4)] +enum PP_TCPSocket_Option_Dev { + // Disables coalescing of small writes to make TCP segments, and instead + // deliver data immediately. Value type is PP_VARTYPE_BOOL. + PP_TCPSOCKET_OPTION_NO_DELAY = 0, + + // Specifies the socket send buffer in bytes. Value's type should be + // PP_VARTYPE_INT32. + // Note: This is only treated as a hint for the browser to set the buffer + // size. Even if SetOption() reports that this option has been successfully + // set, the browser doesn't guarantee to conform to it. + PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE = 1, + + // Specifies the socket receive buffer in bytes. Value's type should be + // PP_VARTYPE_INT32. + // Note: This is only treated as a hint for the browser to set the buffer + // size. Even if SetOption() reports that this option has been successfully + // set, the browser doesn't guarantee to conform to it. + PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE = 2 +}; + +/** + * The <code>PPB_TCPSocket_Dev</code> interface provides TCP socket operations. + */ +interface PPB_TCPSocket_Dev { + /** + * Allocates a TCP socket resource. + */ + PP_Resource Create([in] PP_Instance instance); + + /** + * Determines if a given resource is TCP socket. + */ + PP_Bool IsTCPSocket([in] PP_Resource resource); + + /** + * Connects to an address given by |addr|, which is a PPB_NetAddress_Dev + * resource. + */ + int32_t Connect([in] PP_Resource tcp_socket, + [in] PP_Resource addr, + [in] PP_CompletionCallback callback); + + /** + * Gets the local address of the socket, if it has been connected. + * Returns a PPB_NetAddress_Dev resource on success; returns 0 on failure. + */ + PP_Resource GetLocalAddress([in] PP_Resource tcp_socket); + + /** + * Gets the remote address of the socket, if it has been connected. + * Returns a PPB_NetAddress_Dev resource on success; returns 0 on failure. + */ + PP_Resource GetRemoteAddress([in] PP_Resource tcp_socket); + + /** + * Reads data from the socket. The size of |buffer| must be at least as large + * as |bytes_to_read|. May perform a partial read. Returns the number of bytes + * read or an error code. If the return value is 0, then it indicates that + * end-of-file was reached. + * + * Multiple outstanding read requests are not supported. + */ + int32_t Read([in] PP_Resource tcp_socket, + [out] str_t buffer, + [in] int32_t bytes_to_read, + [in] PP_CompletionCallback callback); + + /** + * Writes data to the socket. May perform a partial write. Returns the number + * of bytes written or an error code. + * + * Multiple outstanding write requests are not supported. + */ + int32_t Write([in] PP_Resource tcp_socket, + [in] str_t buffer, + [in] int32_t bytes_to_write, + [in] PP_CompletionCallback callback); + + /** + * Cancels any IO that may be pending, and disconnects the socket. Any pending + * callbacks will still run, reporting PP_ERROR_ABORTED if pending IO was + * interrupted. It is NOT valid to call Connect() again after a call to this + * method. Note: If the socket is destroyed when it is still connected, then + * it will be implicitly disconnected, so you are not required to call this + * method. + */ + void Close([in] PP_Resource tcp_socket); + + /** + * Sets an option on |tcp_socket|. Supported |name| and |value| parameters + * are as described for PP_TCPSocketOption_Dev. |callback| will be + * invoked with PP_OK if setting the option succeeds, or an error code + * otherwise. The socket must be connected before SetOption is called. + */ + int32_t SetOption([in] PP_Resource tcp_socket, + [in] PP_TCPSocket_Option_Dev name, + [in] PP_Var value, + [in] PP_CompletionCallback callback); +}; |