OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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. Note that the socket | 7 // previously found in the <code>chrome.socket</code> API. |
8 // ids created from this namespace are not compatible with ids created in other | |
9 // namespaces. | |
10 namespace sockets.tcp { | 8 namespace sockets.tcp { |
11 // The socket properties specified in the <code>create</code> or | 9 // The socket properties specified in the <code>create</code> or |
12 // <code>update</code> function. Each property is optional. If a property | 10 // <code>update</code> function. Each property is optional. If a property |
13 // value is not specified, a default value is used when calling | 11 // value is not specified, a default value is used when calling |
14 // <code>create</code>, or the existing value if preserved when calling | 12 // <code>create</code>, or the existing value if preserved when calling |
15 // <code>update</code>. | 13 // <code>update</code>. |
16 dictionary SocketProperties { | 14 dictionary SocketProperties { |
17 // Flag indicating if the socket is left open when the event page of | 15 // Flag indicating if the socket is left open when the event page of |
18 // the application is unloaded (see | 16 // the application is unloaded (see |
19 // <a href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App | 17 // <a href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App |
20 // Lifecycle</a>). The default value is "false." When the application is | 18 // Lifecycle</a>). The default value is "false." When the application is |
21 // loaded, any sockets previously opened with persistent=true can be fetched | 19 // loaded, any sockets previously opened with persistent=true can be fetched |
22 // with <code>getSockets</code>. | 20 // with <code>getSockets</code>. |
23 boolean? persistent; | 21 boolean? persistent; |
24 | 22 |
25 // An application-defined string associated with the socket. | 23 // An application-defined string associated with the socket. |
26 DOMString? name; | 24 DOMString? name; |
27 | 25 |
28 // The size of the buffer used to receive data. The default value is 4096. | 26 // The size of the buffer used to receive data. The default value is 4096. |
29 long? bufferSize; | 27 long? bufferSize; |
30 }; | 28 }; |
31 | 29 |
32 // Result of <code>create</code> call. | 30 // Result of <code>create</code> call. |
33 dictionary CreateInfo { | 31 dictionary CreateInfo { |
34 // The ID of the newly created socket. | 32 // The ID of the newly created socket. Note that socket IDs created from |
| 33 // this API are not compatible with socket IDs created from other APIs, such |
| 34 // as the deprecated <code>$ref:socket</code> API. |
35 long socketId; | 35 long socketId; |
36 }; | 36 }; |
37 | 37 |
38 // Callback from the <code>create</code> method. | 38 // Callback from the <code>create</code> method. |
39 // |createInfo| : The result of the socket creation. | 39 // |createInfo| : The result of the socket creation. |
40 callback CreateCallback = void (CreateInfo createInfo); | 40 callback CreateCallback = void (CreateInfo createInfo); |
41 | 41 |
42 // Callback from the <code>connect</code> method. | 42 // Callback from the <code>connect</code> method. |
43 // |result| : The result code returned from the underlying network call. | 43 // |result| : The result code returned from the underlying network call. |
44 // A negative value indicates an error. | 44 // A negative value indicates an error. |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 static void onReceive(ReceiveInfo info); | 243 static void onReceive(ReceiveInfo info); |
244 | 244 |
245 // Event raised when a network error occured while the runtime was waiting | 245 // 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 | 246 // 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> | 247 // socket is set to <code>paused</code> and no more <code>onReceive</code> |
248 // events are raised for this socket. | 248 // events are raised for this socket. |
249 // |info| : The event data. | 249 // |info| : The event data. |
250 static void onReceiveError(ReceiveErrorInfo info); | 250 static void onReceiveError(ReceiveErrorInfo info); |
251 }; | 251 }; |
252 }; | 252 }; |
OLD | NEW |