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

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: Cleanup Created 4 years, 6 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 : super.fromHandle(handle, autoBegin: impl != null) { 666 : super.fromHandle(handle, autoBegin: impl != null) {
638 _impl = impl; 667 _impl = impl;
639 } 668 }
640 669
641 _NfcTransmissionStubControl.unbound([this._impl]) : super.unbound(); 670 _NfcTransmissionStubControl.unbound([this._impl]) : super.unbound();
642 671
643 String get serviceName => NfcTransmission.serviceName; 672 String get serviceName => NfcTransmission.serviceName;
644 673
645 674
646 675
647 dynamic handleMessage(bindings.ServiceMessage message) { 676 void handleMessage(bindings.ServiceMessage message) {
648 if (bindings.ControlMessageHandler.isControlMessage(message)) { 677 if (bindings.ControlMessageHandler.isControlMessage(message)) {
649 return bindings.ControlMessageHandler.handleMessage(this, 678 bindings.ControlMessageHandler.handleMessage(
650 0, 679 this, 0, message);
651 message); 680 return;
652 } 681 }
653 if (_impl == null) { 682 if (_impl == null) {
654 throw new core.MojoApiError("$this has no implementation set"); 683 throw new core.MojoApiError("$this has no implementation set");
655 } 684 }
656 switch (message.header.type) { 685 switch (message.header.type) {
657 case _nfcTransmissionMethodCancelName: 686 case _nfcTransmissionMethodCancelName:
658 _impl.cancel(); 687 _impl.cancel();
659 break; 688 break;
660 default: 689 default:
661 throw new bindings.MojoCodecError("Unexpected message name"); 690 throw new bindings.MojoCodecError("Unexpected message name");
662 break; 691 break;
663 } 692 }
664 return null;
665 } 693 }
666 694
667 NfcTransmission get impl => _impl; 695 NfcTransmission get impl => _impl;
668 set impl(NfcTransmission d) { 696 set impl(NfcTransmission d) {
669 if (d == null) { 697 if (d == null) {
670 throw new core.MojoApiError("$this: Cannot set a null implementation"); 698 throw new core.MojoApiError("$this: Cannot set a null implementation");
671 } 699 }
672 if (isBound && (_impl == null)) { 700 if (isBound && (_impl == null)) {
673 beginHandlingEvents(); 701 beginHandlingEvents();
674 } 702 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 744
717 745
718 void cancel() { 746 void cancel() {
719 return impl.cancel(); 747 return impl.cancel();
720 } 748 }
721 } 749 }
722 750
723 const int _nfcReceiverMethodOnReceivedNfcDataName = 0; 751 const int _nfcReceiverMethodOnReceivedNfcDataName = 0;
724 752
725 class _NfcReceiverServiceDescription implements service_describer.ServiceDescrip tion { 753 class _NfcReceiverServiceDescription implements service_describer.ServiceDescrip tion {
726 dynamic getTopLevelInterface([Function responseFactory]) => 754 void getTopLevelInterface(Function responder) {
727 responseFactory(null); 755 responder(null);
756 }
728 757
729 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 758 void getTypeDefinition(String typeKey, Function responder) {
730 responseFactory(null); 759 responder(null);
760 }
731 761
732 dynamic getAllTypeDefinitions([Function responseFactory]) => 762 void getAllTypeDefinitions(Function responder) {
733 responseFactory(null); 763 responder(null);
764 }
734 } 765 }
735 766
736 abstract class NfcReceiver { 767 abstract class NfcReceiver {
737 static const String serviceName = "nfc::NfcReceiver"; 768 static const String serviceName = "nfc::NfcReceiver";
738 769
739 static service_describer.ServiceDescription _cachedServiceDescription; 770 static service_describer.ServiceDescription _cachedServiceDescription;
740 static service_describer.ServiceDescription get serviceDescription { 771 static service_describer.ServiceDescription get serviceDescription {
741 if (_cachedServiceDescription == null) { 772 if (_cachedServiceDescription == null) {
742 _cachedServiceDescription = new _NfcReceiverServiceDescription(); 773 _cachedServiceDescription = new _NfcReceiverServiceDescription();
743 } 774 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 : super.fromHandle(handle, autoBegin: impl != null) { 904 : super.fromHandle(handle, autoBegin: impl != null) {
874 _impl = impl; 905 _impl = impl;
875 } 906 }
876 907
877 _NfcReceiverStubControl.unbound([this._impl]) : super.unbound(); 908 _NfcReceiverStubControl.unbound([this._impl]) : super.unbound();
878 909
879 String get serviceName => NfcReceiver.serviceName; 910 String get serviceName => NfcReceiver.serviceName;
880 911
881 912
882 913
883 dynamic handleMessage(bindings.ServiceMessage message) { 914 void handleMessage(bindings.ServiceMessage message) {
884 if (bindings.ControlMessageHandler.isControlMessage(message)) { 915 if (bindings.ControlMessageHandler.isControlMessage(message)) {
885 return bindings.ControlMessageHandler.handleMessage(this, 916 bindings.ControlMessageHandler.handleMessage(
886 0, 917 this, 0, message);
887 message); 918 return;
888 } 919 }
889 if (_impl == null) { 920 if (_impl == null) {
890 throw new core.MojoApiError("$this has no implementation set"); 921 throw new core.MojoApiError("$this has no implementation set");
891 } 922 }
892 switch (message.header.type) { 923 switch (message.header.type) {
893 case _nfcReceiverMethodOnReceivedNfcDataName: 924 case _nfcReceiverMethodOnReceivedNfcDataName:
894 var params = _NfcReceiverOnReceivedNfcDataParams.deserialize( 925 var params = _NfcReceiverOnReceivedNfcDataParams.deserialize(
895 message.payload); 926 message.payload);
896 _impl.onReceivedNfcData(params.nfcData); 927 _impl.onReceivedNfcData(params.nfcData);
897 break; 928 break;
898 default: 929 default:
899 throw new bindings.MojoCodecError("Unexpected message name"); 930 throw new bindings.MojoCodecError("Unexpected message name");
900 break; 931 break;
901 } 932 }
902 return null;
903 } 933 }
904 934
905 NfcReceiver get impl => _impl; 935 NfcReceiver get impl => _impl;
906 set impl(NfcReceiver d) { 936 set impl(NfcReceiver d) {
907 if (d == null) { 937 if (d == null) {
908 throw new core.MojoApiError("$this: Cannot set a null implementation"); 938 throw new core.MojoApiError("$this: Cannot set a null implementation");
909 } 939 }
910 if (isBound && (_impl == null)) { 940 if (isBound && (_impl == null)) {
911 beginHandlingEvents(); 941 beginHandlingEvents();
912 } 942 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 void onReceivedNfcData(NfcData nfcData) { 986 void onReceivedNfcData(NfcData nfcData) {
957 return impl.onReceivedNfcData(nfcData); 987 return impl.onReceivedNfcData(nfcData);
958 } 988 }
959 } 989 }
960 990
961 const int _nfcMethodTransmitOnNextConnectionName = 0; 991 const int _nfcMethodTransmitOnNextConnectionName = 0;
962 const int _nfcMethodRegisterName = 1; 992 const int _nfcMethodRegisterName = 1;
963 const int _nfcMethodUnregisterName = 2; 993 const int _nfcMethodUnregisterName = 2;
964 994
965 class _NfcServiceDescription implements service_describer.ServiceDescription { 995 class _NfcServiceDescription implements service_describer.ServiceDescription {
966 dynamic getTopLevelInterface([Function responseFactory]) => 996 void getTopLevelInterface(Function responder) {
967 responseFactory(null); 997 responder(null);
998 }
968 999
969 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 1000 void getTypeDefinition(String typeKey, Function responder) {
970 responseFactory(null); 1001 responder(null);
1002 }
971 1003
972 dynamic getAllTypeDefinitions([Function responseFactory]) => 1004 void getAllTypeDefinitions(Function responder) {
973 responseFactory(null); 1005 responder(null);
1006 }
974 } 1007 }
975 1008
976 abstract class Nfc { 1009 abstract class Nfc {
977 static const String serviceName = "nfc::Nfc"; 1010 static const String serviceName = "nfc::Nfc";
978 1011
979 static service_describer.ServiceDescription _cachedServiceDescription; 1012 static service_describer.ServiceDescription _cachedServiceDescription;
980 static service_describer.ServiceDescription get serviceDescription { 1013 static service_describer.ServiceDescription get serviceDescription {
981 if (_cachedServiceDescription == null) { 1014 if (_cachedServiceDescription == null) {
982 _cachedServiceDescription = new _NfcServiceDescription(); 1015 _cachedServiceDescription = new _NfcServiceDescription();
983 } 1016 }
984 return _cachedServiceDescription; 1017 return _cachedServiceDescription;
985 } 1018 }
986 1019
987 static NfcProxy connectToService( 1020 static NfcProxy connectToService(
988 bindings.ServiceConnector s, String url, [String serviceName]) { 1021 bindings.ServiceConnector s, String url, [String serviceName]) {
989 NfcProxy p = new NfcProxy.unbound(); 1022 NfcProxy p = new NfcProxy.unbound();
990 String name = serviceName ?? Nfc.serviceName; 1023 String name = serviceName ?? Nfc.serviceName;
991 if ((name == null) || name.isEmpty) { 1024 if ((name == null) || name.isEmpty) {
992 throw new core.MojoApiError( 1025 throw new core.MojoApiError(
993 "If an interface has no ServiceName, then one must be provided."); 1026 "If an interface has no ServiceName, then one must be provided.");
994 } 1027 }
995 s.connectToService(url, p, name); 1028 s.connectToService(url, p, name);
996 return p; 1029 return p;
997 } 1030 }
998 dynamic transmitOnNextConnection(NfcData nfcData,NfcTransmissionInterfaceReque st transmission,[Function responseFactory = null]); 1031 void transmitOnNextConnection(NfcData nfcData,NfcTransmissionInterfaceRequest transmission,void callback(bool success));
999 void register(); 1032 void register();
1000 void unregister(); 1033 void unregister();
1001 } 1034 }
1002 1035
1003 abstract class NfcInterface 1036 abstract class NfcInterface
1004 implements bindings.MojoInterface<Nfc>, 1037 implements bindings.MojoInterface<Nfc>,
1005 Nfc { 1038 Nfc {
1006 factory NfcInterface([Nfc impl]) => 1039 factory NfcInterface([Nfc impl]) =>
1007 new NfcStub.unbound(impl); 1040 new NfcStub.unbound(impl);
1008 1041
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 1073
1041 void handleResponse(bindings.ServiceMessage message) { 1074 void handleResponse(bindings.ServiceMessage message) {
1042 switch (message.header.type) { 1075 switch (message.header.type) {
1043 case _nfcMethodTransmitOnNextConnectionName: 1076 case _nfcMethodTransmitOnNextConnectionName:
1044 var r = NfcTransmitOnNextConnectionResponseParams.deserialize( 1077 var r = NfcTransmitOnNextConnectionResponseParams.deserialize(
1045 message.payload); 1078 message.payload);
1046 if (!message.header.hasRequestId) { 1079 if (!message.header.hasRequestId) {
1047 proxyError("Expected a message with a valid request Id."); 1080 proxyError("Expected a message with a valid request Id.");
1048 return; 1081 return;
1049 } 1082 }
1050 Completer c = completerMap[message.header.requestId]; 1083 Function callback = callbackMap[message.header.requestId];
1051 if (c == null) { 1084 if (callback == null) {
1052 proxyError( 1085 proxyError(
1053 "Message had unknown request Id: ${message.header.requestId}"); 1086 "Message had unknown request Id: ${message.header.requestId}");
1054 return; 1087 return;
1055 } 1088 }
1056 completerMap.remove(message.header.requestId); 1089 callbackMap.remove(message.header.requestId);
1057 if (c.isCompleted) { 1090 callback(r.success );
1058 proxyError("Response completer already completed");
1059 return;
1060 }
1061 c.complete(r);
1062 break; 1091 break;
1063 default: 1092 default:
1064 proxyError("Unexpected message type: ${message.header.type}"); 1093 proxyError("Unexpected message type: ${message.header.type}");
1065 close(immediate: true); 1094 close(immediate: true);
1066 break; 1095 break;
1067 } 1096 }
1068 } 1097 }
1069 1098
1070 @override 1099 @override
1071 String toString() { 1100 String toString() {
(...skipping 24 matching lines...) Expand all
1096 return newMockedProxy; 1125 return newMockedProxy;
1097 } 1126 }
1098 1127
1099 static NfcProxy newFromEndpoint( 1128 static NfcProxy newFromEndpoint(
1100 core.MojoMessagePipeEndpoint endpoint) { 1129 core.MojoMessagePipeEndpoint endpoint) {
1101 assert(endpoint.setDescription("For NfcProxy")); 1130 assert(endpoint.setDescription("For NfcProxy"));
1102 return new NfcProxy.fromEndpoint(endpoint); 1131 return new NfcProxy.fromEndpoint(endpoint);
1103 } 1132 }
1104 1133
1105 1134
1106 dynamic transmitOnNextConnection(NfcData nfcData,NfcTransmissionInterfaceReque st transmission,[Function responseFactory = null]) { 1135 void transmitOnNextConnection(NfcData nfcData,NfcTransmissionInterfaceRequest transmission,void callback(bool success)) {
1107 if (impl != null) { 1136 if (impl != null) {
1108 return new Future(() => impl.transmitOnNextConnection(nfcData,transmission ,_NfcStubControl._nfcTransmitOnNextConnectionResponseParamsFactory)); 1137 impl.transmitOnNextConnection(nfcData,transmission,callback);
1138 return;
1109 } 1139 }
1110 var params = new _NfcTransmitOnNextConnectionParams(); 1140 var params = new _NfcTransmitOnNextConnectionParams();
1111 params.nfcData = nfcData; 1141 params.nfcData = nfcData;
1112 params.transmission = transmission; 1142 params.transmission = transmission;
1113 return ctrl.sendMessageWithRequestId( 1143 ctrl.sendMessageWithRequestId(
1114 params, 1144 params,
1115 _nfcMethodTransmitOnNextConnectionName, 1145 _nfcMethodTransmitOnNextConnectionName,
1116 -1, 1146 -1,
1117 bindings.MessageHeader.kMessageExpectsResponse); 1147 bindings.MessageHeader.kMessageExpectsResponse,
1148 callback);
1118 } 1149 }
1119 void register() { 1150 void register() {
1120 if (impl != null) { 1151 if (impl != null) {
1121 impl.register(); 1152 impl.register();
1122 return; 1153 return;
1123 } 1154 }
1124 if (!ctrl.isBound) { 1155 if (!ctrl.isBound) {
1125 ctrl.proxyError("The Proxy is closed."); 1156 ctrl.proxyError("The Proxy is closed.");
1126 return; 1157 return;
1127 } 1158 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 core.MojoHandle handle, [Nfc impl]) 1190 core.MojoHandle handle, [Nfc impl])
1160 : super.fromHandle(handle, autoBegin: impl != null) { 1191 : super.fromHandle(handle, autoBegin: impl != null) {
1161 _impl = impl; 1192 _impl = impl;
1162 } 1193 }
1163 1194
1164 _NfcStubControl.unbound([this._impl]) : super.unbound(); 1195 _NfcStubControl.unbound([this._impl]) : super.unbound();
1165 1196
1166 String get serviceName => Nfc.serviceName; 1197 String get serviceName => Nfc.serviceName;
1167 1198
1168 1199
1169 static NfcTransmitOnNextConnectionResponseParams _nfcTransmitOnNextConnectionR esponseParamsFactory(bool success) { 1200 Function _nfcTransmitOnNextConnectionResponseParamsResponder(
1170 var result = new NfcTransmitOnNextConnectionResponseParams(); 1201 int requestId) {
1171 result.success = success; 1202 return (bool success) {
1172 return result; 1203 var result = new NfcTransmitOnNextConnectionResponseParams();
1204 result.success = success;
1205 sendResponse(buildResponseWithId(
1206 result,
1207 _nfcMethodTransmitOnNextConnectionName,
1208 requestId,
1209 bindings.MessageHeader.kMessageIsResponse));
1210 };
1173 } 1211 }
1174 1212
1175 dynamic handleMessage(bindings.ServiceMessage message) { 1213 void handleMessage(bindings.ServiceMessage message) {
1176 if (bindings.ControlMessageHandler.isControlMessage(message)) { 1214 if (bindings.ControlMessageHandler.isControlMessage(message)) {
1177 return bindings.ControlMessageHandler.handleMessage(this, 1215 bindings.ControlMessageHandler.handleMessage(
1178 0, 1216 this, 0, message);
1179 message); 1217 return;
1180 } 1218 }
1181 if (_impl == null) { 1219 if (_impl == null) {
1182 throw new core.MojoApiError("$this has no implementation set"); 1220 throw new core.MojoApiError("$this has no implementation set");
1183 } 1221 }
1184 switch (message.header.type) { 1222 switch (message.header.type) {
1185 case _nfcMethodTransmitOnNextConnectionName: 1223 case _nfcMethodTransmitOnNextConnectionName:
1186 var params = _NfcTransmitOnNextConnectionParams.deserialize( 1224 var params = _NfcTransmitOnNextConnectionParams.deserialize(
1187 message.payload); 1225 message.payload);
1188 var response = _impl.transmitOnNextConnection(params.nfcData,params.tran smission,_nfcTransmitOnNextConnectionResponseParamsFactory); 1226 _impl.transmitOnNextConnection(params.nfcData, params.transmission, _nfc TransmitOnNextConnectionResponseParamsResponder(message.header.requestId));
1189 if (response is Future) {
1190 return response.then((response) {
1191 if (response != null) {
1192 return buildResponseWithId(
1193 response,
1194 _nfcMethodTransmitOnNextConnectionName,
1195 message.header.requestId,
1196 bindings.MessageHeader.kMessageIsResponse);
1197 }
1198 });
1199 } else if (response != null) {
1200 return buildResponseWithId(
1201 response,
1202 _nfcMethodTransmitOnNextConnectionName,
1203 message.header.requestId,
1204 bindings.MessageHeader.kMessageIsResponse);
1205 }
1206 break; 1227 break;
1207 case _nfcMethodRegisterName: 1228 case _nfcMethodRegisterName:
1208 _impl.register(); 1229 _impl.register();
1209 break; 1230 break;
1210 case _nfcMethodUnregisterName: 1231 case _nfcMethodUnregisterName:
1211 _impl.unregister(); 1232 _impl.unregister();
1212 break; 1233 break;
1213 default: 1234 default:
1214 throw new bindings.MojoCodecError("Unexpected message name"); 1235 throw new bindings.MojoCodecError("Unexpected message name");
1215 break; 1236 break;
1216 } 1237 }
1217 return null;
1218 } 1238 }
1219 1239
1220 Nfc get impl => _impl; 1240 Nfc get impl => _impl;
1221 set impl(Nfc d) { 1241 set impl(Nfc d) {
1222 if (d == null) { 1242 if (d == null) {
1223 throw new core.MojoApiError("$this: Cannot set a null implementation"); 1243 throw new core.MojoApiError("$this: Cannot set a null implementation");
1224 } 1244 }
1225 if (isBound && (_impl == null)) { 1245 if (isBound && (_impl == null)) {
1226 beginHandlingEvents(); 1246 beginHandlingEvents();
1227 } 1247 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 core.MojoHandle handle, [Nfc impl]) 1281 core.MojoHandle handle, [Nfc impl])
1262 : super(new _NfcStubControl.fromHandle(handle, impl)); 1282 : super(new _NfcStubControl.fromHandle(handle, impl));
1263 1283
1264 static NfcStub newFromEndpoint( 1284 static NfcStub newFromEndpoint(
1265 core.MojoMessagePipeEndpoint endpoint) { 1285 core.MojoMessagePipeEndpoint endpoint) {
1266 assert(endpoint.setDescription("For NfcStub")); 1286 assert(endpoint.setDescription("For NfcStub"));
1267 return new NfcStub.fromEndpoint(endpoint); 1287 return new NfcStub.fromEndpoint(endpoint);
1268 } 1288 }
1269 1289
1270 1290
1271 dynamic transmitOnNextConnection(NfcData nfcData,NfcTransmissionInterfaceReque st transmission,[Function responseFactory = null]) { 1291 void transmitOnNextConnection(NfcData nfcData,NfcTransmissionInterfaceRequest transmission,void callback(bool success)) {
1272 return impl.transmitOnNextConnection(nfcData,transmission,responseFactory); 1292 return impl.transmitOnNextConnection(nfcData,transmission,callback);
1273 } 1293 }
1274 void register() { 1294 void register() {
1275 return impl.register(); 1295 return impl.register();
1276 } 1296 }
1277 void unregister() { 1297 void unregister() {
1278 return impl.unregister(); 1298 return impl.unregister();
1279 } 1299 }
1280 } 1300 }
1281 1301
1282 1302
1283 1303
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698