| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 // File-level comment to appease parser. Eventually this will not be necessary. | 5 // File-level comment to appease parser. Eventually this will not be necessary. |
| 6 | 6 |
| 7 namespace experimental.socket { | 7 namespace experimental.socket { |
| 8 enum SocketType { | 8 enum SocketType { |
| 9 tcp, | 9 tcp, |
| 10 udp | 10 udp, |
| 11 ssl |
| 11 }; | 12 }; |
| 12 | 13 |
| 13 // The socket options. | 14 // The socket options. |
| 14 dictionary CreateOptions { | 15 dictionary CreateOptions { |
| 15 // The schema generator does not support dictionaries without any fields. | 16 // The schema generator does not support dictionaries without any fields. |
| 16 // Ignore this field. | 17 // Ignore this field. |
| 17 [nodoc] long? dummyValue; | 18 [nodoc] long? dummyValue; |
| 18 }; | 19 }; |
| 19 | 20 |
| 20 dictionary CreateInfo { | 21 dictionary CreateInfo { |
| 21 // The id of the newly created socket. | 22 // The id of the newly created socket. |
| 22 long socketId; | 23 long socketId; |
| 23 }; | 24 }; |
| 24 | 25 |
| 25 callback CreateCallback = void (CreateInfo createInfo); | 26 callback CreateCallback = void (CreateInfo createInfo); |
| 26 | 27 |
| 27 callback ConnectCallback = void (long result); | 28 callback ConnectCallback = void (long result); |
| 28 | 29 |
| 30 callback HandshakeCallback = void (long result); |
| 31 |
| 29 callback BindCallback = void (long result); | 32 callback BindCallback = void (long result); |
| 30 | 33 |
| 31 dictionary ReadInfo { | 34 dictionary ReadInfo { |
| 32 // The resultCode returned from the underlying read() call. | 35 // The resultCode returned from the underlying read() call. |
| 33 long resultCode; | 36 long resultCode; |
| 34 | 37 |
| 35 ArrayBuffer data; | 38 ArrayBuffer data; |
| 36 }; | 39 }; |
| 37 | 40 |
| 38 callback ReadCallback = void (ReadInfo readInfo); | 41 callback ReadCallback = void (ReadInfo readInfo); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // Connects the socket to the remote machine. | 82 // Connects the socket to the remote machine. |
| 80 // |socketId| : The socketId. | 83 // |socketId| : The socketId. |
| 81 // |hostname| : The hostname or IP address of the remote machine. | 84 // |hostname| : The hostname or IP address of the remote machine. |
| 82 // |port| : The port of the remote machine. | 85 // |port| : The port of the remote machine. |
| 83 // |callback| : Called when the connection attempt is complete. | 86 // |callback| : Called when the connection attempt is complete. |
| 84 static void connect(long socketId, | 87 static void connect(long socketId, |
| 85 DOMString hostname, | 88 DOMString hostname, |
| 86 long port, | 89 long port, |
| 87 ConnectCallback callback); | 90 ConnectCallback callback); |
| 88 | 91 |
| 92 // Performs an SSL handshake. While a handshake is in flight, calls to |
| 93 // read and write using the socket will fail. |
| 94 // |socketId| : The socketId of an SSL socket. |
| 95 // |hostname| : The hostname to check against the name(s) in the server's |
| 96 // certificate during the SSL handshake. |
| 97 // |port| : The port to check during the SSL handshake. |
| 98 // |callback| : Called when the connection attempt is complete. |
| 99 // Zero signifies success. Non-'ssl' sockets always pass -1. |
| 100 static void handshake(long socketId, |
| 101 DOMString hostname, |
| 102 long port, |
| 103 HandshakeCallback callback); |
| 104 |
| 89 // Binds the local address for socket. Currently, it does not support | 105 // Binds the local address for socket. Currently, it does not support |
| 90 // TCP socket. | 106 // TCP socket. |
| 91 // |socketId| : The socketId. | 107 // |socketId| : The socketId. |
| 92 // |address| : The address of the local machine. | 108 // |address| : The address of the local machine. |
| 93 // |port| : The port of the local machine. | 109 // |port| : The port of the local machine. |
| 94 // |callback| : Called when the bind attempt is complete. | 110 // |callback| : Called when the bind attempt is complete. |
| 95 static void bind(long socketId, | 111 static void bind(long socketId, |
| 96 DOMString address, | 112 DOMString address, |
| 97 long port, | 113 long port, |
| 98 BindCallback callback); | 114 BindCallback callback); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // write operation completes without blocking, the write operation blocked | 156 // write operation completes without blocking, the write operation blocked |
| 141 // before completion (in which case onEvent() will eventually be called with | 157 // before completion (in which case onEvent() will eventually be called with |
| 142 // a <code>writeComplete</code> event), or an error occurred. | 158 // a <code>writeComplete</code> event), or an error occurred. |
| 143 static void sendTo(long socketId, | 159 static void sendTo(long socketId, |
| 144 ArrayBuffer data, | 160 ArrayBuffer data, |
| 145 DOMString address, | 161 DOMString address, |
| 146 long port, | 162 long port, |
| 147 SendToCallback callback); | 163 SendToCallback callback); |
| 148 | 164 |
| 149 // Enable/disable keep-alive functionality for a TCP connection. | 165 // Enable/disable keep-alive functionality for a TCP connection. |
| 166 // Invalid on SSL sockets after the handshake has completed. |
| 150 // |socketId| : The socketId. | 167 // |socketId| : The socketId. |
| 151 // |enable| : If true, enable keep-alive functionality. | 168 // |enable| : If true, enable keep-alive functionality. |
| 152 // |delay| : Set the delay seconds between the last data packet received | 169 // |delay| : Set the delay seconds between the last data packet received |
| 153 // and the first keepalive probe. Default is 0. | 170 // and the first keepalive probe. Default is 0. |
| 154 // |callback| : Called when the setKeepAlive attempt is complete. | 171 // |callback| : Called when the setKeepAlive attempt is complete. |
| 155 static void setKeepAlive(long socketId, | 172 static void setKeepAlive(long socketId, |
| 156 boolean enable, | 173 boolean enable, |
| 157 optional long delay, | 174 optional long delay, |
| 158 SetKeepAliveCallback callback); | 175 SetKeepAliveCallback callback); |
| 159 | 176 |
| 160 // Enable/disable Nagle algorithm. | 177 // Enable/disable Nagle algorithm. Invalid on SSL sockets after the |
| 178 // handshake has completed. |
| 161 // |socketId| : The socketId. | 179 // |socketId| : The socketId. |
| 162 // |noDelay| : If true, disable Nagle algorithm. | 180 // |noDelay| : If true, disable Nagle algorithm. |
| 163 // |callback| : Called when the setNoDelay attempt is complete. | 181 // |callback| : Called when the setNoDelay attempt is complete. |
| 164 static void setNoDelay(long socketId, | 182 static void setNoDelay(long socketId, |
| 165 boolean noDelay, | 183 boolean noDelay, |
| 166 SetNoDelayCallback callback); | 184 SetNoDelayCallback callback); |
| 167 }; | 185 }; |
| 168 | 186 |
| 169 }; | 187 }; |
| OLD | NEW |