OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Use the <code>chrome.sockets.tcp</code> API to send and receive data over the | 5 // Use the <code>chrome.sockets.tcp</code> API to send and receive data over the |
6 // network using TCP connections. This API supersedes the TCP functionality | 6 // network using TCP connections. This API supersedes the TCP functionality |
7 // previously found in the <code>chrome.socket</code> API. | 7 // previously found in the <code>chrome.socket</code> API. |
8 namespace sockets.tcp { | 8 namespace sockets.tcp { |
9 // The socket properties specified in the <code>create</code> or | 9 // The socket properties specified in the <code>create</code> or |
10 // <code>update</code> function. Each property is optional. If a property | 10 // <code>update</code> function. Each property is optional. If a property |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // Callback from the <code>setKeepAliveCallback</code> method. | 73 // Callback from the <code>setKeepAliveCallback</code> method. |
74 // |result| : The result code returned from the underlying network call. | 74 // |result| : The result code returned from the underlying network call. |
75 // A negative value indicates an error. | 75 // A negative value indicates an error. |
76 callback SetKeepAliveCallback = void (long result); | 76 callback SetKeepAliveCallback = void (long result); |
77 | 77 |
78 // Callback from the <code>setNodeDelay</code> method. | 78 // Callback from the <code>setNodeDelay</code> method. |
79 // |result| : The result code returned from the underlying network call. | 79 // |result| : The result code returned from the underlying network call. |
80 // A negative value indicates an error. | 80 // A negative value indicates an error. |
81 callback SetNoDelayCallback = void (long result); | 81 callback SetNoDelayCallback = void (long result); |
82 | 82 |
| 83 dictionary TLSVersionConstraints { |
| 84 // The minimum and maximum acceptable versions of TLS. These will |
| 85 // be <code>ssl3</code>, <code>tls1</code>, <code>tls1.1</code>, |
| 86 // or <code>tls1.2</code>. |
| 87 DOMString? min; |
| 88 DOMString? max; |
| 89 }; |
| 90 |
| 91 dictionary SecureOptions { |
| 92 TLSVersionConstraints? tlsVersion; |
| 93 }; |
| 94 |
| 95 callback SecureCallback = void (long result); |
| 96 |
83 // Result of the <code>getInfo</code> method. | 97 // Result of the <code>getInfo</code> method. |
84 dictionary SocketInfo { | 98 dictionary SocketInfo { |
85 // The socket identifier. | 99 // The socket identifier. |
86 long socketId; | 100 long socketId; |
87 | 101 |
88 // Flag indicating whether the socket is left open when the application is | 102 // Flag indicating whether the socket is left open when the application is |
89 // suspended (see <code>SocketProperties.persistent</code>). | 103 // suspended (see <code>SocketProperties.persistent</code>). |
90 boolean persistent; | 104 boolean persistent; |
91 | 105 |
92 // Application-defined string associated with the socket. | 106 // Application-defined string associated with the socket. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 DOMString peerAddress, | 216 DOMString peerAddress, |
203 long peerPort, | 217 long peerPort, |
204 ConnectCallback callback); | 218 ConnectCallback callback); |
205 | 219 |
206 // Disconnects the socket. | 220 // Disconnects the socket. |
207 // |socketId| : The socket identifier. | 221 // |socketId| : The socket identifier. |
208 // |callback| : Called when the disconnect attempt is complete. | 222 // |callback| : Called when the disconnect attempt is complete. |
209 static void disconnect(long socketId, | 223 static void disconnect(long socketId, |
210 optional DisconnectCallback callback); | 224 optional DisconnectCallback callback); |
211 | 225 |
| 226 // Start a TLS client connection over the connected TCP client socket. |
| 227 // |socketId| : The existing, connected socket to use. |
| 228 // |options| : Constraints and parameters for the TLS connection. |
| 229 // |callback| : Called when the connection attempt is complete. |
| 230 static void secure(long socketId, |
| 231 optional SecureOptions options, |
| 232 SecureCallback callback); |
| 233 |
212 // Sends data on the given TCP socket. | 234 // Sends data on the given TCP socket. |
213 // |socketId| : The socket identifier. | 235 // |socketId| : The socket identifier. |
214 // |data| : The data to send. | 236 // |data| : The data to send. |
215 // |callback| : Called when the <code>send</code> operation completes. | 237 // |callback| : Called when the <code>send</code> operation completes. |
216 static void send(long socketId, | 238 static void send(long socketId, |
217 ArrayBuffer data, | 239 ArrayBuffer data, |
218 SendCallback callback); | 240 SendCallback callback); |
219 | 241 |
220 // Closes the socket and releases the address/port the socket is bound to. | 242 // Closes the socket and releases the address/port the socket is bound to. |
221 // Each socket created should be closed after use. The socket id is no | 243 // Each socket created should be closed after use. The socket id is no |
(...skipping 21 matching lines...) Expand all Loading... |
243 static void onReceive(ReceiveInfo info); | 265 static void onReceive(ReceiveInfo info); |
244 | 266 |
245 // Event raised when a network error occured while the runtime was waiting | 267 // Event raised when a network error occured while the runtime was waiting |
246 // for data on the socket address and port. Once this event is raised, the | 268 // for data on the socket address and port. Once this event is raised, the |
247 // socket is set to <code>paused</code> and no more <code>onReceive</code> | 269 // socket is set to <code>paused</code> and no more <code>onReceive</code> |
248 // events are raised for this socket. | 270 // events are raised for this socket. |
249 // |info| : The event data. | 271 // |info| : The event data. |
250 static void onReceiveError(ReceiveErrorInfo info); | 272 static void onReceiveError(ReceiveErrorInfo info); |
251 }; | 273 }; |
252 }; | 274 }; |
OLD | NEW |