| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 library tcp_bound_socket_mojom; | 5 library tcp_bound_socket_mojom; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'package:mojo/bindings.dart' as bindings; | 7 import 'package:mojo/bindings.dart' as bindings; |
| 8 import 'package:mojo/core.dart' as core; | 8 import 'package:mojo/core.dart' as core; |
| 9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; | 9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; |
| 10 import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; | 10 import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; |
| 11 import 'package:mojo_services/mojo/net_address.mojom.dart' as net_address_mojom; | 11 import 'package:mojo_services/mojo/net_address.mojom.dart' as net_address_mojom; |
| 12 import 'package:mojo_services/mojo/tcp_connected_socket.mojom.dart' as tcp_conne
cted_socket_mojom; | 12 import 'package:mojo_services/mojo/tcp_connected_socket.mojom.dart' as tcp_conne
cted_socket_mojom; |
| 13 import 'package:mojo_services/mojo/tcp_server_socket.mojom.dart' as tcp_server_s
ocket_mojom; | 13 import 'package:mojo_services/mojo/tcp_server_socket.mojom.dart' as tcp_server_s
ocket_mojom; |
| 14 | 14 |
| 15 | 15 |
| 16 | 16 |
| 17 class _TcpBoundSocketStartListeningParams extends bindings.Struct { | 17 class _TcpBoundSocketStartListeningParams extends bindings.Struct { |
| 18 static const List<bindings.StructDataHeader> kVersions = const [ | 18 static const List<bindings.StructDataHeader> kVersions = const [ |
| 19 const bindings.StructDataHeader(16, 0) | 19 const bindings.StructDataHeader(16, 0) |
| 20 ]; | 20 ]; |
| 21 tcp_server_socket_mojom.TcpServerSocketInterfaceRequest server = null; | 21 tcp_server_socket_mojom.TcpServerSocketInterfaceRequest server = null; |
| 22 | 22 |
| 23 _TcpBoundSocketStartListeningParams() : super(kVersions.last.size); | 23 _TcpBoundSocketStartListeningParams() : super(kVersions.last.size); |
| 24 | 24 |
| 25 _TcpBoundSocketStartListeningParams.init( |
| 26 tcp_server_socket_mojom.TcpServerSocketInterfaceRequest this.server |
| 27 ) : super(kVersions.last.size); |
| 28 |
| 25 static _TcpBoundSocketStartListeningParams deserialize(bindings.Message messag
e) { | 29 static _TcpBoundSocketStartListeningParams deserialize(bindings.Message messag
e) { |
| 26 var decoder = new bindings.Decoder(message); | 30 var decoder = new bindings.Decoder(message); |
| 27 var result = decode(decoder); | 31 var result = decode(decoder); |
| 28 if (decoder.excessHandles != null) { | 32 if (decoder.excessHandles != null) { |
| 29 decoder.excessHandles.forEach((h) => h.close()); | 33 decoder.excessHandles.forEach((h) => h.close()); |
| 30 } | 34 } |
| 31 return result; | 35 return result; |
| 32 } | 36 } |
| 33 | 37 |
| 34 static _TcpBoundSocketStartListeningParams decode(bindings.Decoder decoder0) { | 38 static _TcpBoundSocketStartListeningParams decode(bindings.Decoder decoder0) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 90 |
| 87 | 91 |
| 88 class TcpBoundSocketStartListeningResponseParams extends bindings.Struct { | 92 class TcpBoundSocketStartListeningResponseParams extends bindings.Struct { |
| 89 static const List<bindings.StructDataHeader> kVersions = const [ | 93 static const List<bindings.StructDataHeader> kVersions = const [ |
| 90 const bindings.StructDataHeader(16, 0) | 94 const bindings.StructDataHeader(16, 0) |
| 91 ]; | 95 ]; |
| 92 network_error_mojom.NetworkError result = null; | 96 network_error_mojom.NetworkError result = null; |
| 93 | 97 |
| 94 TcpBoundSocketStartListeningResponseParams() : super(kVersions.last.size); | 98 TcpBoundSocketStartListeningResponseParams() : super(kVersions.last.size); |
| 95 | 99 |
| 100 TcpBoundSocketStartListeningResponseParams.init( |
| 101 network_error_mojom.NetworkError this.result |
| 102 ) : super(kVersions.last.size); |
| 103 |
| 96 static TcpBoundSocketStartListeningResponseParams deserialize(bindings.Message
message) { | 104 static TcpBoundSocketStartListeningResponseParams deserialize(bindings.Message
message) { |
| 97 var decoder = new bindings.Decoder(message); | 105 var decoder = new bindings.Decoder(message); |
| 98 var result = decode(decoder); | 106 var result = decode(decoder); |
| 99 if (decoder.excessHandles != null) { | 107 if (decoder.excessHandles != null) { |
| 100 decoder.excessHandles.forEach((h) => h.close()); | 108 decoder.excessHandles.forEach((h) => h.close()); |
| 101 } | 109 } |
| 102 return result; | 110 return result; |
| 103 } | 111 } |
| 104 | 112 |
| 105 static TcpBoundSocketStartListeningResponseParams decode(bindings.Decoder deco
der0) { | 113 static TcpBoundSocketStartListeningResponseParams decode(bindings.Decoder deco
der0) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 static const List<bindings.StructDataHeader> kVersions = const [ | 170 static const List<bindings.StructDataHeader> kVersions = const [ |
| 163 const bindings.StructDataHeader(32, 0) | 171 const bindings.StructDataHeader(32, 0) |
| 164 ]; | 172 ]; |
| 165 net_address_mojom.NetAddress remoteAddress = null; | 173 net_address_mojom.NetAddress remoteAddress = null; |
| 166 core.MojoDataPipeConsumer sendStream = null; | 174 core.MojoDataPipeConsumer sendStream = null; |
| 167 core.MojoDataPipeProducer receiveStream = null; | 175 core.MojoDataPipeProducer receiveStream = null; |
| 168 tcp_connected_socket_mojom.TcpConnectedSocketInterfaceRequest clientSocket = n
ull; | 176 tcp_connected_socket_mojom.TcpConnectedSocketInterfaceRequest clientSocket = n
ull; |
| 169 | 177 |
| 170 _TcpBoundSocketConnectParams() : super(kVersions.last.size); | 178 _TcpBoundSocketConnectParams() : super(kVersions.last.size); |
| 171 | 179 |
| 180 _TcpBoundSocketConnectParams.init( |
| 181 net_address_mojom.NetAddress this.remoteAddress, |
| 182 core.MojoDataPipeConsumer this.sendStream, |
| 183 core.MojoDataPipeProducer this.receiveStream, |
| 184 tcp_connected_socket_mojom.TcpConnectedSocketInterfaceRequest this.clientSoc
ket |
| 185 ) : super(kVersions.last.size); |
| 186 |
| 172 static _TcpBoundSocketConnectParams deserialize(bindings.Message message) { | 187 static _TcpBoundSocketConnectParams deserialize(bindings.Message message) { |
| 173 var decoder = new bindings.Decoder(message); | 188 var decoder = new bindings.Decoder(message); |
| 174 var result = decode(decoder); | 189 var result = decode(decoder); |
| 175 if (decoder.excessHandles != null) { | 190 if (decoder.excessHandles != null) { |
| 176 decoder.excessHandles.forEach((h) => h.close()); | 191 decoder.excessHandles.forEach((h) => h.close()); |
| 177 } | 192 } |
| 178 return result; | 193 return result; |
| 179 } | 194 } |
| 180 | 195 |
| 181 static _TcpBoundSocketConnectParams decode(bindings.Decoder decoder0) { | 196 static _TcpBoundSocketConnectParams decode(bindings.Decoder decoder0) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 285 |
| 271 | 286 |
| 272 class TcpBoundSocketConnectResponseParams extends bindings.Struct { | 287 class TcpBoundSocketConnectResponseParams extends bindings.Struct { |
| 273 static const List<bindings.StructDataHeader> kVersions = const [ | 288 static const List<bindings.StructDataHeader> kVersions = const [ |
| 274 const bindings.StructDataHeader(16, 0) | 289 const bindings.StructDataHeader(16, 0) |
| 275 ]; | 290 ]; |
| 276 network_error_mojom.NetworkError result = null; | 291 network_error_mojom.NetworkError result = null; |
| 277 | 292 |
| 278 TcpBoundSocketConnectResponseParams() : super(kVersions.last.size); | 293 TcpBoundSocketConnectResponseParams() : super(kVersions.last.size); |
| 279 | 294 |
| 295 TcpBoundSocketConnectResponseParams.init( |
| 296 network_error_mojom.NetworkError this.result |
| 297 ) : super(kVersions.last.size); |
| 298 |
| 280 static TcpBoundSocketConnectResponseParams deserialize(bindings.Message messag
e) { | 299 static TcpBoundSocketConnectResponseParams deserialize(bindings.Message messag
e) { |
| 281 var decoder = new bindings.Decoder(message); | 300 var decoder = new bindings.Decoder(message); |
| 282 var result = decode(decoder); | 301 var result = decode(decoder); |
| 283 if (decoder.excessHandles != null) { | 302 if (decoder.excessHandles != null) { |
| 284 decoder.excessHandles.forEach((h) => h.close()); | 303 decoder.excessHandles.forEach((h) => h.close()); |
| 285 } | 304 } |
| 286 return result; | 305 return result; |
| 287 } | 306 } |
| 288 | 307 |
| 289 static TcpBoundSocketConnectResponseParams decode(bindings.Decoder decoder0) { | 308 static TcpBoundSocketConnectResponseParams decode(bindings.Decoder decoder0) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 Map map = new Map(); | 357 Map map = new Map(); |
| 339 map["result"] = result; | 358 map["result"] = result; |
| 340 return map; | 359 return map; |
| 341 } | 360 } |
| 342 } | 361 } |
| 343 | 362 |
| 344 const int _tcpBoundSocketMethodStartListeningName = 0; | 363 const int _tcpBoundSocketMethodStartListeningName = 0; |
| 345 const int _tcpBoundSocketMethodConnectName = 1; | 364 const int _tcpBoundSocketMethodConnectName = 1; |
| 346 | 365 |
| 347 class _TcpBoundSocketServiceDescription implements service_describer.ServiceDesc
ription { | 366 class _TcpBoundSocketServiceDescription implements service_describer.ServiceDesc
ription { |
| 348 dynamic getTopLevelInterface([Function responseFactory]) => | 367 void getTopLevelInterface(Function responder) { |
| 349 responseFactory(null); | 368 responder(null); |
| 369 } |
| 350 | 370 |
| 351 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => | 371 void getTypeDefinition(String typeKey, Function responder) { |
| 352 responseFactory(null); | 372 responder(null); |
| 373 } |
| 353 | 374 |
| 354 dynamic getAllTypeDefinitions([Function responseFactory]) => | 375 void getAllTypeDefinitions(Function responder) { |
| 355 responseFactory(null); | 376 responder(null); |
| 377 } |
| 356 } | 378 } |
| 357 | 379 |
| 358 abstract class TcpBoundSocket { | 380 abstract class TcpBoundSocket { |
| 359 static const String serviceName = null; | 381 static const String serviceName = null; |
| 360 | 382 |
| 361 static service_describer.ServiceDescription _cachedServiceDescription; | 383 static service_describer.ServiceDescription _cachedServiceDescription; |
| 362 static service_describer.ServiceDescription get serviceDescription { | 384 static service_describer.ServiceDescription get serviceDescription { |
| 363 if (_cachedServiceDescription == null) { | 385 if (_cachedServiceDescription == null) { |
| 364 _cachedServiceDescription = new _TcpBoundSocketServiceDescription(); | 386 _cachedServiceDescription = new _TcpBoundSocketServiceDescription(); |
| 365 } | 387 } |
| 366 return _cachedServiceDescription; | 388 return _cachedServiceDescription; |
| 367 } | 389 } |
| 368 | 390 |
| 369 static TcpBoundSocketProxy connectToService( | 391 static TcpBoundSocketProxy connectToService( |
| 370 bindings.ServiceConnector s, String url, [String serviceName]) { | 392 bindings.ServiceConnector s, String url, [String serviceName]) { |
| 371 TcpBoundSocketProxy p = new TcpBoundSocketProxy.unbound(); | 393 TcpBoundSocketProxy p = new TcpBoundSocketProxy.unbound(); |
| 372 String name = serviceName ?? TcpBoundSocket.serviceName; | 394 String name = serviceName ?? TcpBoundSocket.serviceName; |
| 373 if ((name == null) || name.isEmpty) { | 395 if ((name == null) || name.isEmpty) { |
| 374 throw new core.MojoApiError( | 396 throw new core.MojoApiError( |
| 375 "If an interface has no ServiceName, then one must be provided."); | 397 "If an interface has no ServiceName, then one must be provided."); |
| 376 } | 398 } |
| 377 s.connectToService(url, p, name); | 399 s.connectToService(url, p, name); |
| 378 return p; | 400 return p; |
| 379 } | 401 } |
| 380 dynamic startListening(tcp_server_socket_mojom.TcpServerSocketInterfaceRequest
server,[Function responseFactory = null]); | 402 void startListening(tcp_server_socket_mojom.TcpServerSocketInterfaceRequest se
rver,void callback(network_error_mojom.NetworkError result)); |
| 381 dynamic connect(net_address_mojom.NetAddress remoteAddress,core.MojoDataPipeCo
nsumer sendStream,core.MojoDataPipeProducer receiveStream,tcp_connected_socket_m
ojom.TcpConnectedSocketInterfaceRequest clientSocket,[Function responseFactory =
null]); | 403 void connect(net_address_mojom.NetAddress remoteAddress,core.MojoDataPipeConsu
mer sendStream,core.MojoDataPipeProducer receiveStream,tcp_connected_socket_mojo
m.TcpConnectedSocketInterfaceRequest clientSocket,void callback(network_error_mo
jom.NetworkError result)); |
| 382 } | 404 } |
| 383 | 405 |
| 384 abstract class TcpBoundSocketInterface | 406 abstract class TcpBoundSocketInterface |
| 385 implements bindings.MojoInterface<TcpBoundSocket>, | 407 implements bindings.MojoInterface<TcpBoundSocket>, |
| 386 TcpBoundSocket { | 408 TcpBoundSocket { |
| 387 factory TcpBoundSocketInterface([TcpBoundSocket impl]) => | 409 factory TcpBoundSocketInterface([TcpBoundSocket impl]) => |
| 388 new TcpBoundSocketStub.unbound(impl); | 410 new TcpBoundSocketStub.unbound(impl); |
| 389 | 411 |
| 390 factory TcpBoundSocketInterface.fromEndpoint( | 412 factory TcpBoundSocketInterface.fromEndpoint( |
| 391 core.MojoMessagePipeEndpoint endpoint, | 413 core.MojoMessagePipeEndpoint endpoint, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 421 | 443 |
| 422 void handleResponse(bindings.ServiceMessage message) { | 444 void handleResponse(bindings.ServiceMessage message) { |
| 423 switch (message.header.type) { | 445 switch (message.header.type) { |
| 424 case _tcpBoundSocketMethodStartListeningName: | 446 case _tcpBoundSocketMethodStartListeningName: |
| 425 var r = TcpBoundSocketStartListeningResponseParams.deserialize( | 447 var r = TcpBoundSocketStartListeningResponseParams.deserialize( |
| 426 message.payload); | 448 message.payload); |
| 427 if (!message.header.hasRequestId) { | 449 if (!message.header.hasRequestId) { |
| 428 proxyError("Expected a message with a valid request Id."); | 450 proxyError("Expected a message with a valid request Id."); |
| 429 return; | 451 return; |
| 430 } | 452 } |
| 431 Completer c = completerMap[message.header.requestId]; | 453 Function callback = callbackMap[message.header.requestId]; |
| 432 if (c == null) { | 454 if (callback == null) { |
| 433 proxyError( | 455 proxyError( |
| 434 "Message had unknown request Id: ${message.header.requestId}"); | 456 "Message had unknown request Id: ${message.header.requestId}"); |
| 435 return; | 457 return; |
| 436 } | 458 } |
| 437 completerMap.remove(message.header.requestId); | 459 callbackMap.remove(message.header.requestId); |
| 438 if (c.isCompleted) { | 460 callback(r.result ); |
| 439 proxyError("Response completer already completed"); | |
| 440 return; | |
| 441 } | |
| 442 c.complete(r); | |
| 443 break; | 461 break; |
| 444 case _tcpBoundSocketMethodConnectName: | 462 case _tcpBoundSocketMethodConnectName: |
| 445 var r = TcpBoundSocketConnectResponseParams.deserialize( | 463 var r = TcpBoundSocketConnectResponseParams.deserialize( |
| 446 message.payload); | 464 message.payload); |
| 447 if (!message.header.hasRequestId) { | 465 if (!message.header.hasRequestId) { |
| 448 proxyError("Expected a message with a valid request Id."); | 466 proxyError("Expected a message with a valid request Id."); |
| 449 return; | 467 return; |
| 450 } | 468 } |
| 451 Completer c = completerMap[message.header.requestId]; | 469 Function callback = callbackMap[message.header.requestId]; |
| 452 if (c == null) { | 470 if (callback == null) { |
| 453 proxyError( | 471 proxyError( |
| 454 "Message had unknown request Id: ${message.header.requestId}"); | 472 "Message had unknown request Id: ${message.header.requestId}"); |
| 455 return; | 473 return; |
| 456 } | 474 } |
| 457 completerMap.remove(message.header.requestId); | 475 callbackMap.remove(message.header.requestId); |
| 458 if (c.isCompleted) { | 476 callback(r.result ); |
| 459 proxyError("Response completer already completed"); | |
| 460 return; | |
| 461 } | |
| 462 c.complete(r); | |
| 463 break; | 477 break; |
| 464 default: | 478 default: |
| 465 proxyError("Unexpected message type: ${message.header.type}"); | 479 proxyError("Unexpected message type: ${message.header.type}"); |
| 466 close(immediate: true); | 480 close(immediate: true); |
| 467 break; | 481 break; |
| 468 } | 482 } |
| 469 } | 483 } |
| 470 | 484 |
| 471 @override | 485 @override |
| 472 String toString() { | 486 String toString() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 497 return newMockedProxy; | 511 return newMockedProxy; |
| 498 } | 512 } |
| 499 | 513 |
| 500 static TcpBoundSocketProxy newFromEndpoint( | 514 static TcpBoundSocketProxy newFromEndpoint( |
| 501 core.MojoMessagePipeEndpoint endpoint) { | 515 core.MojoMessagePipeEndpoint endpoint) { |
| 502 assert(endpoint.setDescription("For TcpBoundSocketProxy")); | 516 assert(endpoint.setDescription("For TcpBoundSocketProxy")); |
| 503 return new TcpBoundSocketProxy.fromEndpoint(endpoint); | 517 return new TcpBoundSocketProxy.fromEndpoint(endpoint); |
| 504 } | 518 } |
| 505 | 519 |
| 506 | 520 |
| 507 dynamic startListening(tcp_server_socket_mojom.TcpServerSocketInterfaceRequest
server,[Function responseFactory = null]) { | 521 void startListening(tcp_server_socket_mojom.TcpServerSocketInterfaceRequest se
rver,void callback(network_error_mojom.NetworkError result)) { |
| 508 if (impl != null) { | 522 if (impl != null) { |
| 509 return new Future(() => impl.startListening(server,_TcpBoundSocketStubCont
rol._tcpBoundSocketStartListeningResponseParamsFactory)); | 523 impl.startListening(server,callback); |
| 524 return; |
| 510 } | 525 } |
| 511 var params = new _TcpBoundSocketStartListeningParams(); | 526 var params = new _TcpBoundSocketStartListeningParams(); |
| 512 params.server = server; | 527 params.server = server; |
| 513 return ctrl.sendMessageWithRequestId( | 528 ctrl.sendMessageWithRequestId( |
| 514 params, | 529 params, |
| 515 _tcpBoundSocketMethodStartListeningName, | 530 _tcpBoundSocketMethodStartListeningName, |
| 516 -1, | 531 -1, |
| 517 bindings.MessageHeader.kMessageExpectsResponse); | 532 bindings.MessageHeader.kMessageExpectsResponse, |
| 533 callback); |
| 518 } | 534 } |
| 519 dynamic connect(net_address_mojom.NetAddress remoteAddress,core.MojoDataPipeCo
nsumer sendStream,core.MojoDataPipeProducer receiveStream,tcp_connected_socket_m
ojom.TcpConnectedSocketInterfaceRequest clientSocket,[Function responseFactory =
null]) { | 535 void connect(net_address_mojom.NetAddress remoteAddress,core.MojoDataPipeConsu
mer sendStream,core.MojoDataPipeProducer receiveStream,tcp_connected_socket_mojo
m.TcpConnectedSocketInterfaceRequest clientSocket,void callback(network_error_mo
jom.NetworkError result)) { |
| 520 if (impl != null) { | 536 if (impl != null) { |
| 521 return new Future(() => impl.connect(remoteAddress,sendStream,receiveStrea
m,clientSocket,_TcpBoundSocketStubControl._tcpBoundSocketConnectResponseParamsFa
ctory)); | 537 impl.connect(remoteAddress,sendStream,receiveStream,clientSocket,callback)
; |
| 538 return; |
| 522 } | 539 } |
| 523 var params = new _TcpBoundSocketConnectParams(); | 540 var params = new _TcpBoundSocketConnectParams(); |
| 524 params.remoteAddress = remoteAddress; | 541 params.remoteAddress = remoteAddress; |
| 525 params.sendStream = sendStream; | 542 params.sendStream = sendStream; |
| 526 params.receiveStream = receiveStream; | 543 params.receiveStream = receiveStream; |
| 527 params.clientSocket = clientSocket; | 544 params.clientSocket = clientSocket; |
| 528 return ctrl.sendMessageWithRequestId( | 545 ctrl.sendMessageWithRequestId( |
| 529 params, | 546 params, |
| 530 _tcpBoundSocketMethodConnectName, | 547 _tcpBoundSocketMethodConnectName, |
| 531 -1, | 548 -1, |
| 532 bindings.MessageHeader.kMessageExpectsResponse); | 549 bindings.MessageHeader.kMessageExpectsResponse, |
| 550 callback); |
| 533 } | 551 } |
| 534 } | 552 } |
| 535 | 553 |
| 536 class _TcpBoundSocketStubControl | 554 class _TcpBoundSocketStubControl |
| 537 extends bindings.StubMessageHandler | 555 extends bindings.StubMessageHandler |
| 538 implements bindings.StubControl<TcpBoundSocket> { | 556 implements bindings.StubControl<TcpBoundSocket> { |
| 539 TcpBoundSocket _impl; | 557 TcpBoundSocket _impl; |
| 540 | 558 |
| 541 _TcpBoundSocketStubControl.fromEndpoint( | 559 _TcpBoundSocketStubControl.fromEndpoint( |
| 542 core.MojoMessagePipeEndpoint endpoint, [TcpBoundSocket impl]) | 560 core.MojoMessagePipeEndpoint endpoint, [TcpBoundSocket impl]) |
| 543 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 561 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| 544 _impl = impl; | 562 _impl = impl; |
| 545 } | 563 } |
| 546 | 564 |
| 547 _TcpBoundSocketStubControl.fromHandle( | 565 _TcpBoundSocketStubControl.fromHandle( |
| 548 core.MojoHandle handle, [TcpBoundSocket impl]) | 566 core.MojoHandle handle, [TcpBoundSocket impl]) |
| 549 : super.fromHandle(handle, autoBegin: impl != null) { | 567 : super.fromHandle(handle, autoBegin: impl != null) { |
| 550 _impl = impl; | 568 _impl = impl; |
| 551 } | 569 } |
| 552 | 570 |
| 553 _TcpBoundSocketStubControl.unbound([this._impl]) : super.unbound(); | 571 _TcpBoundSocketStubControl.unbound([this._impl]) : super.unbound(); |
| 554 | 572 |
| 555 String get serviceName => TcpBoundSocket.serviceName; | 573 String get serviceName => TcpBoundSocket.serviceName; |
| 556 | 574 |
| 557 | 575 |
| 558 static TcpBoundSocketStartListeningResponseParams _tcpBoundSocketStartListenin
gResponseParamsFactory(network_error_mojom.NetworkError result) { | 576 Function _tcpBoundSocketStartListeningResponseParamsResponder( |
| 559 var result = new TcpBoundSocketStartListeningResponseParams(); | 577 int requestId) { |
| 560 result.result = result; | 578 return (network_error_mojom.NetworkError result) { |
| 561 return result; | 579 var result = new TcpBoundSocketStartListeningResponseParams(); |
| 580 result.result = result; |
| 581 sendResponse(buildResponseWithId( |
| 582 result, |
| 583 _tcpBoundSocketMethodStartListeningName, |
| 584 requestId, |
| 585 bindings.MessageHeader.kMessageIsResponse)); |
| 586 }; |
| 562 } | 587 } |
| 563 static TcpBoundSocketConnectResponseParams _tcpBoundSocketConnectResponseParam
sFactory(network_error_mojom.NetworkError result) { | 588 Function _tcpBoundSocketConnectResponseParamsResponder( |
| 564 var result = new TcpBoundSocketConnectResponseParams(); | 589 int requestId) { |
| 565 result.result = result; | 590 return (network_error_mojom.NetworkError result) { |
| 566 return result; | 591 var result = new TcpBoundSocketConnectResponseParams(); |
| 592 result.result = result; |
| 593 sendResponse(buildResponseWithId( |
| 594 result, |
| 595 _tcpBoundSocketMethodConnectName, |
| 596 requestId, |
| 597 bindings.MessageHeader.kMessageIsResponse)); |
| 598 }; |
| 567 } | 599 } |
| 568 | 600 |
| 569 dynamic handleMessage(bindings.ServiceMessage message) { | 601 void handleMessage(bindings.ServiceMessage message) { |
| 570 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 602 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 571 return bindings.ControlMessageHandler.handleMessage(this, | 603 bindings.ControlMessageHandler.handleMessage( |
| 572 0, | 604 this, 0, message); |
| 573 message); | 605 return; |
| 574 } | 606 } |
| 575 if (_impl == null) { | 607 if (_impl == null) { |
| 576 throw new core.MojoApiError("$this has no implementation set"); | 608 throw new core.MojoApiError("$this has no implementation set"); |
| 577 } | 609 } |
| 578 switch (message.header.type) { | 610 switch (message.header.type) { |
| 579 case _tcpBoundSocketMethodStartListeningName: | 611 case _tcpBoundSocketMethodStartListeningName: |
| 580 var params = _TcpBoundSocketStartListeningParams.deserialize( | 612 var params = _TcpBoundSocketStartListeningParams.deserialize( |
| 581 message.payload); | 613 message.payload); |
| 582 var response = _impl.startListening(params.server,_tcpBoundSocketStartLi
steningResponseParamsFactory); | 614 _impl.startListening(params.server, _tcpBoundSocketStartListeningRespons
eParamsResponder(message.header.requestId)); |
| 583 if (response is Future) { | |
| 584 return response.then((response) { | |
| 585 if (response != null) { | |
| 586 return buildResponseWithId( | |
| 587 response, | |
| 588 _tcpBoundSocketMethodStartListeningName, | |
| 589 message.header.requestId, | |
| 590 bindings.MessageHeader.kMessageIsResponse); | |
| 591 } | |
| 592 }); | |
| 593 } else if (response != null) { | |
| 594 return buildResponseWithId( | |
| 595 response, | |
| 596 _tcpBoundSocketMethodStartListeningName, | |
| 597 message.header.requestId, | |
| 598 bindings.MessageHeader.kMessageIsResponse); | |
| 599 } | |
| 600 break; | 615 break; |
| 601 case _tcpBoundSocketMethodConnectName: | 616 case _tcpBoundSocketMethodConnectName: |
| 602 var params = _TcpBoundSocketConnectParams.deserialize( | 617 var params = _TcpBoundSocketConnectParams.deserialize( |
| 603 message.payload); | 618 message.payload); |
| 604 var response = _impl.connect(params.remoteAddress,params.sendStream,para
ms.receiveStream,params.clientSocket,_tcpBoundSocketConnectResponseParamsFactory
); | 619 _impl.connect(params.remoteAddress, params.sendStream, params.receiveStr
eam, params.clientSocket, _tcpBoundSocketConnectResponseParamsResponder(message.
header.requestId)); |
| 605 if (response is Future) { | |
| 606 return response.then((response) { | |
| 607 if (response != null) { | |
| 608 return buildResponseWithId( | |
| 609 response, | |
| 610 _tcpBoundSocketMethodConnectName, | |
| 611 message.header.requestId, | |
| 612 bindings.MessageHeader.kMessageIsResponse); | |
| 613 } | |
| 614 }); | |
| 615 } else if (response != null) { | |
| 616 return buildResponseWithId( | |
| 617 response, | |
| 618 _tcpBoundSocketMethodConnectName, | |
| 619 message.header.requestId, | |
| 620 bindings.MessageHeader.kMessageIsResponse); | |
| 621 } | |
| 622 break; | 620 break; |
| 623 default: | 621 default: |
| 624 throw new bindings.MojoCodecError("Unexpected message name"); | 622 throw new bindings.MojoCodecError("Unexpected message name"); |
| 625 break; | 623 break; |
| 626 } | 624 } |
| 627 return null; | |
| 628 } | 625 } |
| 629 | 626 |
| 630 TcpBoundSocket get impl => _impl; | 627 TcpBoundSocket get impl => _impl; |
| 631 set impl(TcpBoundSocket d) { | 628 set impl(TcpBoundSocket d) { |
| 632 if (d == null) { | 629 if (d == null) { |
| 633 throw new core.MojoApiError("$this: Cannot set a null implementation"); | 630 throw new core.MojoApiError("$this: Cannot set a null implementation"); |
| 634 } | 631 } |
| 635 if (isBound && (_impl == null)) { | 632 if (isBound && (_impl == null)) { |
| 636 beginHandlingEvents(); | 633 beginHandlingEvents(); |
| 637 } | 634 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 core.MojoHandle handle, [TcpBoundSocket impl]) | 668 core.MojoHandle handle, [TcpBoundSocket impl]) |
| 672 : super(new _TcpBoundSocketStubControl.fromHandle(handle, impl)); | 669 : super(new _TcpBoundSocketStubControl.fromHandle(handle, impl)); |
| 673 | 670 |
| 674 static TcpBoundSocketStub newFromEndpoint( | 671 static TcpBoundSocketStub newFromEndpoint( |
| 675 core.MojoMessagePipeEndpoint endpoint) { | 672 core.MojoMessagePipeEndpoint endpoint) { |
| 676 assert(endpoint.setDescription("For TcpBoundSocketStub")); | 673 assert(endpoint.setDescription("For TcpBoundSocketStub")); |
| 677 return new TcpBoundSocketStub.fromEndpoint(endpoint); | 674 return new TcpBoundSocketStub.fromEndpoint(endpoint); |
| 678 } | 675 } |
| 679 | 676 |
| 680 | 677 |
| 681 dynamic startListening(tcp_server_socket_mojom.TcpServerSocketInterfaceRequest
server,[Function responseFactory = null]) { | 678 void startListening(tcp_server_socket_mojom.TcpServerSocketInterfaceRequest se
rver,void callback(network_error_mojom.NetworkError result)) { |
| 682 return impl.startListening(server,responseFactory); | 679 return impl.startListening(server,callback); |
| 683 } | 680 } |
| 684 dynamic connect(net_address_mojom.NetAddress remoteAddress,core.MojoDataPipeCo
nsumer sendStream,core.MojoDataPipeProducer receiveStream,tcp_connected_socket_m
ojom.TcpConnectedSocketInterfaceRequest clientSocket,[Function responseFactory =
null]) { | 681 void connect(net_address_mojom.NetAddress remoteAddress,core.MojoDataPipeConsu
mer sendStream,core.MojoDataPipeProducer receiveStream,tcp_connected_socket_mojo
m.TcpConnectedSocketInterfaceRequest clientSocket,void callback(network_error_mo
jom.NetworkError result)) { |
| 685 return impl.connect(remoteAddress,sendStream,receiveStream,clientSocket,resp
onseFactory); | 682 return impl.connect(remoteAddress,sendStream,receiveStream,clientSocket,call
back); |
| 686 } | 683 } |
| 687 } | 684 } |
| 688 | 685 |
| 689 | 686 |
| 690 | 687 |
| OLD | NEW |