| 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 | 8 |
| 9 // A socket event. | 9 // A socket event. |
| 10 dictionary SocketEvent { | 10 dictionary SocketEvent { |
| 11 // A connectComplete event reports the result of a connect that blocked. A | 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 | 12 // writeComplete event reports the result of a write that blocked. A |
| 13 // dataRead event reports bytes that have arrived following a read call | 13 // dataRead event reports bytes that have arrived following a read call |
| 14 // that blocked. | 14 // that blocked. |
| 15 DOMString type; | 15 DOMString type; |
| 16 | 16 |
| 17 // The result code, if the event type is writeComplete. The result code | 17 // The result code, if the event type is writeComplete. The result code |
| 18 // description matches that of <code>writeInfo.bytesWritten</code>. | 18 // description matches that of <code>writeInfo.bytesWritten</code>. |
| 19 long? resultCode; | 19 long? resultCode; |
| 20 | 20 |
| 21 // The data read, if the event type is dataRead. | 21 // The data read, if the event type is dataRead. |
| 22 DOMString? data; | 22 // TODO(miket): [instanceOf=ArrayBuffer]object? data; |
| 23 long[]? data; |
| 23 | 24 |
| 24 // Whether this is the final event that this socket will send. | 25 // Whether this is the final event that this socket will send. |
| 25 [nodoc] boolean isFinalEvent; | 26 [nodoc] boolean isFinalEvent; |
| 26 | 27 |
| 27 // An ID unique to the calling function's context so that events can get | 28 // An ID unique to the calling function's context so that events can get |
| 28 // routed back to the correct callback. | 29 // routed back to the correct callback. |
| 29 [nodoc] long? srcId; | 30 [nodoc] long? srcId; |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 callback OnEventCallback = void (SocketEvent event); | 33 callback OnEventCallback = void (SocketEvent event); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 46 long socketId; | 47 long socketId; |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 callback CreateCallback = void (CreateInfo createInfo); | 50 callback CreateCallback = void (CreateInfo createInfo); |
| 50 | 51 |
| 51 callback ConnectCallback = void (long result); | 52 callback ConnectCallback = void (long result); |
| 52 | 53 |
| 53 dictionary ReadInfo { | 54 dictionary ReadInfo { |
| 54 // The data received. Warning: will probably become a blob or other | 55 // The data received. Warning: will probably become a blob or other |
| 55 // appropriate binary-friendly type. | 56 // appropriate binary-friendly type. |
| 56 DOMString message; | 57 // TODO(miket): [instanceOf=ArrayBuffer]object data; |
| 58 long[] data; |
| 57 }; | 59 }; |
| 58 | 60 |
| 59 callback ReadCallback = void (ReadInfo readInfo); | 61 callback ReadCallback = void (ReadInfo readInfo); |
| 60 | 62 |
| 61 dictionary WriteInfo { | 63 dictionary WriteInfo { |
| 62 // The number of bytes sent, or a negative error code. | 64 // The number of bytes sent, or a negative error code. |
| 63 long bytesWritten; | 65 long bytesWritten; |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 callback WriteCallback = void (WriteInfo writeInfo); | 68 callback WriteCallback = void (WriteInfo writeInfo); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 ReadCallback callback); | 106 ReadCallback callback); |
| 105 | 107 |
| 106 // Writes data on the given socket. | 108 // Writes data on the given socket. |
| 107 // |socketId| : The socketId. | 109 // |socketId| : The socketId. |
| 108 // |data| : The data to write. Warning: will probably become a blob or other | 110 // |data| : The data to write. Warning: will probably become a blob or other |
| 109 // appropriate binary-friendly type. | 111 // appropriate binary-friendly type. |
| 110 // |callback| : Called when the first of any of the following happens: the | 112 // |callback| : Called when the first of any of the following happens: the |
| 111 // write operation completes without blocking, the write operation blocked | 113 // write operation completes without blocking, the write operation blocked |
| 112 // before completion (in which case onEvent() will eventually be called with | 114 // before completion (in which case onEvent() will eventually be called with |
| 113 // a <code>writeComplete</code> event), or an error occurred. | 115 // a <code>writeComplete</code> event), or an error occurred. |
| 116 // TODO(miket): [instanceOf=ArrayBuffer]object data; |
| 114 static void write(long socketId, | 117 static void write(long socketId, |
| 115 DOMString data, | 118 long[] data, |
| 116 WriteCallback callback); | 119 WriteCallback callback); |
| 117 }; | 120 }; |
| 118 | 121 |
| 119 interface Events { | 122 interface Events { |
| 120 // Used to pass events back to the socket creator. | 123 // Used to pass events back to the socket creator. |
| 121 // |event| : The event indicating socket status. | 124 // |event| : The event indicating socket status. |
| 122 static void onEvent(SocketEvent event); | 125 static void onEvent(SocketEvent event); |
| 123 }; | 126 }; |
| 124 | 127 |
| 125 }; | 128 }; |
| OLD | NEW |