Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: tools/dom/src/chrome/socket.dart

Issue 12316032: Added more Chrome.* libraries to dart:chrome (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added isMaximised override file Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/dom/src/chrome/serial.dart ('k') | tools/dom/src/chrome/sync_file_system.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Generated from namespace: socket
6
7 part of chrome;
8
9 /**
10 * Types
11 */
12
13 class SocketCreateOptions extends ChromeObject {
14 /*
15 * Public constructor
16 */
17 SocketCreateOptions({}) {
18 }
19
20 /*
21 * Private constructor
22 */
23 SocketCreateOptions._proxy(_jsObject) : super._proxy(_jsObject);
24 }
25
26 class SocketCreateInfo extends ChromeObject {
27 /*
28 * Public constructor
29 */
30 SocketCreateInfo({int socketId}) {
31 if (?socketId)
32 this.socketId = socketId;
33 }
34
35 /*
36 * Private constructor
37 */
38 SocketCreateInfo._proxy(_jsObject) : super._proxy(_jsObject);
39
40 /*
41 * Public accessors
42 */
43 /// The id of the newly created socket.
44 int get socketId => JS('int', '#.socketId', this._jsObject);
45
46 void set socketId(int socketId) {
47 JS('void', '#.socketId = #', this._jsObject, socketId);
48 }
49
50 }
51
52 class SocketAcceptInfo extends ChromeObject {
53 /*
54 * Public constructor
55 */
56 SocketAcceptInfo({int resultCode, int socketId}) {
57 if (?resultCode)
58 this.resultCode = resultCode;
59 if (?socketId)
60 this.socketId = socketId;
61 }
62
63 /*
64 * Private constructor
65 */
66 SocketAcceptInfo._proxy(_jsObject) : super._proxy(_jsObject);
67
68 /*
69 * Public accessors
70 */
71 int get resultCode => JS('int', '#.resultCode', this._jsObject);
72
73 void set resultCode(int resultCode) {
74 JS('void', '#.resultCode = #', this._jsObject, resultCode);
75 }
76
77 /// The id of the accepted socket.
78 int get socketId => JS('int', '#.socketId', this._jsObject);
79
80 void set socketId(int socketId) {
81 JS('void', '#.socketId = #', this._jsObject, socketId);
82 }
83
84 }
85
86 class SocketReadInfo extends ChromeObject {
87 /*
88 * Public constructor
89 */
90 SocketReadInfo({int resultCode, String data}) {
91 if (?resultCode)
92 this.resultCode = resultCode;
93 if (?data)
94 this.data = data;
95 }
96
97 /*
98 * Private constructor
99 */
100 SocketReadInfo._proxy(_jsObject) : super._proxy(_jsObject);
101
102 /*
103 * Public accessors
104 */
105 /// The resultCode returned from the underlying read() call.
106 int get resultCode => JS('int', '#.resultCode', this._jsObject);
107
108 void set resultCode(int resultCode) {
109 JS('void', '#.resultCode = #', this._jsObject, resultCode);
110 }
111
112 String get data => JS('String', '#.data', this._jsObject);
113
114 void set data(String data) {
115 JS('void', '#.data = #', this._jsObject, data);
116 }
117
118 }
119
120 class SocketWriteInfo extends ChromeObject {
121 /*
122 * Public constructor
123 */
124 SocketWriteInfo({int bytesWritten}) {
125 if (?bytesWritten)
126 this.bytesWritten = bytesWritten;
127 }
128
129 /*
130 * Private constructor
131 */
132 SocketWriteInfo._proxy(_jsObject) : super._proxy(_jsObject);
133
134 /*
135 * Public accessors
136 */
137 /// The number of bytes sent, or a negative error code.
138 int get bytesWritten => JS('int', '#.bytesWritten', this._jsObject);
139
140 void set bytesWritten(int bytesWritten) {
141 JS('void', '#.bytesWritten = #', this._jsObject, bytesWritten);
142 }
143
144 }
145
146 class SocketRecvFromInfo extends ChromeObject {
147 /*
148 * Public constructor
149 */
150 SocketRecvFromInfo({int resultCode, String data, String address, int port}) {
151 if (?resultCode)
152 this.resultCode = resultCode;
153 if (?data)
154 this.data = data;
155 if (?address)
156 this.address = address;
157 if (?port)
158 this.port = port;
159 }
160
161 /*
162 * Private constructor
163 */
164 SocketRecvFromInfo._proxy(_jsObject) : super._proxy(_jsObject);
165
166 /*
167 * Public accessors
168 */
169 /// The resultCode returned from the underlying recvfrom() call.
170 int get resultCode => JS('int', '#.resultCode', this._jsObject);
171
172 void set resultCode(int resultCode) {
173 JS('void', '#.resultCode = #', this._jsObject, resultCode);
174 }
175
176 String get data => JS('String', '#.data', this._jsObject);
177
178 void set data(String data) {
179 JS('void', '#.data = #', this._jsObject, data);
180 }
181
182 /// The address of the remote machine.
183 String get address => JS('String', '#.address', this._jsObject);
184
185 void set address(String address) {
186 JS('void', '#.address = #', this._jsObject, address);
187 }
188
189 int get port => JS('int', '#.port', this._jsObject);
190
191 void set port(int port) {
192 JS('void', '#.port = #', this._jsObject, port);
193 }
194
195 }
196
197 class SocketSocketInfo extends ChromeObject {
198 /*
199 * Public constructor
200 */
201 SocketSocketInfo({String socketType, bool connected, String peerAddress, int p eerPort, String localAddress, int localPort}) {
202 if (?socketType)
203 this.socketType = socketType;
204 if (?connected)
205 this.connected = connected;
206 if (?peerAddress)
207 this.peerAddress = peerAddress;
208 if (?peerPort)
209 this.peerPort = peerPort;
210 if (?localAddress)
211 this.localAddress = localAddress;
212 if (?localPort)
213 this.localPort = localPort;
214 }
215
216 /*
217 * Private constructor
218 */
219 SocketSocketInfo._proxy(_jsObject) : super._proxy(_jsObject);
220
221 /*
222 * Public accessors
223 */
224 /// The type of the passed socket. This will be <code>tcp</code> or
225 /// <code>udp</code>.
226 String get socketType => JS('String', '#.socketType', this._jsObject);
227
228 void set socketType(String socketType) {
229 JS('void', '#.socketType = #', this._jsObject, socketType);
230 }
231
232 /// Whether or not the underlying socket is connected.<br/><br/> For
233 /// <code>tcp</code> sockets, this will remain true even if the remote peer ha s
234 /// disconnected. Reading or writing to the socket may then result in an error ,
235 /// hinting that this socket should be disconnected via
236 /// <code>disconnect()</code>.<br/><br/> For <code>udp</code> sockets, this
237 /// just represents whether a default remote address has been specified for
238 /// reading and writing packets.
239 bool get connected => JS('bool', '#.connected', this._jsObject);
240
241 void set connected(bool connected) {
242 JS('void', '#.connected = #', this._jsObject, connected);
243 }
244
245 /// If the underlying socket is connected, contains the IPv4/6 address of the
246 /// peer.
247 String get peerAddress => JS('String', '#.peerAddress', this._jsObject);
248
249 void set peerAddress(String peerAddress) {
250 JS('void', '#.peerAddress = #', this._jsObject, peerAddress);
251 }
252
253 /// If the underlying socket is connected, contains the port of the connected
254 /// peer.
255 int get peerPort => JS('int', '#.peerPort', this._jsObject);
256
257 void set peerPort(int peerPort) {
258 JS('void', '#.peerPort = #', this._jsObject, peerPort);
259 }
260
261 /// If the underlying socket is bound or connected, contains its local IPv4/6
262 /// address.
263 String get localAddress => JS('String', '#.localAddress', this._jsObject);
264
265 void set localAddress(String localAddress) {
266 JS('void', '#.localAddress = #', this._jsObject, localAddress);
267 }
268
269 /// If the underlying socket is bound or connected, contains its local port.
270 int get localPort => JS('int', '#.localPort', this._jsObject);
271
272 void set localPort(int localPort) {
273 JS('void', '#.localPort = #', this._jsObject, localPort);
274 }
275
276 }
277
278 class SocketNetworkInterface extends ChromeObject {
279 /*
280 * Public constructor
281 */
282 SocketNetworkInterface({String name, String address}) {
283 if (?name)
284 this.name = name;
285 if (?address)
286 this.address = address;
287 }
288
289 /*
290 * Private constructor
291 */
292 SocketNetworkInterface._proxy(_jsObject) : super._proxy(_jsObject);
293
294 /*
295 * Public accessors
296 */
297 /// The underlying name of the adapter. On *nix, this will typically be "eth0" ,
298 /// "lo", etc.
299 String get name => JS('String', '#.name', this._jsObject);
300
301 void set name(String name) {
302 JS('void', '#.name = #', this._jsObject, name);
303 }
304
305 /// The available IPv4/6 address.
306 String get address => JS('String', '#.address', this._jsObject);
307
308 void set address(String address) {
309 JS('void', '#.address = #', this._jsObject, address);
310 }
311
312 }
313
314 /**
315 * Functions
316 */
317
318 class API_socket {
319 /*
320 * API connection
321 */
322 Object _jsObject;
323
324 /*
325 * Functions
326 */
327 /// Creates a socket of the specified type that will connect to the specified
328 /// remote machine.
329 void create(String type, void callback(SocketCreateInfo createInfo), [SocketCr eateOptions options]) {
330 void __proxy_callback(createInfo) {
331 if (?callback) {
332 callback(new SocketCreateInfo._proxy(createInfo));
333 }
334 }
335 JS('void', '#.create(#, #, #)', this._jsObject, type, convertArgument(option s), convertDartClosureToJS(__proxy_callback, 1));
336 }
337
338 /// Destroys the socket. Each socket created should be destroyed after use.
339 void destroy(int socketId) => JS('void', '#.destroy(#)', this._jsObject, socke tId);
340
341 /// Connects the socket to the remote machine (for a <code>tcp</code> socket).
342 /// For a <code>udp</code> socket, this sets the default address which packets
343 /// are sent to and read from for <code>read()</code> and <code>write()</code>
344 /// calls.
345 void connect(int socketId, String hostname, int port, void callback(int result )) => JS('void', '#.connect(#, #, #, #)', this._jsObject, socketId, hostname, po rt, convertDartClosureToJS(callback, 1));
346
347 /// Binds the local address for socket. Currently, it does not support TCP
348 /// socket.
349 void bind(int socketId, String address, int port, void callback(int result)) = > JS('void', '#.bind(#, #, #, #)', this._jsObject, socketId, address, port, conv ertDartClosureToJS(callback, 1));
350
351 /// Disconnects the socket. For UDP sockets, <code>disconnect</code> is a
352 /// non-operation but is safe to call.
353 void disconnect(int socketId) => JS('void', '#.disconnect(#)', this._jsObject, socketId);
354
355 /// Reads data from the given connected socket.
356 void read(int socketId, void callback(SocketReadInfo readInfo), [int bufferSiz e]) {
357 void __proxy_callback(readInfo) {
358 if (?callback) {
359 callback(new SocketReadInfo._proxy(readInfo));
360 }
361 }
362 JS('void', '#.read(#, #, #)', this._jsObject, socketId, bufferSize, convertD artClosureToJS(__proxy_callback, 1));
363 }
364
365 /// Writes data on the given connected socket.
366 void write(int socketId, String data, void callback(SocketWriteInfo writeInfo) ) {
367 void __proxy_callback(writeInfo) {
368 if (?callback) {
369 callback(new SocketWriteInfo._proxy(writeInfo));
370 }
371 }
372 JS('void', '#.write(#, #, #)', this._jsObject, socketId, data, convertDartCl osureToJS(__proxy_callback, 1));
373 }
374
375 /// Receives data from the given UDP socket.
376 void recvFrom(int socketId, void callback(SocketRecvFromInfo recvFromInfo), [i nt bufferSize]) {
377 void __proxy_callback(recvFromInfo) {
378 if (?callback) {
379 callback(new SocketRecvFromInfo._proxy(recvFromInfo));
380 }
381 }
382 JS('void', '#.recvFrom(#, #, #)', this._jsObject, socketId, bufferSize, conv ertDartClosureToJS(__proxy_callback, 1));
383 }
384
385 /// Sends data on the given UDP socket to the given address and port.
386 void sendTo(int socketId, String data, String address, int port, void callback (SocketWriteInfo writeInfo)) {
387 void __proxy_callback(writeInfo) {
388 if (?callback) {
389 callback(new SocketWriteInfo._proxy(writeInfo));
390 }
391 }
392 JS('void', '#.sendTo(#, #, #, #, #)', this._jsObject, socketId, data, addres s, port, convertDartClosureToJS(__proxy_callback, 1));
393 }
394
395 /// This method applies to TCP sockets only. Listens for connections on the
396 /// specified port and address. This effectively makes this a server socket,
397 /// and client socket functions (connect, read, write) can no longer be used o n
398 /// this socket.
399 void listen(int socketId, String address, int port, void callback(int result), [int backlog]) => JS('void', '#.listen(#, #, #, #, #)', this._jsObject, socketI d, address, port, backlog, convertDartClosureToJS(callback, 1));
400
401 /// This method applies to TCP sockets only. Registers a callback function to
402 /// be called when a connection is accepted on this listening server socket.
403 /// Listen must be called first. If there is already an active accept callback ,
404 /// this callback will be invoked immediately with an error as the resultCode.
405 void accept(int socketId, void callback(SocketAcceptInfo acceptInfo)) {
406 void __proxy_callback(acceptInfo) {
407 if (?callback) {
408 callback(new SocketAcceptInfo._proxy(acceptInfo));
409 }
410 }
411 JS('void', '#.accept(#, #)', this._jsObject, socketId, convertDartClosureToJ S(__proxy_callback, 1));
412 }
413
414 /// Enables or disables the keep-alive functionality for a TCP connection.
415 void setKeepAlive(int socketId, bool enable, void callback(bool result), [int delay]) => JS('void', '#.setKeepAlive(#, #, #, #)', this._jsObject, socketId, en able, delay, convertDartClosureToJS(callback, 1));
416
417 /// Sets or clears <code>TCP_NODELAY</code> for a TCP connection. Nagle's
418 /// algorithm will be disabled when <code>TCP_NODELAY</code> is set.
419 void setNoDelay(int socketId, bool noDelay, void callback(bool result)) => JS( 'void', '#.setNoDelay(#, #, #)', this._jsObject, socketId, noDelay, convertDartC losureToJS(callback, 1));
420
421 /// Retrieves the state of the given socket.
422 void getInfo(int socketId, void callback(SocketSocketInfo result)) {
423 void __proxy_callback(result) {
424 if (?callback) {
425 callback(new SocketSocketInfo._proxy(result));
426 }
427 }
428 JS('void', '#.getInfo(#, #)', this._jsObject, socketId, convertDartClosureTo JS(__proxy_callback, 1));
429 }
430
431 /// Retrieves information about local adapters on this system.
432 void getNetworkList(void callback(List<SocketNetworkInterface> result)) {
433 void __proxy_callback(result) {
434 if (?callback) {
435 List<SocketNetworkInterface> __proxy_result = new List<SocketNetworkInte rface>();
436 for (var o in result) {
437 __proxy_result.add(new SocketNetworkInterface._proxy(o));
438 }
439 callback(__proxy_result);
440 }
441 }
442 JS('void', '#.getNetworkList(#)', this._jsObject, convertDartClosureToJS(__p roxy_callback, 1));
443 }
444
445 API_socket(this._jsObject) {
446 }
447 }
OLDNEW
« no previous file with comments | « tools/dom/src/chrome/serial.dart ('k') | tools/dom/src/chrome/sync_file_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698