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

Side by Side Diff: mojo/dart/packages/mojo_services/lib/contacts/contacts.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 contacts_mojom; 5 library contacts_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 Contact extends bindings.Struct { 13 class Contact extends bindings.Struct {
14 static const List<bindings.StructDataHeader> kVersions = const [ 14 static const List<bindings.StructDataHeader> kVersions = const [
15 const bindings.StructDataHeader(24, 0) 15 const bindings.StructDataHeader(24, 0)
16 ]; 16 ];
17 int id = 0; 17 int id = 0;
18 String name = null; 18 String name = null;
19 19
20 Contact() : super(kVersions.last.size); 20 Contact() : super(kVersions.last.size);
21 21
22 Contact.init(
23 int this.id,
24 String this.name
25 ) : super(kVersions.last.size);
26
22 static Contact deserialize(bindings.Message message) { 27 static Contact deserialize(bindings.Message message) {
23 var decoder = new bindings.Decoder(message); 28 var decoder = new bindings.Decoder(message);
24 var result = decode(decoder); 29 var result = decode(decoder);
25 if (decoder.excessHandles != null) { 30 if (decoder.excessHandles != null) {
26 decoder.excessHandles.forEach((h) => h.close()); 31 decoder.excessHandles.forEach((h) => h.close());
27 } 32 }
28 return result; 33 return result;
29 } 34 }
30 35
31 static Contact decode(bindings.Decoder decoder0) { 36 static Contact decode(bindings.Decoder decoder0) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 102
98 103
99 class _ContactsServiceGetCountParams extends bindings.Struct { 104 class _ContactsServiceGetCountParams extends bindings.Struct {
100 static const List<bindings.StructDataHeader> kVersions = const [ 105 static const List<bindings.StructDataHeader> kVersions = const [
101 const bindings.StructDataHeader(16, 0) 106 const bindings.StructDataHeader(16, 0)
102 ]; 107 ];
103 String filter = null; 108 String filter = null;
104 109
105 _ContactsServiceGetCountParams() : super(kVersions.last.size); 110 _ContactsServiceGetCountParams() : super(kVersions.last.size);
106 111
112 _ContactsServiceGetCountParams.init(
113 String this.filter
114 ) : super(kVersions.last.size);
115
107 static _ContactsServiceGetCountParams deserialize(bindings.Message message) { 116 static _ContactsServiceGetCountParams deserialize(bindings.Message message) {
108 var decoder = new bindings.Decoder(message); 117 var decoder = new bindings.Decoder(message);
109 var result = decode(decoder); 118 var result = decode(decoder);
110 if (decoder.excessHandles != null) { 119 if (decoder.excessHandles != null) {
111 decoder.excessHandles.forEach((h) => h.close()); 120 decoder.excessHandles.forEach((h) => h.close());
112 } 121 }
113 return result; 122 return result;
114 } 123 }
115 124
116 static _ContactsServiceGetCountParams decode(bindings.Decoder decoder0) { 125 static _ContactsServiceGetCountParams decode(bindings.Decoder decoder0) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 178
170 179
171 class ContactsServiceGetCountResponseParams extends bindings.Struct { 180 class ContactsServiceGetCountResponseParams extends bindings.Struct {
172 static const List<bindings.StructDataHeader> kVersions = const [ 181 static const List<bindings.StructDataHeader> kVersions = const [
173 const bindings.StructDataHeader(16, 0) 182 const bindings.StructDataHeader(16, 0)
174 ]; 183 ];
175 int count = 0; 184 int count = 0;
176 185
177 ContactsServiceGetCountResponseParams() : super(kVersions.last.size); 186 ContactsServiceGetCountResponseParams() : super(kVersions.last.size);
178 187
188 ContactsServiceGetCountResponseParams.init(
189 int this.count
190 ) : super(kVersions.last.size);
191
179 static ContactsServiceGetCountResponseParams deserialize(bindings.Message mess age) { 192 static ContactsServiceGetCountResponseParams deserialize(bindings.Message mess age) {
180 var decoder = new bindings.Decoder(message); 193 var decoder = new bindings.Decoder(message);
181 var result = decode(decoder); 194 var result = decode(decoder);
182 if (decoder.excessHandles != null) { 195 if (decoder.excessHandles != null) {
183 decoder.excessHandles.forEach((h) => h.close()); 196 decoder.excessHandles.forEach((h) => h.close());
184 } 197 }
185 return result; 198 return result;
186 } 199 }
187 200
188 static ContactsServiceGetCountResponseParams decode(bindings.Decoder decoder0) { 201 static ContactsServiceGetCountResponseParams decode(bindings.Decoder decoder0) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 class _ContactsServiceGetParams extends bindings.Struct { 256 class _ContactsServiceGetParams extends bindings.Struct {
244 static const List<bindings.StructDataHeader> kVersions = const [ 257 static const List<bindings.StructDataHeader> kVersions = const [
245 const bindings.StructDataHeader(24, 0) 258 const bindings.StructDataHeader(24, 0)
246 ]; 259 ];
247 String filter = null; 260 String filter = null;
248 int offset = 0; 261 int offset = 0;
249 int limit = 0; 262 int limit = 0;
250 263
251 _ContactsServiceGetParams() : super(kVersions.last.size); 264 _ContactsServiceGetParams() : super(kVersions.last.size);
252 265
266 _ContactsServiceGetParams.init(
267 String this.filter,
268 int this.offset,
269 int this.limit
270 ) : super(kVersions.last.size);
271
253 static _ContactsServiceGetParams deserialize(bindings.Message message) { 272 static _ContactsServiceGetParams deserialize(bindings.Message message) {
254 var decoder = new bindings.Decoder(message); 273 var decoder = new bindings.Decoder(message);
255 var result = decode(decoder); 274 var result = decode(decoder);
256 if (decoder.excessHandles != null) { 275 if (decoder.excessHandles != null) {
257 decoder.excessHandles.forEach((h) => h.close()); 276 decoder.excessHandles.forEach((h) => h.close());
258 } 277 }
259 return result; 278 return result;
260 } 279 }
261 280
262 static _ContactsServiceGetParams decode(bindings.Decoder decoder0) { 281 static _ContactsServiceGetParams decode(bindings.Decoder decoder0) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 360
342 361
343 class ContactsServiceGetResponseParams extends bindings.Struct { 362 class ContactsServiceGetResponseParams extends bindings.Struct {
344 static const List<bindings.StructDataHeader> kVersions = const [ 363 static const List<bindings.StructDataHeader> kVersions = const [
345 const bindings.StructDataHeader(16, 0) 364 const bindings.StructDataHeader(16, 0)
346 ]; 365 ];
347 List<Contact> contacts = null; 366 List<Contact> contacts = null;
348 367
349 ContactsServiceGetResponseParams() : super(kVersions.last.size); 368 ContactsServiceGetResponseParams() : super(kVersions.last.size);
350 369
370 ContactsServiceGetResponseParams.init(
371 List<Contact> this.contacts
372 ) : super(kVersions.last.size);
373
351 static ContactsServiceGetResponseParams deserialize(bindings.Message message) { 374 static ContactsServiceGetResponseParams deserialize(bindings.Message message) {
352 var decoder = new bindings.Decoder(message); 375 var decoder = new bindings.Decoder(message);
353 var result = decode(decoder); 376 var result = decode(decoder);
354 if (decoder.excessHandles != null) { 377 if (decoder.excessHandles != null) {
355 decoder.excessHandles.forEach((h) => h.close()); 378 decoder.excessHandles.forEach((h) => h.close());
356 } 379 }
357 return result; 380 return result;
358 } 381 }
359 382
360 static ContactsServiceGetResponseParams decode(bindings.Decoder decoder0) { 383 static ContactsServiceGetResponseParams decode(bindings.Decoder decoder0) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 452
430 453
431 class _ContactsServiceGetEmailsParams extends bindings.Struct { 454 class _ContactsServiceGetEmailsParams extends bindings.Struct {
432 static const List<bindings.StructDataHeader> kVersions = const [ 455 static const List<bindings.StructDataHeader> kVersions = const [
433 const bindings.StructDataHeader(16, 0) 456 const bindings.StructDataHeader(16, 0)
434 ]; 457 ];
435 int id = 0; 458 int id = 0;
436 459
437 _ContactsServiceGetEmailsParams() : super(kVersions.last.size); 460 _ContactsServiceGetEmailsParams() : super(kVersions.last.size);
438 461
462 _ContactsServiceGetEmailsParams.init(
463 int this.id
464 ) : super(kVersions.last.size);
465
439 static _ContactsServiceGetEmailsParams deserialize(bindings.Message message) { 466 static _ContactsServiceGetEmailsParams deserialize(bindings.Message message) {
440 var decoder = new bindings.Decoder(message); 467 var decoder = new bindings.Decoder(message);
441 var result = decode(decoder); 468 var result = decode(decoder);
442 if (decoder.excessHandles != null) { 469 if (decoder.excessHandles != null) {
443 decoder.excessHandles.forEach((h) => h.close()); 470 decoder.excessHandles.forEach((h) => h.close());
444 } 471 }
445 return result; 472 return result;
446 } 473 }
447 474
448 static _ContactsServiceGetEmailsParams decode(bindings.Decoder decoder0) { 475 static _ContactsServiceGetEmailsParams decode(bindings.Decoder decoder0) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 528
502 529
503 class ContactsServiceGetEmailsResponseParams extends bindings.Struct { 530 class ContactsServiceGetEmailsResponseParams extends bindings.Struct {
504 static const List<bindings.StructDataHeader> kVersions = const [ 531 static const List<bindings.StructDataHeader> kVersions = const [
505 const bindings.StructDataHeader(16, 0) 532 const bindings.StructDataHeader(16, 0)
506 ]; 533 ];
507 List<String> emails = null; 534 List<String> emails = null;
508 535
509 ContactsServiceGetEmailsResponseParams() : super(kVersions.last.size); 536 ContactsServiceGetEmailsResponseParams() : super(kVersions.last.size);
510 537
538 ContactsServiceGetEmailsResponseParams.init(
539 List<String> this.emails
540 ) : super(kVersions.last.size);
541
511 static ContactsServiceGetEmailsResponseParams deserialize(bindings.Message mes sage) { 542 static ContactsServiceGetEmailsResponseParams deserialize(bindings.Message mes sage) {
512 var decoder = new bindings.Decoder(message); 543 var decoder = new bindings.Decoder(message);
513 var result = decode(decoder); 544 var result = decode(decoder);
514 if (decoder.excessHandles != null) { 545 if (decoder.excessHandles != null) {
515 decoder.excessHandles.forEach((h) => h.close()); 546 decoder.excessHandles.forEach((h) => h.close());
516 } 547 }
517 return result; 548 return result;
518 } 549 }
519 550
520 static ContactsServiceGetEmailsResponseParams decode(bindings.Decoder decoder0 ) { 551 static ContactsServiceGetEmailsResponseParams decode(bindings.Decoder decoder0 ) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 620
590 class _ContactsServiceGetPhotoParams extends bindings.Struct { 621 class _ContactsServiceGetPhotoParams extends bindings.Struct {
591 static const List<bindings.StructDataHeader> kVersions = const [ 622 static const List<bindings.StructDataHeader> kVersions = const [
592 const bindings.StructDataHeader(24, 0) 623 const bindings.StructDataHeader(24, 0)
593 ]; 624 ];
594 int id = 0; 625 int id = 0;
595 bool highResolution = false; 626 bool highResolution = false;
596 627
597 _ContactsServiceGetPhotoParams() : super(kVersions.last.size); 628 _ContactsServiceGetPhotoParams() : super(kVersions.last.size);
598 629
630 _ContactsServiceGetPhotoParams.init(
631 int this.id,
632 bool this.highResolution
633 ) : super(kVersions.last.size);
634
599 static _ContactsServiceGetPhotoParams deserialize(bindings.Message message) { 635 static _ContactsServiceGetPhotoParams deserialize(bindings.Message message) {
600 var decoder = new bindings.Decoder(message); 636 var decoder = new bindings.Decoder(message);
601 var result = decode(decoder); 637 var result = decode(decoder);
602 if (decoder.excessHandles != null) { 638 if (decoder.excessHandles != null) {
603 decoder.excessHandles.forEach((h) => h.close()); 639 decoder.excessHandles.forEach((h) => h.close());
604 } 640 }
605 return result; 641 return result;
606 } 642 }
607 643
608 static _ContactsServiceGetPhotoParams decode(bindings.Decoder decoder0) { 644 static _ContactsServiceGetPhotoParams decode(bindings.Decoder decoder0) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 710
675 711
676 class ContactsServiceGetPhotoResponseParams extends bindings.Struct { 712 class ContactsServiceGetPhotoResponseParams extends bindings.Struct {
677 static const List<bindings.StructDataHeader> kVersions = const [ 713 static const List<bindings.StructDataHeader> kVersions = const [
678 const bindings.StructDataHeader(16, 0) 714 const bindings.StructDataHeader(16, 0)
679 ]; 715 ];
680 String photoUrl = null; 716 String photoUrl = null;
681 717
682 ContactsServiceGetPhotoResponseParams() : super(kVersions.last.size); 718 ContactsServiceGetPhotoResponseParams() : super(kVersions.last.size);
683 719
720 ContactsServiceGetPhotoResponseParams.init(
721 String this.photoUrl
722 ) : super(kVersions.last.size);
723
684 static ContactsServiceGetPhotoResponseParams deserialize(bindings.Message mess age) { 724 static ContactsServiceGetPhotoResponseParams deserialize(bindings.Message mess age) {
685 var decoder = new bindings.Decoder(message); 725 var decoder = new bindings.Decoder(message);
686 var result = decode(decoder); 726 var result = decode(decoder);
687 if (decoder.excessHandles != null) { 727 if (decoder.excessHandles != null) {
688 decoder.excessHandles.forEach((h) => h.close()); 728 decoder.excessHandles.forEach((h) => h.close());
689 } 729 }
690 return result; 730 return result;
691 } 731 }
692 732
693 static ContactsServiceGetPhotoResponseParams decode(bindings.Decoder decoder0) { 733 static ContactsServiceGetPhotoResponseParams decode(bindings.Decoder decoder0) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 return map; 783 return map;
744 } 784 }
745 } 785 }
746 786
747 const int _contactsServiceMethodGetCountName = 0; 787 const int _contactsServiceMethodGetCountName = 0;
748 const int _contactsServiceMethodGetName = 1; 788 const int _contactsServiceMethodGetName = 1;
749 const int _contactsServiceMethodGetEmailsName = 2; 789 const int _contactsServiceMethodGetEmailsName = 2;
750 const int _contactsServiceMethodGetPhotoName = 3; 790 const int _contactsServiceMethodGetPhotoName = 3;
751 791
752 class _ContactsServiceServiceDescription implements service_describer.ServiceDes cription { 792 class _ContactsServiceServiceDescription implements service_describer.ServiceDes cription {
753 dynamic getTopLevelInterface([Function responseFactory]) => 793 void getTopLevelInterface(Function responder) {
754 responseFactory(null); 794 responder(null);
795 }
755 796
756 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 797 void getTypeDefinition(String typeKey, Function responder) {
757 responseFactory(null); 798 responder(null);
799 }
758 800
759 dynamic getAllTypeDefinitions([Function responseFactory]) => 801 void getAllTypeDefinitions(Function responder) {
760 responseFactory(null); 802 responder(null);
803 }
761 } 804 }
762 805
763 abstract class ContactsService { 806 abstract class ContactsService {
764 static const String serviceName = "contacts::ContactsService"; 807 static const String serviceName = "contacts::ContactsService";
765 808
766 static service_describer.ServiceDescription _cachedServiceDescription; 809 static service_describer.ServiceDescription _cachedServiceDescription;
767 static service_describer.ServiceDescription get serviceDescription { 810 static service_describer.ServiceDescription get serviceDescription {
768 if (_cachedServiceDescription == null) { 811 if (_cachedServiceDescription == null) {
769 _cachedServiceDescription = new _ContactsServiceServiceDescription(); 812 _cachedServiceDescription = new _ContactsServiceServiceDescription();
770 } 813 }
771 return _cachedServiceDescription; 814 return _cachedServiceDescription;
772 } 815 }
773 816
774 static ContactsServiceProxy connectToService( 817 static ContactsServiceProxy connectToService(
775 bindings.ServiceConnector s, String url, [String serviceName]) { 818 bindings.ServiceConnector s, String url, [String serviceName]) {
776 ContactsServiceProxy p = new ContactsServiceProxy.unbound(); 819 ContactsServiceProxy p = new ContactsServiceProxy.unbound();
777 String name = serviceName ?? ContactsService.serviceName; 820 String name = serviceName ?? ContactsService.serviceName;
778 if ((name == null) || name.isEmpty) { 821 if ((name == null) || name.isEmpty) {
779 throw new core.MojoApiError( 822 throw new core.MojoApiError(
780 "If an interface has no ServiceName, then one must be provided."); 823 "If an interface has no ServiceName, then one must be provided.");
781 } 824 }
782 s.connectToService(url, p, name); 825 s.connectToService(url, p, name);
783 return p; 826 return p;
784 } 827 }
785 dynamic getCount(String filter,[Function responseFactory = null]); 828 void getCount(String filter,void callback(int count));
786 dynamic get(String filter,int offset,int limit,[Function responseFactory = nul l]); 829 void get(String filter,int offset,int limit,void callback(List<Contact> contac ts));
787 dynamic getEmails(int id,[Function responseFactory = null]); 830 void getEmails(int id,void callback(List<String> emails));
788 dynamic getPhoto(int id,bool highResolution,[Function responseFactory = null]) ; 831 void getPhoto(int id,bool highResolution,void callback(String photoUrl));
789 } 832 }
790 833
791 abstract class ContactsServiceInterface 834 abstract class ContactsServiceInterface
792 implements bindings.MojoInterface<ContactsService>, 835 implements bindings.MojoInterface<ContactsService>,
793 ContactsService { 836 ContactsService {
794 factory ContactsServiceInterface([ContactsService impl]) => 837 factory ContactsServiceInterface([ContactsService impl]) =>
795 new ContactsServiceStub.unbound(impl); 838 new ContactsServiceStub.unbound(impl);
796 839
797 factory ContactsServiceInterface.fromEndpoint( 840 factory ContactsServiceInterface.fromEndpoint(
798 core.MojoMessagePipeEndpoint endpoint, 841 core.MojoMessagePipeEndpoint endpoint,
(...skipping 29 matching lines...) Expand all
828 871
829 void handleResponse(bindings.ServiceMessage message) { 872 void handleResponse(bindings.ServiceMessage message) {
830 switch (message.header.type) { 873 switch (message.header.type) {
831 case _contactsServiceMethodGetCountName: 874 case _contactsServiceMethodGetCountName:
832 var r = ContactsServiceGetCountResponseParams.deserialize( 875 var r = ContactsServiceGetCountResponseParams.deserialize(
833 message.payload); 876 message.payload);
834 if (!message.header.hasRequestId) { 877 if (!message.header.hasRequestId) {
835 proxyError("Expected a message with a valid request Id."); 878 proxyError("Expected a message with a valid request Id.");
836 return; 879 return;
837 } 880 }
838 Completer c = completerMap[message.header.requestId]; 881 Function callback = callbackMap[message.header.requestId];
839 if (c == null) { 882 if (callback == null) {
840 proxyError( 883 proxyError(
841 "Message had unknown request Id: ${message.header.requestId}"); 884 "Message had unknown request Id: ${message.header.requestId}");
842 return; 885 return;
843 } 886 }
844 completerMap.remove(message.header.requestId); 887 callbackMap.remove(message.header.requestId);
845 if (c.isCompleted) { 888 callback(r.count );
846 proxyError("Response completer already completed");
847 return;
848 }
849 c.complete(r);
850 break; 889 break;
851 case _contactsServiceMethodGetName: 890 case _contactsServiceMethodGetName:
852 var r = ContactsServiceGetResponseParams.deserialize( 891 var r = ContactsServiceGetResponseParams.deserialize(
853 message.payload); 892 message.payload);
854 if (!message.header.hasRequestId) { 893 if (!message.header.hasRequestId) {
855 proxyError("Expected a message with a valid request Id."); 894 proxyError("Expected a message with a valid request Id.");
856 return; 895 return;
857 } 896 }
858 Completer c = completerMap[message.header.requestId]; 897 Function callback = callbackMap[message.header.requestId];
859 if (c == null) { 898 if (callback == null) {
860 proxyError( 899 proxyError(
861 "Message had unknown request Id: ${message.header.requestId}"); 900 "Message had unknown request Id: ${message.header.requestId}");
862 return; 901 return;
863 } 902 }
864 completerMap.remove(message.header.requestId); 903 callbackMap.remove(message.header.requestId);
865 if (c.isCompleted) { 904 callback(r.contacts );
866 proxyError("Response completer already completed");
867 return;
868 }
869 c.complete(r);
870 break; 905 break;
871 case _contactsServiceMethodGetEmailsName: 906 case _contactsServiceMethodGetEmailsName:
872 var r = ContactsServiceGetEmailsResponseParams.deserialize( 907 var r = ContactsServiceGetEmailsResponseParams.deserialize(
873 message.payload); 908 message.payload);
874 if (!message.header.hasRequestId) { 909 if (!message.header.hasRequestId) {
875 proxyError("Expected a message with a valid request Id."); 910 proxyError("Expected a message with a valid request Id.");
876 return; 911 return;
877 } 912 }
878 Completer c = completerMap[message.header.requestId]; 913 Function callback = callbackMap[message.header.requestId];
879 if (c == null) { 914 if (callback == null) {
880 proxyError( 915 proxyError(
881 "Message had unknown request Id: ${message.header.requestId}"); 916 "Message had unknown request Id: ${message.header.requestId}");
882 return; 917 return;
883 } 918 }
884 completerMap.remove(message.header.requestId); 919 callbackMap.remove(message.header.requestId);
885 if (c.isCompleted) { 920 callback(r.emails );
886 proxyError("Response completer already completed");
887 return;
888 }
889 c.complete(r);
890 break; 921 break;
891 case _contactsServiceMethodGetPhotoName: 922 case _contactsServiceMethodGetPhotoName:
892 var r = ContactsServiceGetPhotoResponseParams.deserialize( 923 var r = ContactsServiceGetPhotoResponseParams.deserialize(
893 message.payload); 924 message.payload);
894 if (!message.header.hasRequestId) { 925 if (!message.header.hasRequestId) {
895 proxyError("Expected a message with a valid request Id."); 926 proxyError("Expected a message with a valid request Id.");
896 return; 927 return;
897 } 928 }
898 Completer c = completerMap[message.header.requestId]; 929 Function callback = callbackMap[message.header.requestId];
899 if (c == null) { 930 if (callback == null) {
900 proxyError( 931 proxyError(
901 "Message had unknown request Id: ${message.header.requestId}"); 932 "Message had unknown request Id: ${message.header.requestId}");
902 return; 933 return;
903 } 934 }
904 completerMap.remove(message.header.requestId); 935 callbackMap.remove(message.header.requestId);
905 if (c.isCompleted) { 936 callback(r.photoUrl );
906 proxyError("Response completer already completed");
907 return;
908 }
909 c.complete(r);
910 break; 937 break;
911 default: 938 default:
912 proxyError("Unexpected message type: ${message.header.type}"); 939 proxyError("Unexpected message type: ${message.header.type}");
913 close(immediate: true); 940 close(immediate: true);
914 break; 941 break;
915 } 942 }
916 } 943 }
917 944
918 @override 945 @override
919 String toString() { 946 String toString() {
(...skipping 24 matching lines...) Expand all
944 return newMockedProxy; 971 return newMockedProxy;
945 } 972 }
946 973
947 static ContactsServiceProxy newFromEndpoint( 974 static ContactsServiceProxy newFromEndpoint(
948 core.MojoMessagePipeEndpoint endpoint) { 975 core.MojoMessagePipeEndpoint endpoint) {
949 assert(endpoint.setDescription("For ContactsServiceProxy")); 976 assert(endpoint.setDescription("For ContactsServiceProxy"));
950 return new ContactsServiceProxy.fromEndpoint(endpoint); 977 return new ContactsServiceProxy.fromEndpoint(endpoint);
951 } 978 }
952 979
953 980
954 dynamic getCount(String filter,[Function responseFactory = null]) { 981 void getCount(String filter,void callback(int count)) {
955 if (impl != null) { 982 if (impl != null) {
956 return new Future(() => impl.getCount(filter,_ContactsServiceStubControl._ contactsServiceGetCountResponseParamsFactory)); 983 impl.getCount(filter,callback);
984 return;
957 } 985 }
958 var params = new _ContactsServiceGetCountParams(); 986 var params = new _ContactsServiceGetCountParams();
959 params.filter = filter; 987 params.filter = filter;
960 return ctrl.sendMessageWithRequestId( 988 ctrl.sendMessageWithRequestId(
961 params, 989 params,
962 _contactsServiceMethodGetCountName, 990 _contactsServiceMethodGetCountName,
963 -1, 991 -1,
964 bindings.MessageHeader.kMessageExpectsResponse); 992 bindings.MessageHeader.kMessageExpectsResponse,
993 callback);
965 } 994 }
966 dynamic get(String filter,int offset,int limit,[Function responseFactory = nul l]) { 995 void get(String filter,int offset,int limit,void callback(List<Contact> contac ts)) {
967 if (impl != null) { 996 if (impl != null) {
968 return new Future(() => impl.get(filter,offset,limit,_ContactsServiceStubC ontrol._contactsServiceGetResponseParamsFactory)); 997 impl.get(filter,offset,limit,callback);
998 return;
969 } 999 }
970 var params = new _ContactsServiceGetParams(); 1000 var params = new _ContactsServiceGetParams();
971 params.filter = filter; 1001 params.filter = filter;
972 params.offset = offset; 1002 params.offset = offset;
973 params.limit = limit; 1003 params.limit = limit;
974 return ctrl.sendMessageWithRequestId( 1004 ctrl.sendMessageWithRequestId(
975 params, 1005 params,
976 _contactsServiceMethodGetName, 1006 _contactsServiceMethodGetName,
977 -1, 1007 -1,
978 bindings.MessageHeader.kMessageExpectsResponse); 1008 bindings.MessageHeader.kMessageExpectsResponse,
1009 callback);
979 } 1010 }
980 dynamic getEmails(int id,[Function responseFactory = null]) { 1011 void getEmails(int id,void callback(List<String> emails)) {
981 if (impl != null) { 1012 if (impl != null) {
982 return new Future(() => impl.getEmails(id,_ContactsServiceStubControl._con tactsServiceGetEmailsResponseParamsFactory)); 1013 impl.getEmails(id,callback);
1014 return;
983 } 1015 }
984 var params = new _ContactsServiceGetEmailsParams(); 1016 var params = new _ContactsServiceGetEmailsParams();
985 params.id = id; 1017 params.id = id;
986 return ctrl.sendMessageWithRequestId( 1018 ctrl.sendMessageWithRequestId(
987 params, 1019 params,
988 _contactsServiceMethodGetEmailsName, 1020 _contactsServiceMethodGetEmailsName,
989 -1, 1021 -1,
990 bindings.MessageHeader.kMessageExpectsResponse); 1022 bindings.MessageHeader.kMessageExpectsResponse,
1023 callback);
991 } 1024 }
992 dynamic getPhoto(int id,bool highResolution,[Function responseFactory = null]) { 1025 void getPhoto(int id,bool highResolution,void callback(String photoUrl)) {
993 if (impl != null) { 1026 if (impl != null) {
994 return new Future(() => impl.getPhoto(id,highResolution,_ContactsServiceSt ubControl._contactsServiceGetPhotoResponseParamsFactory)); 1027 impl.getPhoto(id,highResolution,callback);
1028 return;
995 } 1029 }
996 var params = new _ContactsServiceGetPhotoParams(); 1030 var params = new _ContactsServiceGetPhotoParams();
997 params.id = id; 1031 params.id = id;
998 params.highResolution = highResolution; 1032 params.highResolution = highResolution;
999 return ctrl.sendMessageWithRequestId( 1033 ctrl.sendMessageWithRequestId(
1000 params, 1034 params,
1001 _contactsServiceMethodGetPhotoName, 1035 _contactsServiceMethodGetPhotoName,
1002 -1, 1036 -1,
1003 bindings.MessageHeader.kMessageExpectsResponse); 1037 bindings.MessageHeader.kMessageExpectsResponse,
1038 callback);
1004 } 1039 }
1005 } 1040 }
1006 1041
1007 class _ContactsServiceStubControl 1042 class _ContactsServiceStubControl
1008 extends bindings.StubMessageHandler 1043 extends bindings.StubMessageHandler
1009 implements bindings.StubControl<ContactsService> { 1044 implements bindings.StubControl<ContactsService> {
1010 ContactsService _impl; 1045 ContactsService _impl;
1011 1046
1012 _ContactsServiceStubControl.fromEndpoint( 1047 _ContactsServiceStubControl.fromEndpoint(
1013 core.MojoMessagePipeEndpoint endpoint, [ContactsService impl]) 1048 core.MojoMessagePipeEndpoint endpoint, [ContactsService impl])
1014 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 1049 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
1015 _impl = impl; 1050 _impl = impl;
1016 } 1051 }
1017 1052
1018 _ContactsServiceStubControl.fromHandle( 1053 _ContactsServiceStubControl.fromHandle(
1019 core.MojoHandle handle, [ContactsService impl]) 1054 core.MojoHandle handle, [ContactsService impl])
1020 : super.fromHandle(handle, autoBegin: impl != null) { 1055 : super.fromHandle(handle, autoBegin: impl != null) {
1021 _impl = impl; 1056 _impl = impl;
1022 } 1057 }
1023 1058
1024 _ContactsServiceStubControl.unbound([this._impl]) : super.unbound(); 1059 _ContactsServiceStubControl.unbound([this._impl]) : super.unbound();
1025 1060
1026 String get serviceName => ContactsService.serviceName; 1061 String get serviceName => ContactsService.serviceName;
1027 1062
1028 1063
1029 static ContactsServiceGetCountResponseParams _contactsServiceGetCountResponseP aramsFactory(int count) { 1064 Function _contactsServiceGetCountResponseParamsResponder(
1030 var result = new ContactsServiceGetCountResponseParams(); 1065 int requestId) {
1031 result.count = count; 1066 return (int count) {
1032 return result; 1067 var result = new ContactsServiceGetCountResponseParams();
1068 result.count = count;
1069 sendResponse(buildResponseWithId(
1070 result,
1071 _contactsServiceMethodGetCountName,
1072 requestId,
1073 bindings.MessageHeader.kMessageIsResponse));
1074 };
1033 } 1075 }
1034 static ContactsServiceGetResponseParams _contactsServiceGetResponseParamsFacto ry(List<Contact> contacts) { 1076 Function _contactsServiceGetResponseParamsResponder(
1035 var result = new ContactsServiceGetResponseParams(); 1077 int requestId) {
1036 result.contacts = contacts; 1078 return (List<Contact> contacts) {
1037 return result; 1079 var result = new ContactsServiceGetResponseParams();
1080 result.contacts = contacts;
1081 sendResponse(buildResponseWithId(
1082 result,
1083 _contactsServiceMethodGetName,
1084 requestId,
1085 bindings.MessageHeader.kMessageIsResponse));
1086 };
1038 } 1087 }
1039 static ContactsServiceGetEmailsResponseParams _contactsServiceGetEmailsRespons eParamsFactory(List<String> emails) { 1088 Function _contactsServiceGetEmailsResponseParamsResponder(
1040 var result = new ContactsServiceGetEmailsResponseParams(); 1089 int requestId) {
1041 result.emails = emails; 1090 return (List<String> emails) {
1042 return result; 1091 var result = new ContactsServiceGetEmailsResponseParams();
1092 result.emails = emails;
1093 sendResponse(buildResponseWithId(
1094 result,
1095 _contactsServiceMethodGetEmailsName,
1096 requestId,
1097 bindings.MessageHeader.kMessageIsResponse));
1098 };
1043 } 1099 }
1044 static ContactsServiceGetPhotoResponseParams _contactsServiceGetPhotoResponseP aramsFactory(String photoUrl) { 1100 Function _contactsServiceGetPhotoResponseParamsResponder(
1045 var result = new ContactsServiceGetPhotoResponseParams(); 1101 int requestId) {
1046 result.photoUrl = photoUrl; 1102 return (String photoUrl) {
1047 return result; 1103 var result = new ContactsServiceGetPhotoResponseParams();
1104 result.photoUrl = photoUrl;
1105 sendResponse(buildResponseWithId(
1106 result,
1107 _contactsServiceMethodGetPhotoName,
1108 requestId,
1109 bindings.MessageHeader.kMessageIsResponse));
1110 };
1048 } 1111 }
1049 1112
1050 dynamic handleMessage(bindings.ServiceMessage message) { 1113 void handleMessage(bindings.ServiceMessage message) {
1051 if (bindings.ControlMessageHandler.isControlMessage(message)) { 1114 if (bindings.ControlMessageHandler.isControlMessage(message)) {
1052 return bindings.ControlMessageHandler.handleMessage(this, 1115 bindings.ControlMessageHandler.handleMessage(
1053 0, 1116 this, 0, message);
1054 message); 1117 return;
1055 } 1118 }
1056 if (_impl == null) { 1119 if (_impl == null) {
1057 throw new core.MojoApiError("$this has no implementation set"); 1120 throw new core.MojoApiError("$this has no implementation set");
1058 } 1121 }
1059 switch (message.header.type) { 1122 switch (message.header.type) {
1060 case _contactsServiceMethodGetCountName: 1123 case _contactsServiceMethodGetCountName:
1061 var params = _ContactsServiceGetCountParams.deserialize( 1124 var params = _ContactsServiceGetCountParams.deserialize(
1062 message.payload); 1125 message.payload);
1063 var response = _impl.getCount(params.filter,_contactsServiceGetCountResp onseParamsFactory); 1126 _impl.getCount(params.filter, _contactsServiceGetCountResponseParamsResp onder(message.header.requestId));
1064 if (response is Future) {
1065 return response.then((response) {
1066 if (response != null) {
1067 return buildResponseWithId(
1068 response,
1069 _contactsServiceMethodGetCountName,
1070 message.header.requestId,
1071 bindings.MessageHeader.kMessageIsResponse);
1072 }
1073 });
1074 } else if (response != null) {
1075 return buildResponseWithId(
1076 response,
1077 _contactsServiceMethodGetCountName,
1078 message.header.requestId,
1079 bindings.MessageHeader.kMessageIsResponse);
1080 }
1081 break; 1127 break;
1082 case _contactsServiceMethodGetName: 1128 case _contactsServiceMethodGetName:
1083 var params = _ContactsServiceGetParams.deserialize( 1129 var params = _ContactsServiceGetParams.deserialize(
1084 message.payload); 1130 message.payload);
1085 var response = _impl.get(params.filter,params.offset,params.limit,_conta ctsServiceGetResponseParamsFactory); 1131 _impl.get(params.filter, params.offset, params.limit, _contactsServiceGe tResponseParamsResponder(message.header.requestId));
1086 if (response is Future) {
1087 return response.then((response) {
1088 if (response != null) {
1089 return buildResponseWithId(
1090 response,
1091 _contactsServiceMethodGetName,
1092 message.header.requestId,
1093 bindings.MessageHeader.kMessageIsResponse);
1094 }
1095 });
1096 } else if (response != null) {
1097 return buildResponseWithId(
1098 response,
1099 _contactsServiceMethodGetName,
1100 message.header.requestId,
1101 bindings.MessageHeader.kMessageIsResponse);
1102 }
1103 break; 1132 break;
1104 case _contactsServiceMethodGetEmailsName: 1133 case _contactsServiceMethodGetEmailsName:
1105 var params = _ContactsServiceGetEmailsParams.deserialize( 1134 var params = _ContactsServiceGetEmailsParams.deserialize(
1106 message.payload); 1135 message.payload);
1107 var response = _impl.getEmails(params.id,_contactsServiceGetEmailsRespon seParamsFactory); 1136 _impl.getEmails(params.id, _contactsServiceGetEmailsResponseParamsRespon der(message.header.requestId));
1108 if (response is Future) {
1109 return response.then((response) {
1110 if (response != null) {
1111 return buildResponseWithId(
1112 response,
1113 _contactsServiceMethodGetEmailsName,
1114 message.header.requestId,
1115 bindings.MessageHeader.kMessageIsResponse);
1116 }
1117 });
1118 } else if (response != null) {
1119 return buildResponseWithId(
1120 response,
1121 _contactsServiceMethodGetEmailsName,
1122 message.header.requestId,
1123 bindings.MessageHeader.kMessageIsResponse);
1124 }
1125 break; 1137 break;
1126 case _contactsServiceMethodGetPhotoName: 1138 case _contactsServiceMethodGetPhotoName:
1127 var params = _ContactsServiceGetPhotoParams.deserialize( 1139 var params = _ContactsServiceGetPhotoParams.deserialize(
1128 message.payload); 1140 message.payload);
1129 var response = _impl.getPhoto(params.id,params.highResolution,_contactsS erviceGetPhotoResponseParamsFactory); 1141 _impl.getPhoto(params.id, params.highResolution, _contactsServiceGetPhot oResponseParamsResponder(message.header.requestId));
1130 if (response is Future) {
1131 return response.then((response) {
1132 if (response != null) {
1133 return buildResponseWithId(
1134 response,
1135 _contactsServiceMethodGetPhotoName,
1136 message.header.requestId,
1137 bindings.MessageHeader.kMessageIsResponse);
1138 }
1139 });
1140 } else if (response != null) {
1141 return buildResponseWithId(
1142 response,
1143 _contactsServiceMethodGetPhotoName,
1144 message.header.requestId,
1145 bindings.MessageHeader.kMessageIsResponse);
1146 }
1147 break; 1142 break;
1148 default: 1143 default:
1149 throw new bindings.MojoCodecError("Unexpected message name"); 1144 throw new bindings.MojoCodecError("Unexpected message name");
1150 break; 1145 break;
1151 } 1146 }
1152 return null;
1153 } 1147 }
1154 1148
1155 ContactsService get impl => _impl; 1149 ContactsService get impl => _impl;
1156 set impl(ContactsService d) { 1150 set impl(ContactsService d) {
1157 if (d == null) { 1151 if (d == null) {
1158 throw new core.MojoApiError("$this: Cannot set a null implementation"); 1152 throw new core.MojoApiError("$this: Cannot set a null implementation");
1159 } 1153 }
1160 if (isBound && (_impl == null)) { 1154 if (isBound && (_impl == null)) {
1161 beginHandlingEvents(); 1155 beginHandlingEvents();
1162 } 1156 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 core.MojoHandle handle, [ContactsService impl]) 1190 core.MojoHandle handle, [ContactsService impl])
1197 : super(new _ContactsServiceStubControl.fromHandle(handle, impl)); 1191 : super(new _ContactsServiceStubControl.fromHandle(handle, impl));
1198 1192
1199 static ContactsServiceStub newFromEndpoint( 1193 static ContactsServiceStub newFromEndpoint(
1200 core.MojoMessagePipeEndpoint endpoint) { 1194 core.MojoMessagePipeEndpoint endpoint) {
1201 assert(endpoint.setDescription("For ContactsServiceStub")); 1195 assert(endpoint.setDescription("For ContactsServiceStub"));
1202 return new ContactsServiceStub.fromEndpoint(endpoint); 1196 return new ContactsServiceStub.fromEndpoint(endpoint);
1203 } 1197 }
1204 1198
1205 1199
1206 dynamic getCount(String filter,[Function responseFactory = null]) { 1200 void getCount(String filter,void callback(int count)) {
1207 return impl.getCount(filter,responseFactory); 1201 return impl.getCount(filter,callback);
1208 } 1202 }
1209 dynamic get(String filter,int offset,int limit,[Function responseFactory = nul l]) { 1203 void get(String filter,int offset,int limit,void callback(List<Contact> contac ts)) {
1210 return impl.get(filter,offset,limit,responseFactory); 1204 return impl.get(filter,offset,limit,callback);
1211 } 1205 }
1212 dynamic getEmails(int id,[Function responseFactory = null]) { 1206 void getEmails(int id,void callback(List<String> emails)) {
1213 return impl.getEmails(id,responseFactory); 1207 return impl.getEmails(id,callback);
1214 } 1208 }
1215 dynamic getPhoto(int id,bool highResolution,[Function responseFactory = null]) { 1209 void getPhoto(int id,bool highResolution,void callback(String photoUrl)) {
1216 return impl.getPhoto(id,highResolution,responseFactory); 1210 return impl.getPhoto(id,highResolution,callback);
1217 } 1211 }
1218 } 1212 }
1219 1213
1220 1214
1221 1215
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698