Chromium Code Reviews| 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 socket { | 7 namespace socket { |
| 8 enum SocketType { | 8 enum SocketType { |
| 9 tcp, | 9 tcp, |
| 10 udp | 10 udp |
| 11 }; | 11 }; |
| 12 | 12 |
| 13 // The socket options. | 13 // The socket options. |
| 14 dictionary CreateOptions { | 14 dictionary CreateOptions { |
| 15 }; | 15 }; |
| 16 | 16 |
| 17 dictionary CreateInfo { | 17 dictionary CreateInfo { |
| 18 // The id of the newly created socket. | 18 // The id of the newly created socket. |
| 19 long socketId; | 19 long socketId; |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 dictionary AcceptInfo { | |
| 23 long result; | |
| 24 long socketId; | |
| 25 }; | |
| 26 | |
| 22 callback CreateCallback = void (CreateInfo createInfo); | 27 callback CreateCallback = void (CreateInfo createInfo); |
| 23 | 28 |
| 24 callback ConnectCallback = void (long result); | 29 callback ConnectCallback = void (long result); |
| 25 | 30 |
| 26 callback BindCallback = void (long result); | 31 callback BindCallback = void (long result); |
| 27 | 32 |
| 33 callback AcceptCallback = void (AcceptInfo acceptInfo); | |
| 34 | |
| 28 dictionary ReadInfo { | 35 dictionary ReadInfo { |
| 29 // The resultCode returned from the underlying read() call. | 36 // The resultCode returned from the underlying read() call. |
| 30 long resultCode; | 37 long resultCode; |
| 31 | 38 |
| 32 ArrayBuffer data; | 39 ArrayBuffer data; |
| 33 }; | 40 }; |
| 34 | 41 |
| 35 callback ReadCallback = void (ReadInfo readInfo); | 42 callback ReadCallback = void (ReadInfo readInfo); |
| 36 | 43 |
| 37 dictionary WriteInfo { | 44 dictionary WriteInfo { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 // TCP socket. | 134 // TCP socket. |
| 128 // |socketId| : The socketId. | 135 // |socketId| : The socketId. |
| 129 // |address| : The address of the local machine. | 136 // |address| : The address of the local machine. |
| 130 // |port| : The port of the local machine. | 137 // |port| : The port of the local machine. |
| 131 // |callback| : Called when the bind attempt is complete. | 138 // |callback| : Called when the bind attempt is complete. |
| 132 static void bind(long socketId, | 139 static void bind(long socketId, |
| 133 DOMString address, | 140 DOMString address, |
| 134 long port, | 141 long port, |
| 135 BindCallback callback); | 142 BindCallback callback); |
| 136 | 143 |
| 144 static void listen(long socketId, | |
| 145 long backlog); | |
|
Peng
2012/08/18 12:17:12
No callback?
justinlin
2012/09/11 04:32:32
Done.
| |
| 146 | |
| 147 static void accept(long socketId, | |
| 148 AcceptCallback callback); | |
| 149 | |
| 137 // Disconnects the socket. For UDP sockets, <code>disconnect</code> is a | 150 // Disconnects the socket. For UDP sockets, <code>disconnect</code> is a |
| 138 // non-operation but is safe to call. | 151 // non-operation but is safe to call. |
| 139 // |socketId| : The socketId. | 152 // |socketId| : The socketId. |
| 140 static void disconnect(long socketId); | 153 static void disconnect(long socketId); |
| 141 | 154 |
| 142 // Reads data from the given connected socket. | 155 // Reads data from the given connected socket. |
| 143 // |socketId| : The socketId. | 156 // |socketId| : The socketId. |
| 144 // |bufferSize| : The read buffer size. | 157 // |bufferSize| : The read buffer size. |
| 145 // |callback| : Delivers data that was available to be read without | 158 // |callback| : Delivers data that was available to be read without |
| 146 // blocking. | 159 // blocking. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 SetNoDelayCallback callback); | 212 SetNoDelayCallback callback); |
| 200 | 213 |
| 201 // Retrieves the state of the given socket. | 214 // Retrieves the state of the given socket. |
| 202 // |socketId| : The socketId. | 215 // |socketId| : The socketId. |
| 203 // |callback| : Called when the state is available. | 216 // |callback| : Called when the state is available. |
| 204 static void getInfo(long socketId, | 217 static void getInfo(long socketId, |
| 205 GetInfoCallback callback); | 218 GetInfoCallback callback); |
| 206 }; | 219 }; |
| 207 | 220 |
| 208 }; | 221 }; |
| OLD | NEW |