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

Side by Side Diff: mojo/dart/packages/mojo_services/lib/nfc/nfc.mojom.dart

Issue 2006093002: Dart: Futures -> Callbacks. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Move code from mojo_patch to proxy.dart Created 4 years, 7 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
OLDNEW
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 nfc_mojom; 5 library nfc_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 10
11 11
12 12
13 class NfcData extends bindings.Struct { 13 class NfcData extends bindings.Struct {
14 static const List<bindings.StructDataHeader> kVersions = const [ 14 static const List<bindings.StructDataHeader> kVersions = const [
15 const bindings.StructDataHeader(16, 0) 15 const bindings.StructDataHeader(16, 0)
16 ]; 16 ];
17 List<int> data = null; 17 List<int> data = null;
18 18
19 NfcData() : super(kVersions.last.size); 19 NfcData() : super(kVersions.last.size);
20 20
21 NfcData.init(
22 List<int> this.data
23 ) : super(kVersions.last.size);
24
21 static NfcData deserialize(bindings.Message message) { 25 static NfcData deserialize(bindings.Message message) {
22 var decoder = new bindings.Decoder(message); 26 var decoder = new bindings.Decoder(message);
23 var result = decode(decoder); 27 var result = decode(decoder);
24 if (decoder.excessHandles != null) { 28 if (decoder.excessHandles != null) {
25 decoder.excessHandles.forEach((h) => h.close()); 29 decoder.excessHandles.forEach((h) => h.close());
26 } 30 }
27 return result; 31 return result;
28 } 32 }
29 33
30 static NfcData decode(bindings.Decoder decoder0) { 34 static NfcData decode(bindings.Decoder decoder0) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 86 }
83 87
84 88
85 class _NfcTransmissionCancelParams extends bindings.Struct { 89 class _NfcTransmissionCancelParams extends bindings.Struct {
86 static const List<bindings.StructDataHeader> kVersions = const [ 90 static const List<bindings.StructDataHeader> kVersions = const [
87 const bindings.StructDataHeader(8, 0) 91 const bindings.StructDataHeader(8, 0)
88 ]; 92 ];
89 93
90 _NfcTransmissionCancelParams() : super(kVersions.last.size); 94 _NfcTransmissionCancelParams() : super(kVersions.last.size);
91 95
96 _NfcTransmissionCancelParams.init(
97 ) : super(kVersions.last.size);
98
92 static _NfcTransmissionCancelParams deserialize(bindings.Message message) { 99 static _NfcTransmissionCancelParams deserialize(bindings.Message message) {
93 var decoder = new bindings.Decoder(message); 100 var decoder = new bindings.Decoder(message);
94 var result = decode(decoder); 101 var result = decode(decoder);
95 if (decoder.excessHandles != null) { 102 if (decoder.excessHandles != null) {
96 decoder.excessHandles.forEach((h) => h.close()); 103 decoder.excessHandles.forEach((h) => h.close());
97 } 104 }
98 return result; 105 return result;
99 } 106 }
100 107
101 static _NfcTransmissionCancelParams decode(bindings.Decoder decoder0) { 108 static _NfcTransmissionCancelParams decode(bindings.Decoder decoder0) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 148
142 149
143 class _NfcReceiverOnReceivedNfcDataParams extends bindings.Struct { 150 class _NfcReceiverOnReceivedNfcDataParams extends bindings.Struct {
144 static const List<bindings.StructDataHeader> kVersions = const [ 151 static const List<bindings.StructDataHeader> kVersions = const [
145 const bindings.StructDataHeader(16, 0) 152 const bindings.StructDataHeader(16, 0)
146 ]; 153 ];
147 NfcData nfcData = null; 154 NfcData nfcData = null;
148 155
149 _NfcReceiverOnReceivedNfcDataParams() : super(kVersions.last.size); 156 _NfcReceiverOnReceivedNfcDataParams() : super(kVersions.last.size);
150 157
158 _NfcReceiverOnReceivedNfcDataParams.init(
159 NfcData this.nfcData
160 ) : super(kVersions.last.size);
161
151 static _NfcReceiverOnReceivedNfcDataParams deserialize(bindings.Message messag e) { 162 static _NfcReceiverOnReceivedNfcDataParams deserialize(bindings.Message messag e) {
152 var decoder = new bindings.Decoder(message); 163 var decoder = new bindings.Decoder(message);
153 var result = decode(decoder); 164 var result = decode(decoder);
154 if (decoder.excessHandles != null) { 165 if (decoder.excessHandles != null) {
155 decoder.excessHandles.forEach((h) => h.close()); 166 decoder.excessHandles.forEach((h) => h.close());
156 } 167 }
157 return result; 168 return result;
158 } 169 }
159 170
160 static _NfcReceiverOnReceivedNfcDataParams decode(bindings.Decoder decoder0) { 171 static _NfcReceiverOnReceivedNfcDataParams decode(bindings.Decoder decoder0) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 226
216 class _NfcTransmitOnNextConnectionParams extends bindings.Struct { 227 class _NfcTransmitOnNextConnectionParams extends bindings.Struct {
217 static const List<bindings.StructDataHeader> kVersions = const [ 228 static const List<bindings.StructDataHeader> kVersions = const [
218 const bindings.StructDataHeader(24, 0) 229 const bindings.StructDataHeader(24, 0)
219 ]; 230 ];
220 NfcData nfcData = null; 231 NfcData nfcData = null;
221 NfcTransmissionInterfaceRequest transmission = null; 232 NfcTransmissionInterfaceRequest transmission = null;
222 233
223 _NfcTransmitOnNextConnectionParams() : super(kVersions.last.size); 234 _NfcTransmitOnNextConnectionParams() : super(kVersions.last.size);
224 235
236 _NfcTransmitOnNextConnectionParams.init(
237 NfcData this.nfcData,
238 NfcTransmissionInterfaceRequest this.transmission
239 ) : super(kVersions.last.size);
240
225 static _NfcTransmitOnNextConnectionParams deserialize(bindings.Message message ) { 241 static _NfcTransmitOnNextConnectionParams deserialize(bindings.Message message ) {
226 var decoder = new bindings.Decoder(message); 242 var decoder = new bindings.Decoder(message);
227 var result = decode(decoder); 243 var result = decode(decoder);
228 if (decoder.excessHandles != null) { 244 if (decoder.excessHandles != null) {
229 decoder.excessHandles.forEach((h) => h.close()); 245 decoder.excessHandles.forEach((h) => h.close());
230 } 246 }
231 return result; 247 return result;
232 } 248 }
233 249
234 static _NfcTransmitOnNextConnectionParams decode(bindings.Decoder decoder0) { 250 static _NfcTransmitOnNextConnectionParams decode(bindings.Decoder decoder0) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 315
300 316
301 class NfcTransmitOnNextConnectionResponseParams extends bindings.Struct { 317 class NfcTransmitOnNextConnectionResponseParams extends bindings.Struct {
302 static const List<bindings.StructDataHeader> kVersions = const [ 318 static const List<bindings.StructDataHeader> kVersions = const [
303 const bindings.StructDataHeader(16, 0) 319 const bindings.StructDataHeader(16, 0)
304 ]; 320 ];
305 bool success = false; 321 bool success = false;
306 322
307 NfcTransmitOnNextConnectionResponseParams() : super(kVersions.last.size); 323 NfcTransmitOnNextConnectionResponseParams() : super(kVersions.last.size);
308 324
325 NfcTransmitOnNextConnectionResponseParams.init(
326 bool this.success
327 ) : super(kVersions.last.size);
328
309 static NfcTransmitOnNextConnectionResponseParams deserialize(bindings.Message message) { 329 static NfcTransmitOnNextConnectionResponseParams deserialize(bindings.Message message) {
310 var decoder = new bindings.Decoder(message); 330 var decoder = new bindings.Decoder(message);
311 var result = decode(decoder); 331 var result = decode(decoder);
312 if (decoder.excessHandles != null) { 332 if (decoder.excessHandles != null) {
313 decoder.excessHandles.forEach((h) => h.close()); 333 decoder.excessHandles.forEach((h) => h.close());
314 } 334 }
315 return result; 335 return result;
316 } 336 }
317 337
318 static NfcTransmitOnNextConnectionResponseParams decode(bindings.Decoder decod er0) { 338 static NfcTransmitOnNextConnectionResponseParams decode(bindings.Decoder decod er0) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } 390 }
371 391
372 392
373 class _NfcRegisterParams extends bindings.Struct { 393 class _NfcRegisterParams extends bindings.Struct {
374 static const List<bindings.StructDataHeader> kVersions = const [ 394 static const List<bindings.StructDataHeader> kVersions = const [
375 const bindings.StructDataHeader(8, 0) 395 const bindings.StructDataHeader(8, 0)
376 ]; 396 ];
377 397
378 _NfcRegisterParams() : super(kVersions.last.size); 398 _NfcRegisterParams() : super(kVersions.last.size);
379 399
400 _NfcRegisterParams.init(
401 ) : super(kVersions.last.size);
402
380 static _NfcRegisterParams deserialize(bindings.Message message) { 403 static _NfcRegisterParams deserialize(bindings.Message message) {
381 var decoder = new bindings.Decoder(message); 404 var decoder = new bindings.Decoder(message);
382 var result = decode(decoder); 405 var result = decode(decoder);
383 if (decoder.excessHandles != null) { 406 if (decoder.excessHandles != null) {
384 decoder.excessHandles.forEach((h) => h.close()); 407 decoder.excessHandles.forEach((h) => h.close());
385 } 408 }
386 return result; 409 return result;
387 } 410 }
388 411
389 static _NfcRegisterParams decode(bindings.Decoder decoder0) { 412 static _NfcRegisterParams decode(bindings.Decoder decoder0) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 } 451 }
429 452
430 453
431 class _NfcUnregisterParams extends bindings.Struct { 454 class _NfcUnregisterParams extends bindings.Struct {
432 static const List<bindings.StructDataHeader> kVersions = const [ 455 static const List<bindings.StructDataHeader> kVersions = const [
433 const bindings.StructDataHeader(8, 0) 456 const bindings.StructDataHeader(8, 0)
434 ]; 457 ];
435 458
436 _NfcUnregisterParams() : super(kVersions.last.size); 459 _NfcUnregisterParams() : super(kVersions.last.size);
437 460
461 _NfcUnregisterParams.init(
462 ) : super(kVersions.last.size);
463
438 static _NfcUnregisterParams deserialize(bindings.Message message) { 464 static _NfcUnregisterParams deserialize(bindings.Message message) {
439 var decoder = new bindings.Decoder(message); 465 var decoder = new bindings.Decoder(message);
440 var result = decode(decoder); 466 var result = decode(decoder);
441 if (decoder.excessHandles != null) { 467 if (decoder.excessHandles != null) {
442 decoder.excessHandles.forEach((h) => h.close()); 468 decoder.excessHandles.forEach((h) => h.close());
443 } 469 }
444 return result; 470 return result;
445 } 471 }
446 472
447 static _NfcUnregisterParams decode(bindings.Decoder decoder0) { 473 static _NfcUnregisterParams decode(bindings.Decoder decoder0) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 507
482 Map toJson() { 508 Map toJson() {
483 Map map = new Map(); 509 Map map = new Map();
484 return map; 510 return map;
485 } 511 }
486 } 512 }
487 513
488 const int _nfcTransmissionMethodCancelName = 0; 514 const int _nfcTransmissionMethodCancelName = 0;
489 515
490 class _NfcTransmissionServiceDescription implements service_describer.ServiceDes cription { 516 class _NfcTransmissionServiceDescription implements service_describer.ServiceDes cription {
491 dynamic getTopLevelInterface([Function responseFactory]) => 517 void getTopLevelInterface(Function responder) {
492 responseFactory(null); 518 responder(null);
519 }
493 520
494 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 521 void getTypeDefinition(String typeKey, Function responder) {
495 responseFactory(null); 522 responder(null);
523 }
496 524
497 dynamic getAllTypeDefinitions([Function responseFactory]) => 525 void getAllTypeDefinitions(Function responder) {
498 responseFactory(null); 526 responder(null);
527 }
499 } 528 }
500 529
501 abstract class NfcTransmission { 530 abstract class NfcTransmission {
502 static const String serviceName = null; 531 static const String serviceName = null;
503 532
504 static service_describer.ServiceDescription _cachedServiceDescription; 533 static service_describer.ServiceDescription _cachedServiceDescription;
505 static service_describer.ServiceDescription get serviceDescription { 534 static service_describer.ServiceDescription get serviceDescription {
506 if (_cachedServiceDescription == null) { 535 if (_cachedServiceDescription == null) {
507 _cachedServiceDescription = new _NfcTransmissionServiceDescription(); 536 _cachedServiceDescription = new _NfcTransmissionServiceDescription();
508 } 537 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 : super.fromHandle(handle, autoBegin: impl != null) { 653 : super.fromHandle(handle, autoBegin: impl != null) {
625 _impl = impl; 654 _impl = impl;
626 } 655 }
627 656
628 _NfcTransmissionStubControl.unbound([this._impl]) : super.unbound(); 657 _NfcTransmissionStubControl.unbound([this._impl]) : super.unbound();
629 658
630 String get serviceName => NfcTransmission.serviceName; 659 String get serviceName => NfcTransmission.serviceName;
631 660
632 661
633 662
634 dynamic handleMessage(bindings.ServiceMessage message) { 663 void handleMessage(bindings.ServiceMessage message) {
635 if (bindings.ControlMessageHandler.isControlMessage(message)) { 664 if (bindings.ControlMessageHandler.isControlMessage(message)) {
636 return bindings.ControlMessageHandler.handleMessage(this, 665 bindings.ControlMessageHandler.handleMessage(
637 0, 666 this, 0, message);
638 message); 667 return;
639 } 668 }
640 if (_impl == null) { 669 if (_impl == null) {
641 throw new core.MojoApiError("$this has no implementation set"); 670 throw new core.MojoApiError("$this has no implementation set");
642 } 671 }
643 switch (message.header.type) { 672 switch (message.header.type) {
644 case _nfcTransmissionMethodCancelName: 673 case _nfcTransmissionMethodCancelName:
645 _impl.cancel(); 674 _impl.cancel();
646 break; 675 break;
647 default: 676 default:
648 throw new bindings.MojoCodecError("Unexpected message name"); 677 throw new bindings.MojoCodecError("Unexpected message name");
649 break; 678 break;
650 } 679 }
651 return null;
652 } 680 }
653 681
654 NfcTransmission get impl => _impl; 682 NfcTransmission get impl => _impl;
655 set impl(NfcTransmission d) { 683 set impl(NfcTransmission d) {
656 if (d == null) { 684 if (d == null) {
657 throw new core.MojoApiError("$this: Cannot set a null implementation"); 685 throw new core.MojoApiError("$this: Cannot set a null implementation");
658 } 686 }
659 if (isBound && (_impl == null)) { 687 if (isBound && (_impl == null)) {
660 beginHandlingEvents(); 688 beginHandlingEvents();
661 } 689 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 731
704 732
705 void cancel() { 733 void cancel() {
706 return impl.cancel(); 734 return impl.cancel();
707 } 735 }
708 } 736 }
709 737
710 const int _nfcReceiverMethodOnReceivedNfcDataName = 0; 738 const int _nfcReceiverMethodOnReceivedNfcDataName = 0;
711 739
712 class _NfcReceiverServiceDescription implements service_describer.ServiceDescrip tion { 740 class _NfcReceiverServiceDescription implements service_describer.ServiceDescrip tion {
713 dynamic getTopLevelInterface([Function responseFactory]) => 741 void getTopLevelInterface(Function responder) {
714 responseFactory(null); 742 responder(null);
743 }
715 744
716 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 745 void getTypeDefinition(String typeKey, Function responder) {
717 responseFactory(null); 746 responder(null);
747 }
718 748
719 dynamic getAllTypeDefinitions([Function responseFactory]) => 749 void getAllTypeDefinitions(Function responder) {
720 responseFactory(null); 750 responder(null);
751 }
721 } 752 }
722 753
723 abstract class NfcReceiver { 754 abstract class NfcReceiver {
724 static const String serviceName = "nfc::NfcReceiver"; 755 static const String serviceName = "nfc::NfcReceiver";
725 756
726 static service_describer.ServiceDescription _cachedServiceDescription; 757 static service_describer.ServiceDescription _cachedServiceDescription;
727 static service_describer.ServiceDescription get serviceDescription { 758 static service_describer.ServiceDescription get serviceDescription {
728 if (_cachedServiceDescription == null) { 759 if (_cachedServiceDescription == null) {
729 _cachedServiceDescription = new _NfcReceiverServiceDescription(); 760 _cachedServiceDescription = new _NfcReceiverServiceDescription();
730 } 761 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 : super.fromHandle(handle, autoBegin: impl != null) { 878 : super.fromHandle(handle, autoBegin: impl != null) {
848 _impl = impl; 879 _impl = impl;
849 } 880 }
850 881
851 _NfcReceiverStubControl.unbound([this._impl]) : super.unbound(); 882 _NfcReceiverStubControl.unbound([this._impl]) : super.unbound();
852 883
853 String get serviceName => NfcReceiver.serviceName; 884 String get serviceName => NfcReceiver.serviceName;
854 885
855 886
856 887
857 dynamic handleMessage(bindings.ServiceMessage message) { 888 void handleMessage(bindings.ServiceMessage message) {
858 if (bindings.ControlMessageHandler.isControlMessage(message)) { 889 if (bindings.ControlMessageHandler.isControlMessage(message)) {
859 return bindings.ControlMessageHandler.handleMessage(this, 890 bindings.ControlMessageHandler.handleMessage(
860 0, 891 this, 0, message);
861 message); 892 return;
862 } 893 }
863 if (_impl == null) { 894 if (_impl == null) {
864 throw new core.MojoApiError("$this has no implementation set"); 895 throw new core.MojoApiError("$this has no implementation set");
865 } 896 }
866 switch (message.header.type) { 897 switch (message.header.type) {
867 case _nfcReceiverMethodOnReceivedNfcDataName: 898 case _nfcReceiverMethodOnReceivedNfcDataName:
868 var params = _NfcReceiverOnReceivedNfcDataParams.deserialize( 899 var params = _NfcReceiverOnReceivedNfcDataParams.deserialize(
869 message.payload); 900 message.payload);
870 _impl.onReceivedNfcData(params.nfcData); 901 _impl.onReceivedNfcData(params.nfcData);
871 break; 902 break;
872 default: 903 default:
873 throw new bindings.MojoCodecError("Unexpected message name"); 904 throw new bindings.MojoCodecError("Unexpected message name");
874 break; 905 break;
875 } 906 }
876 return null;
877 } 907 }
878 908
879 NfcReceiver get impl => _impl; 909 NfcReceiver get impl => _impl;
880 set impl(NfcReceiver d) { 910 set impl(NfcReceiver d) {
881 if (d == null) { 911 if (d == null) {
882 throw new core.MojoApiError("$this: Cannot set a null implementation"); 912 throw new core.MojoApiError("$this: Cannot set a null implementation");
883 } 913 }
884 if (isBound && (_impl == null)) { 914 if (isBound && (_impl == null)) {
885 beginHandlingEvents(); 915 beginHandlingEvents();
886 } 916 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 void onReceivedNfcData(NfcData nfcData) { 960 void onReceivedNfcData(NfcData nfcData) {
931 return impl.onReceivedNfcData(nfcData); 961 return impl.onReceivedNfcData(nfcData);
932 } 962 }
933 } 963 }
934 964
935 const int _nfcMethodTransmitOnNextConnectionName = 0; 965 const int _nfcMethodTransmitOnNextConnectionName = 0;
936 const int _nfcMethodRegisterName = 1; 966 const int _nfcMethodRegisterName = 1;
937 const int _nfcMethodUnregisterName = 2; 967 const int _nfcMethodUnregisterName = 2;
938 968
939 class _NfcServiceDescription implements service_describer.ServiceDescription { 969 class _NfcServiceDescription implements service_describer.ServiceDescription {
940 dynamic getTopLevelInterface([Function responseFactory]) => 970 void getTopLevelInterface(Function responder) {
941 responseFactory(null); 971 responder(null);
972 }
942 973
943 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 974 void getTypeDefinition(String typeKey, Function responder) {
944 responseFactory(null); 975 responder(null);
976 }
945 977
946 dynamic getAllTypeDefinitions([Function responseFactory]) => 978 void getAllTypeDefinitions(Function responder) {
947 responseFactory(null); 979 responder(null);
980 }
948 } 981 }
949 982
950 abstract class Nfc { 983 abstract class Nfc {
951 static const String serviceName = "nfc::Nfc"; 984 static const String serviceName = "nfc::Nfc";
952 985
953 static service_describer.ServiceDescription _cachedServiceDescription; 986 static service_describer.ServiceDescription _cachedServiceDescription;
954 static service_describer.ServiceDescription get serviceDescription { 987 static service_describer.ServiceDescription get serviceDescription {
955 if (_cachedServiceDescription == null) { 988 if (_cachedServiceDescription == null) {
956 _cachedServiceDescription = new _NfcServiceDescription(); 989 _cachedServiceDescription = new _NfcServiceDescription();
957 } 990 }
958 return _cachedServiceDescription; 991 return _cachedServiceDescription;
959 } 992 }
960 993
961 static NfcProxy connectToService( 994 static NfcProxy connectToService(
962 bindings.ServiceConnector s, String url, [String serviceName]) { 995 bindings.ServiceConnector s, String url, [String serviceName]) {
963 NfcProxy p = new NfcProxy.unbound(); 996 NfcProxy p = new NfcProxy.unbound();
964 String name = serviceName ?? Nfc.serviceName; 997 String name = serviceName ?? Nfc.serviceName;
965 if ((name == null) || name.isEmpty) { 998 if ((name == null) || name.isEmpty) {
966 throw new core.MojoApiError( 999 throw new core.MojoApiError(
967 "If an interface has no ServiceName, then one must be provided."); 1000 "If an interface has no ServiceName, then one must be provided.");
968 } 1001 }
969 s.connectToService(url, p, name); 1002 s.connectToService(url, p, name);
970 return p; 1003 return p;
971 } 1004 }
972 dynamic transmitOnNextConnection(NfcData nfcData,NfcTransmissionInterfaceReque st transmission,[Function responseFactory = null]); 1005 void transmitOnNextConnection(NfcData nfcData,NfcTransmissionInterfaceRequest transmission,void callback(bool success));
973 void register(); 1006 void register();
974 void unregister(); 1007 void unregister();
975 } 1008 }
976 1009
977 abstract class NfcInterface 1010 abstract class NfcInterface
978 implements bindings.MojoInterface<Nfc>, 1011 implements bindings.MojoInterface<Nfc>,
979 Nfc { 1012 Nfc {
980 factory NfcInterface([Nfc impl]) => 1013 factory NfcInterface([Nfc impl]) =>
981 new NfcStub.unbound(impl); 1014 new NfcStub.unbound(impl);
982 factory NfcInterface.fromEndpoint( 1015 factory NfcInterface.fromEndpoint(
(...skipping 24 matching lines...) Expand all
1007 1040
1008 void handleResponse(bindings.ServiceMessage message) { 1041 void handleResponse(bindings.ServiceMessage message) {
1009 switch (message.header.type) { 1042 switch (message.header.type) {
1010 case _nfcMethodTransmitOnNextConnectionName: 1043 case _nfcMethodTransmitOnNextConnectionName:
1011 var r = NfcTransmitOnNextConnectionResponseParams.deserialize( 1044 var r = NfcTransmitOnNextConnectionResponseParams.deserialize(
1012 message.payload); 1045 message.payload);
1013 if (!message.header.hasRequestId) { 1046 if (!message.header.hasRequestId) {
1014 proxyError("Expected a message with a valid request Id."); 1047 proxyError("Expected a message with a valid request Id.");
1015 return; 1048 return;
1016 } 1049 }
1017 Completer c = completerMap[message.header.requestId]; 1050 Function callback = callbackMap[message.header.requestId];
1018 if (c == null) { 1051 if (callback == null) {
1019 proxyError( 1052 proxyError(
1020 "Message had unknown request Id: ${message.header.requestId}"); 1053 "Message had unknown request Id: ${message.header.requestId}");
1021 return; 1054 return;
1022 } 1055 }
1023 completerMap.remove(message.header.requestId); 1056 callbackMap.remove(message.header.requestId);
1024 if (c.isCompleted) { 1057 callback(r.success );
1025 proxyError("Response completer already completed");
1026 return;
1027 }
1028 c.complete(r);
1029 break; 1058 break;
1030 default: 1059 default:
1031 proxyError("Unexpected message type: ${message.header.type}"); 1060 proxyError("Unexpected message type: ${message.header.type}");
1032 close(immediate: true); 1061 close(immediate: true);
1033 break; 1062 break;
1034 } 1063 }
1035 } 1064 }
1036 1065
1037 Nfc get impl => null; 1066 Nfc get impl => null;
1038 set impl(Nfc _) { 1067 set impl(Nfc _) {
(...skipping 22 matching lines...) Expand all
1061 NfcProxy.unbound() 1090 NfcProxy.unbound()
1062 : super(new _NfcProxyControl.unbound()); 1091 : super(new _NfcProxyControl.unbound());
1063 1092
1064 static NfcProxy newFromEndpoint( 1093 static NfcProxy newFromEndpoint(
1065 core.MojoMessagePipeEndpoint endpoint) { 1094 core.MojoMessagePipeEndpoint endpoint) {
1066 assert(endpoint.setDescription("For NfcProxy")); 1095 assert(endpoint.setDescription("For NfcProxy"));
1067 return new NfcProxy.fromEndpoint(endpoint); 1096 return new NfcProxy.fromEndpoint(endpoint);
1068 } 1097 }
1069 1098
1070 1099
1071 dynamic transmitOnNextConnection(NfcData nfcData,NfcTransmissionInterfaceReque st transmission,[Function responseFactory = null]) { 1100 void transmitOnNextConnection(NfcData nfcData,NfcTransmissionInterfaceRequest transmission,void callback(bool success)) {
1072 var params = new _NfcTransmitOnNextConnectionParams(); 1101 var params = new _NfcTransmitOnNextConnectionParams();
1073 params.nfcData = nfcData; 1102 params.nfcData = nfcData;
1074 params.transmission = transmission; 1103 params.transmission = transmission;
1075 return ctrl.sendMessageWithRequestId( 1104 ctrl.sendMessageWithRequestId(
1076 params, 1105 params,
1077 _nfcMethodTransmitOnNextConnectionName, 1106 _nfcMethodTransmitOnNextConnectionName,
1078 -1, 1107 -1,
1079 bindings.MessageHeader.kMessageExpectsResponse); 1108 bindings.MessageHeader.kMessageExpectsResponse,
1109 callback);
1080 } 1110 }
1081 void register() { 1111 void register() {
1082 if (!ctrl.isBound) { 1112 if (!ctrl.isBound) {
1083 ctrl.proxyError("The Proxy is closed."); 1113 ctrl.proxyError("The Proxy is closed.");
1084 return; 1114 return;
1085 } 1115 }
1086 var params = new _NfcRegisterParams(); 1116 var params = new _NfcRegisterParams();
1087 ctrl.sendMessage(params, 1117 ctrl.sendMessage(params,
1088 _nfcMethodRegisterName); 1118 _nfcMethodRegisterName);
1089 } 1119 }
(...skipping 23 matching lines...) Expand all
1113 core.MojoHandle handle, [Nfc impl]) 1143 core.MojoHandle handle, [Nfc impl])
1114 : super.fromHandle(handle, autoBegin: impl != null) { 1144 : super.fromHandle(handle, autoBegin: impl != null) {
1115 _impl = impl; 1145 _impl = impl;
1116 } 1146 }
1117 1147
1118 _NfcStubControl.unbound([this._impl]) : super.unbound(); 1148 _NfcStubControl.unbound([this._impl]) : super.unbound();
1119 1149
1120 String get serviceName => Nfc.serviceName; 1150 String get serviceName => Nfc.serviceName;
1121 1151
1122 1152
1123 NfcTransmitOnNextConnectionResponseParams _nfcTransmitOnNextConnectionResponse ParamsFactory(bool success) { 1153 Function _nfcTransmitOnNextConnectionResponseParamsResponder(
1124 var result = new NfcTransmitOnNextConnectionResponseParams(); 1154 int requestId) {
1125 result.success = success; 1155 return (bool success) {
1126 return result; 1156 var result = new NfcTransmitOnNextConnectionResponseParams();
1157 result.success = success;
1158 sendResponse(buildResponseWithId(
1159 result,
1160 _nfcMethodTransmitOnNextConnectionName,
1161 requestId,
1162 bindings.MessageHeader.kMessageIsResponse));
1163 };
1127 } 1164 }
1128 1165
1129 dynamic handleMessage(bindings.ServiceMessage message) { 1166 void handleMessage(bindings.ServiceMessage message) {
1130 if (bindings.ControlMessageHandler.isControlMessage(message)) { 1167 if (bindings.ControlMessageHandler.isControlMessage(message)) {
1131 return bindings.ControlMessageHandler.handleMessage(this, 1168 bindings.ControlMessageHandler.handleMessage(
1132 0, 1169 this, 0, message);
1133 message); 1170 return;
1134 } 1171 }
1135 if (_impl == null) { 1172 if (_impl == null) {
1136 throw new core.MojoApiError("$this has no implementation set"); 1173 throw new core.MojoApiError("$this has no implementation set");
1137 } 1174 }
1138 switch (message.header.type) { 1175 switch (message.header.type) {
1139 case _nfcMethodTransmitOnNextConnectionName: 1176 case _nfcMethodTransmitOnNextConnectionName:
1140 var params = _NfcTransmitOnNextConnectionParams.deserialize( 1177 var params = _NfcTransmitOnNextConnectionParams.deserialize(
1141 message.payload); 1178 message.payload);
1142 var response = _impl.transmitOnNextConnection(params.nfcData,params.tran smission,_nfcTransmitOnNextConnectionResponseParamsFactory); 1179 _impl.transmitOnNextConnection(params.nfcData, params.transmission, _nfc TransmitOnNextConnectionResponseParamsResponder(message.header.requestId));
1143 if (response is Future) {
1144 return response.then((response) {
1145 if (response != null) {
1146 return buildResponseWithId(
1147 response,
1148 _nfcMethodTransmitOnNextConnectionName,
1149 message.header.requestId,
1150 bindings.MessageHeader.kMessageIsResponse);
1151 }
1152 });
1153 } else if (response != null) {
1154 return buildResponseWithId(
1155 response,
1156 _nfcMethodTransmitOnNextConnectionName,
1157 message.header.requestId,
1158 bindings.MessageHeader.kMessageIsResponse);
1159 }
1160 break; 1180 break;
1161 case _nfcMethodRegisterName: 1181 case _nfcMethodRegisterName:
1162 _impl.register(); 1182 _impl.register();
1163 break; 1183 break;
1164 case _nfcMethodUnregisterName: 1184 case _nfcMethodUnregisterName:
1165 _impl.unregister(); 1185 _impl.unregister();
1166 break; 1186 break;
1167 default: 1187 default:
1168 throw new bindings.MojoCodecError("Unexpected message name"); 1188 throw new bindings.MojoCodecError("Unexpected message name");
1169 break; 1189 break;
1170 } 1190 }
1171 return null;
1172 } 1191 }
1173 1192
1174 Nfc get impl => _impl; 1193 Nfc get impl => _impl;
1175 set impl(Nfc d) { 1194 set impl(Nfc d) {
1176 if (d == null) { 1195 if (d == null) {
1177 throw new core.MojoApiError("$this: Cannot set a null implementation"); 1196 throw new core.MojoApiError("$this: Cannot set a null implementation");
1178 } 1197 }
1179 if (isBound && (_impl == null)) { 1198 if (isBound && (_impl == null)) {
1180 beginHandlingEvents(); 1199 beginHandlingEvents();
1181 } 1200 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 core.MojoHandle handle, [Nfc impl]) 1234 core.MojoHandle handle, [Nfc impl])
1216 : super(new _NfcStubControl.fromHandle(handle, impl)); 1235 : super(new _NfcStubControl.fromHandle(handle, impl));
1217 1236
1218 static NfcStub newFromEndpoint( 1237 static NfcStub newFromEndpoint(
1219 core.MojoMessagePipeEndpoint endpoint) { 1238 core.MojoMessagePipeEndpoint endpoint) {
1220 assert(endpoint.setDescription("For NfcStub")); 1239 assert(endpoint.setDescription("For NfcStub"));
1221 return new NfcStub.fromEndpoint(endpoint); 1240 return new NfcStub.fromEndpoint(endpoint);
1222 } 1241 }
1223 1242
1224 1243
1225 dynamic transmitOnNextConnection(NfcData nfcData,NfcTransmissionInterfaceReque st transmission,[Function responseFactory = null]) { 1244 void transmitOnNextConnection(NfcData nfcData,NfcTransmissionInterfaceRequest transmission,void callback(bool success)) {
1226 return impl.transmitOnNextConnection(nfcData,transmission,responseFactory); 1245 return impl.transmitOnNextConnection(nfcData,transmission,callback);
1227 } 1246 }
1228 void register() { 1247 void register() {
1229 return impl.register(); 1248 return impl.register();
1230 } 1249 }
1231 void unregister() { 1250 void unregister() {
1232 return impl.unregister(); 1251 return impl.unregister();
1233 } 1252 }
1234 } 1253 }
1235 1254
1236 1255
1237 1256
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698