| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 // File-level comment to appease parser. Eventually this will not be necessary. | |
| 6 | |
| 7 [nodoc] namespace experimental.socket { | |
| 8 // The socket options. | |
| 9 dictionary CreateOptions { | |
| 10 // The schema generator does not support dictionaries without any fields. | |
| 11 // Ignore this field. | |
| 12 [nodoc] long? dummyValue; | |
| 13 }; | |
| 14 | |
| 15 dictionary CreateInfo { | |
| 16 // The id of the newly created socket. | |
| 17 long socketId; | |
| 18 }; | |
| 19 | |
| 20 callback CreateCallback = void (CreateInfo createInfo); | |
| 21 | |
| 22 callback ConnectCallback = void (long result); | |
| 23 | |
| 24 callback BindCallback = void (long result); | |
| 25 | |
| 26 dictionary ReadInfo { | |
| 27 // The resultCode returned from the underlying read() call. | |
| 28 long resultCode; | |
| 29 | |
| 30 ArrayBuffer data; | |
| 31 }; | |
| 32 | |
| 33 callback ReadCallback = void (ReadInfo readInfo); | |
| 34 | |
| 35 dictionary WriteInfo { | |
| 36 // The number of bytes sent, or a negative error code. | |
| 37 long bytesWritten; | |
| 38 }; | |
| 39 | |
| 40 callback WriteCallback = void (WriteInfo writeInfo); | |
| 41 | |
| 42 dictionary RecvFromInfo { | |
| 43 // The resultCode returned from the underlying read() call. | |
| 44 long resultCode; | |
| 45 | |
| 46 ArrayBuffer data; | |
| 47 DOMString address; | |
| 48 long port; | |
| 49 }; | |
| 50 | |
| 51 callback RecvFromCallback = void (RecvFromInfo recvFromInfo); | |
| 52 | |
| 53 callback SendToCallback = void (WriteInfo writeInfo); | |
| 54 | |
| 55 interface Functions { | |
| 56 // Creates a socket of the specified type that will connect to the specified | |
| 57 // remote machine. | |
| 58 // |type| : The type of socket to create. Must be <code>tcp</code> or | |
| 59 // <code>udp</code>. | |
| 60 // |options| : The socket options. | |
| 61 // |callback| : Called when the socket has been created. | |
| 62 static void create(DOMString type, | |
| 63 optional CreateOptions options, | |
| 64 CreateCallback callback); | |
| 65 | |
| 66 // Destroys the socket. Each socket created should be destroyed after use. | |
| 67 // |socketId| : The socketId. | |
| 68 static void destroy(long socketId); | |
| 69 | |
| 70 // Connects the socket to the remote machine. | |
| 71 // |socketId| : The socketId. | |
| 72 // |address| : The address of the remote machine. | |
| 73 // |port| : The port of the remote machine. | |
| 74 // |callback| : Called when the connection attempt is complete. | |
| 75 static void connect(long socketId, | |
| 76 DOMString address, | |
| 77 long port, | |
| 78 ConnectCallback callback); | |
| 79 | |
| 80 // Binds the local address for UDP socket. Currently, it does not support | |
| 81 // TCP socket. | |
| 82 // |socketId| : The socketId. | |
| 83 // |address| : The address of the remote machine. | |
| 84 // |port| : The port of the remote machine. | |
| 85 // |callback| : Called when the connection attempt is complete. | |
| 86 static void bind(long socketId, | |
| 87 DOMString address, | |
| 88 long port, | |
| 89 BindCallback callback); | |
| 90 | |
| 91 // Disconnects the socket. For UDP sockets, <code>disconnect</code> is a | |
| 92 // non-operation but is safe to call. | |
| 93 // |socketId| : The socketId. | |
| 94 static void disconnect(long socketId); | |
| 95 | |
| 96 // Reads data from the given socket. | |
| 97 // |socketId| : The socketId. | |
| 98 // |bufferSize| : The read buffer size. | |
| 99 // |callback| : Delivers data that was available to be read without | |
| 100 // blocking. | |
| 101 static void read(long socketId, | |
| 102 optional long bufferSize, | |
| 103 ReadCallback callback); | |
| 104 | |
| 105 // Writes data on the given socket. | |
| 106 // |socketId| : The socketId. | |
| 107 // |data| : The data to write. Warning: will probably become a blob or other | |
| 108 // appropriate binary-friendly type. | |
| 109 // |callback| : Called when the first of any of the following happens: the | |
| 110 // write operation completes without blocking, the write operation blocked | |
| 111 // before completion (in which case onEvent() will eventually be called with | |
| 112 // a <code>writeComplete</code> event), or an error occurred. | |
| 113 static void write(long socketId, | |
| 114 ArrayBuffer data, | |
| 115 WriteCallback callback); | |
| 116 | |
| 117 // Reads data from the given socket. | |
| 118 // |socketId| : The socketId. | |
| 119 // |bufferSize| : The receive buffer size. | |
| 120 // |callback| : Delivers data that was available to be read without | |
| 121 // blocking. | |
| 122 static void recvFrom(long socketId, | |
| 123 optional long bufferSize, | |
| 124 RecvFromCallback callback); | |
| 125 | |
| 126 // Writes data on the given socket. | |
| 127 // |socketId| : The socketId. | |
| 128 // |data| : The data to write. Warning: will probably become a blob or other | |
| 129 // appropriate binary-friendly type. | |
| 130 // |address| : The address of the remote machine. | |
| 131 // |port| : The port of the remote machine. | |
| 132 // |callback| : Called when the first of any of the following happens: the | |
| 133 // write operation completes without blocking, the write operation blocked | |
| 134 // before completion (in which case onEvent() will eventually be called with | |
| 135 // a <code>writeComplete</code> event), or an error occurred. | |
| 136 static void sendTo(long socketId, | |
| 137 ArrayBuffer data, | |
| 138 DOMString address, | |
| 139 long port, | |
| 140 SendToCallback callback); | |
| 141 }; | |
| 142 | |
| 143 }; | |
| OLD | NEW |