| OLD | NEW |
| (Empty) | |
| 1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. |
| 4 */ |
| 5 |
| 6 /** |
| 7 * This file defines the <code>PPB_TCPSocket_Private</code> interface. |
| 8 */ |
| 9 |
| 10 label Chrome { |
| 11 M17 = 0.3 |
| 12 }; |
| 13 |
| 14 /** |
| 15 * The <code>PPB_TCPSocket_Private</code> interface provides TCP socket |
| 16 * operations. |
| 17 */ |
| 18 interface PPB_TCPSocket_Private { |
| 19 /** |
| 20 * Allocates a TCP socket resource. |
| 21 */ |
| 22 PP_Resource Create([in] PP_Instance instance); |
| 23 |
| 24 /** |
| 25 * Determines if a given resource is TCP socket. |
| 26 */ |
| 27 PP_Bool IsTCPSocket([in] PP_Resource resource); |
| 28 |
| 29 /** |
| 30 * Connects to a TCP port given as a host-port pair. |
| 31 * When a proxy server is used, |host| and |port| refer to the proxy server |
| 32 * instead of the destination server. |
| 33 */ |
| 34 int32_t Connect([in] PP_Resource tcp_socket, |
| 35 [in] str_t host, |
| 36 [in] uint16_t port, |
| 37 [in] PP_CompletionCallback callback); |
| 38 |
| 39 /** |
| 40 * Same as Connect(), but connecting to the address given by |addr|. A typical |
| 41 * use-case would be for reconnections. |
| 42 */ |
| 43 int32_t ConnectWithNetAddress([in] PP_Resource tcp_socket, |
| 44 [in] PP_NetAddress_Private addr, |
| 45 [in] PP_CompletionCallback callback); |
| 46 |
| 47 /** |
| 48 * Gets the local address of the socket, if it has been connected. |
| 49 * Returns PP_TRUE on success. |
| 50 */ |
| 51 PP_Bool GetLocalAddress([in] PP_Resource tcp_socket, |
| 52 [out] PP_NetAddress_Private local_addr); |
| 53 |
| 54 /** |
| 55 * Gets the remote address of the socket, if it has been connected. |
| 56 * Returns PP_TRUE on success. |
| 57 */ |
| 58 PP_Bool GetRemoteAddress([in] PP_Resource tcp_socket, |
| 59 [out] PP_NetAddress_Private remote_addr); |
| 60 |
| 61 /** |
| 62 * Does SSL handshake and moves to sending and receiving encrypted data. The |
| 63 * socket must have been successfully connected. |server_name| will be |
| 64 * compared with the name(s) in the server's certificate during the SSL |
| 65 * handshake. |server_port| is only used to identify an SSL server in the SSL |
| 66 * session cache. |
| 67 * When a proxy server is used, |server_name| and |server_port| refer to the |
| 68 * destination server. |
| 69 * If the socket is not connected, or there are pending read/write requests, |
| 70 * SSLHandshake() will fail without starting a handshake. Otherwise, any |
| 71 * failure during the handshake process will cause the socket to be |
| 72 * disconnected. |
| 73 */ |
| 74 int32_t SSLHandshake([in] PP_Resource tcp_socket, |
| 75 [in] str_t server_name, |
| 76 [in] uint16_t server_port, |
| 77 [in] PP_CompletionCallback callback); |
| 78 |
| 79 /** |
| 80 * Reads data from the socket. The size of |buffer| must be at least as large |
| 81 * as |bytes_to_read|. May perform a partial read. Returns the number of bytes |
| 82 * read or an error code. If the return value is 0, then it indicates that |
| 83 * end-of-file was reached. |
| 84 * This method won't return more than 1 megabyte, so if |bytes_to_read| |
| 85 * exceeds 1 megabyte, it will always perform a partial read. |
| 86 * Multiple outstanding read requests are not supported. |
| 87 */ |
| 88 int32_t Read([in] PP_Resource tcp_socket, |
| 89 [out] str_t buffer, |
| 90 [in] int32_t bytes_to_read, |
| 91 [in] PP_CompletionCallback callback); |
| 92 |
| 93 /** |
| 94 * Writes data to the socket. May perform a partial write. Returns the number |
| 95 * of bytes written or an error code. |
| 96 * This method won't write more than 1 megabyte, so if |bytes_to_write| |
| 97 * exceeds 1 megabyte, it will always perform a partial write. |
| 98 * Multiple outstanding write requests are not supported. |
| 99 */ |
| 100 int32_t Write([in] PP_Resource tcp_socket, |
| 101 [in] str_t buffer, |
| 102 [in] int32_t bytes_to_write, |
| 103 [in] PP_CompletionCallback callback); |
| 104 |
| 105 /** |
| 106 * Cancels any IO that may be pending, and disconnects the socket. Any pending |
| 107 * callbacks will still run, reporting PP_Error_Aborted if pending IO was |
| 108 * interrupted. It is NOT valid to call Connect() again after a call to this |
| 109 * method. Note: If the socket is destroyed when it is still connected, then |
| 110 * it will be implicitly disconnected, so you are not required to call this |
| 111 * method. |
| 112 */ |
| 113 void Disconnect([in] PP_Resource tcp_socket); |
| 114 }; |
| OLD | NEW |