| 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 [nodoc] namespace experimental.socket { | 7 [nodoc] namespace experimental.socket { |
| 8 | |
| 9 // A socket event. | |
| 10 dictionary SocketEvent { | |
| 11 // A connectComplete event reports the result of a connect that blocked. A | |
| 12 // writeComplete event reports the result of a write that blocked. A | |
| 13 // dataRead event reports bytes that have arrived following a read call | |
| 14 // that blocked. | |
| 15 DOMString type; | |
| 16 | |
| 17 // The result code, if the event type is dataRead or writeComplete. The | |
| 18 // result code description matches the resultCode field in the immediate | |
| 19 // callback for the call that led to this event. | |
| 20 long? resultCode; | |
| 21 | |
| 22 // The data read, if the event type is dataRead. | |
| 23 // TODO(miket): [instanceOf=ArrayBuffer]object? data; | |
| 24 long[]? data; | |
| 25 | |
| 26 // Whether this is the final event that this socket will send. | |
| 27 [nodoc] boolean isFinalEvent; | |
| 28 | |
| 29 // An ID unique to the calling function's context so that events can get | |
| 30 // routed back to the correct callback. | |
| 31 [nodoc] long? srcId; | |
| 32 }; | |
| 33 | |
| 34 callback OnEventCallback = void (SocketEvent event); | |
| 35 | |
| 36 // The socket options. | 8 // The socket options. |
| 37 dictionary CreateOptions { | 9 dictionary CreateOptions { |
| 38 // This function is called with events that occur during the lifetime of | 10 // The schema generator does not support dictionaries without any fields. |
| 39 // the socket. | 11 // Ignore this field. |
| 40 OnEventCallback? onEvent; | 12 [nodoc] long? dummyValue; |
| 41 }; | 13 }; |
| 42 | 14 |
| 43 dictionary CreateInfo { | 15 dictionary CreateInfo { |
| 44 // The id of the newly created socket. | 16 // The id of the newly created socket. |
| 45 long socketId; | 17 long socketId; |
| 46 }; | 18 }; |
| 47 | 19 |
| 48 callback CreateCallback = void (CreateInfo createInfo); | 20 callback CreateCallback = void (CreateInfo createInfo); |
| 49 | 21 |
| 50 callback ConnectCallback = void (long result); | 22 callback ConnectCallback = void (long result); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // write operation completes without blocking, the write operation blocked | 136 // write operation completes without blocking, the write operation blocked |
| 165 // before completion (in which case onEvent() will eventually be called with | 137 // before completion (in which case onEvent() will eventually be called with |
| 166 // a <code>writeComplete</code> event), or an error occurred. | 138 // a <code>writeComplete</code> event), or an error occurred. |
| 167 static void sendTo(long socketId, | 139 static void sendTo(long socketId, |
| 168 long[] data, | 140 long[] data, |
| 169 DOMString address, | 141 DOMString address, |
| 170 long port, | 142 long port, |
| 171 SendToCallback callback); | 143 SendToCallback callback); |
| 172 }; | 144 }; |
| 173 | 145 |
| 174 interface Events { | |
| 175 // Used to pass events back to the socket creator. | |
| 176 // |event| : The event indicating socket status. | |
| 177 static void onEvent(SocketEvent event); | |
| 178 }; | |
| 179 | |
| 180 }; | 146 }; |
| OLD | NEW |