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.udp</code> API to send and receive data over the | 5 // Use the <code>chrome.sockets.udp</code> API to send and receive data over the |
6 // network using UDP connections. This API supersedes the UDP functionality | 6 // network using UDP connections. This API supersedes the UDP functionality |
7 // previously found in the "socket" API. Note that the socket ids created from | 7 // previously found in the "socket" API. |
8 // this namespace are not compatible with ids created in other namespaces. | |
9 namespace sockets.udp { | 8 namespace sockets.udp { |
10 // The socket properties specified in the <code>create</code> or | 9 // The socket properties specified in the <code>create</code> or |
11 // <code>update</code> function. Each property is optional. If a property | 10 // <code>update</code> function. Each property is optional. If a property |
12 // value is not specified, a default value is used when calling | 11 // value is not specified, a default value is used when calling |
13 // <code>create</code>, or the existing value if preserved when calling | 12 // <code>create</code>, or the existing value if preserved when calling |
14 // <code>update</code>. | 13 // <code>update</code>. |
15 dictionary SocketProperties { | 14 dictionary SocketProperties { |
16 // Flag indicating if the socket is left open when the event page of the | 15 // Flag indicating if the socket is left open when the event page of the |
17 // application is unloaded (see | 16 // application is unloaded (see |
18 // <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 |
19 // Lifecycle</a>). The default value is "false." When the application is | 18 // Lifecycle</a>). The default value is "false." When the application is |
20 // loaded, any sockets previously opened with persistent=true can be fetched | 19 // loaded, any sockets previously opened with persistent=true can be fetched |
21 // with <code>getSockets</code>. | 20 // with <code>getSockets</code>. |
22 boolean? persistent; | 21 boolean? persistent; |
23 | 22 |
24 // An application-defined string associated with the socket. | 23 // An application-defined string associated with the socket. |
25 DOMString? name; | 24 DOMString? name; |
26 | 25 |
27 // The size of the buffer used to receive data. If the buffer is too small | 26 // The size of the buffer used to receive data. If the buffer is too small |
28 // to receive the UDP packet, data is lost. The default value is 4096. | 27 // to receive the UDP packet, data is lost. The default value is 4096. |
29 long? bufferSize; | 28 long? bufferSize; |
30 }; | 29 }; |
31 | 30 |
32 // Result of <code>create</code> call. | 31 // Result of <code>create</code> call. |
33 dictionary CreateInfo { | 32 dictionary CreateInfo { |
34 // The ID of the newly created socket. | 33 // The ID of the newly created socket. Note that socket IDs created from |
| 34 // this API are not compatible with socket IDs created from other APIs, such |
| 35 // as the deprecated <code>$ref:socket</code> API. |
35 long socketId; | 36 long socketId; |
36 }; | 37 }; |
37 | 38 |
38 // Callback from the <code>create</code> method. | 39 // Callback from the <code>create</code> method. |
39 // |createInfo| : The result of the socket creation. | 40 // |createInfo| : The result of the socket creation. |
40 callback CreateCallback = void (CreateInfo createInfo); | 41 callback CreateCallback = void (CreateInfo createInfo); |
41 | 42 |
42 // Callback from the <code>bind</code> method. | 43 // Callback from the <code>bind</code> method. |
43 // |result| : The result code returned from the underlying network call. | 44 // |result| : The result code returned from the underlying network call. |
44 // A negative value indicates an error. | 45 // A negative value indicates an error. |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 static void onReceive(ReceiveInfo info); | 299 static void onReceive(ReceiveInfo info); |
299 | 300 |
300 // Event raised when a network error occured while the runtime was waiting | 301 // Event raised when a network error occured while the runtime was waiting |
301 // for data on the socket address and port. Once this event is raised, the | 302 // for data on the socket address and port. Once this event is raised, the |
302 // socket is paused and no more <code>onReceive</code> events will be raised | 303 // socket is paused and no more <code>onReceive</code> events will be raised |
303 // for this socket until the socket is resumed. | 304 // for this socket until the socket is resumed. |
304 // |info| : The event data. | 305 // |info| : The event data. |
305 static void onReceiveError(ReceiveErrorInfo info); | 306 static void onReceiveError(ReceiveErrorInfo info); |
306 }; | 307 }; |
307 }; | 308 }; |
OLD | NEW |