| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 library 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 factory ContactsServiceInterface.fromEndpoint( | 839 factory ContactsServiceInterface.fromEndpoint( |
| 797 core.MojoMessagePipeEndpoint endpoint, | 840 core.MojoMessagePipeEndpoint endpoint, |
| 798 [ContactsService impl]) => | 841 [ContactsService impl]) => |
| (...skipping 22 matching lines...) Expand all Loading... |
| 821 | 864 |
| 822 void handleResponse(bindings.ServiceMessage message) { | 865 void handleResponse(bindings.ServiceMessage message) { |
| 823 switch (message.header.type) { | 866 switch (message.header.type) { |
| 824 case _contactsServiceMethodGetCountName: | 867 case _contactsServiceMethodGetCountName: |
| 825 var r = ContactsServiceGetCountResponseParams.deserialize( | 868 var r = ContactsServiceGetCountResponseParams.deserialize( |
| 826 message.payload); | 869 message.payload); |
| 827 if (!message.header.hasRequestId) { | 870 if (!message.header.hasRequestId) { |
| 828 proxyError("Expected a message with a valid request Id."); | 871 proxyError("Expected a message with a valid request Id."); |
| 829 return; | 872 return; |
| 830 } | 873 } |
| 831 Completer c = completerMap[message.header.requestId]; | 874 Function callback = callbackMap[message.header.requestId]; |
| 832 if (c == null) { | 875 if (callback == null) { |
| 833 proxyError( | 876 proxyError( |
| 834 "Message had unknown request Id: ${message.header.requestId}"); | 877 "Message had unknown request Id: ${message.header.requestId}"); |
| 835 return; | 878 return; |
| 836 } | 879 } |
| 837 completerMap.remove(message.header.requestId); | 880 callbackMap.remove(message.header.requestId); |
| 838 if (c.isCompleted) { | 881 callback(r.count ); |
| 839 proxyError("Response completer already completed"); | |
| 840 return; | |
| 841 } | |
| 842 c.complete(r); | |
| 843 break; | 882 break; |
| 844 case _contactsServiceMethodGetName: | 883 case _contactsServiceMethodGetName: |
| 845 var r = ContactsServiceGetResponseParams.deserialize( | 884 var r = ContactsServiceGetResponseParams.deserialize( |
| 846 message.payload); | 885 message.payload); |
| 847 if (!message.header.hasRequestId) { | 886 if (!message.header.hasRequestId) { |
| 848 proxyError("Expected a message with a valid request Id."); | 887 proxyError("Expected a message with a valid request Id."); |
| 849 return; | 888 return; |
| 850 } | 889 } |
| 851 Completer c = completerMap[message.header.requestId]; | 890 Function callback = callbackMap[message.header.requestId]; |
| 852 if (c == null) { | 891 if (callback == null) { |
| 853 proxyError( | 892 proxyError( |
| 854 "Message had unknown request Id: ${message.header.requestId}"); | 893 "Message had unknown request Id: ${message.header.requestId}"); |
| 855 return; | 894 return; |
| 856 } | 895 } |
| 857 completerMap.remove(message.header.requestId); | 896 callbackMap.remove(message.header.requestId); |
| 858 if (c.isCompleted) { | 897 callback(r.contacts ); |
| 859 proxyError("Response completer already completed"); | |
| 860 return; | |
| 861 } | |
| 862 c.complete(r); | |
| 863 break; | 898 break; |
| 864 case _contactsServiceMethodGetEmailsName: | 899 case _contactsServiceMethodGetEmailsName: |
| 865 var r = ContactsServiceGetEmailsResponseParams.deserialize( | 900 var r = ContactsServiceGetEmailsResponseParams.deserialize( |
| 866 message.payload); | 901 message.payload); |
| 867 if (!message.header.hasRequestId) { | 902 if (!message.header.hasRequestId) { |
| 868 proxyError("Expected a message with a valid request Id."); | 903 proxyError("Expected a message with a valid request Id."); |
| 869 return; | 904 return; |
| 870 } | 905 } |
| 871 Completer c = completerMap[message.header.requestId]; | 906 Function callback = callbackMap[message.header.requestId]; |
| 872 if (c == null) { | 907 if (callback == null) { |
| 873 proxyError( | 908 proxyError( |
| 874 "Message had unknown request Id: ${message.header.requestId}"); | 909 "Message had unknown request Id: ${message.header.requestId}"); |
| 875 return; | 910 return; |
| 876 } | 911 } |
| 877 completerMap.remove(message.header.requestId); | 912 callbackMap.remove(message.header.requestId); |
| 878 if (c.isCompleted) { | 913 callback(r.emails ); |
| 879 proxyError("Response completer already completed"); | |
| 880 return; | |
| 881 } | |
| 882 c.complete(r); | |
| 883 break; | 914 break; |
| 884 case _contactsServiceMethodGetPhotoName: | 915 case _contactsServiceMethodGetPhotoName: |
| 885 var r = ContactsServiceGetPhotoResponseParams.deserialize( | 916 var r = ContactsServiceGetPhotoResponseParams.deserialize( |
| 886 message.payload); | 917 message.payload); |
| 887 if (!message.header.hasRequestId) { | 918 if (!message.header.hasRequestId) { |
| 888 proxyError("Expected a message with a valid request Id."); | 919 proxyError("Expected a message with a valid request Id."); |
| 889 return; | 920 return; |
| 890 } | 921 } |
| 891 Completer c = completerMap[message.header.requestId]; | 922 Function callback = callbackMap[message.header.requestId]; |
| 892 if (c == null) { | 923 if (callback == null) { |
| 893 proxyError( | 924 proxyError( |
| 894 "Message had unknown request Id: ${message.header.requestId}"); | 925 "Message had unknown request Id: ${message.header.requestId}"); |
| 895 return; | 926 return; |
| 896 } | 927 } |
| 897 completerMap.remove(message.header.requestId); | 928 callbackMap.remove(message.header.requestId); |
| 898 if (c.isCompleted) { | 929 callback(r.photoUrl ); |
| 899 proxyError("Response completer already completed"); | |
| 900 return; | |
| 901 } | |
| 902 c.complete(r); | |
| 903 break; | 930 break; |
| 904 default: | 931 default: |
| 905 proxyError("Unexpected message type: ${message.header.type}"); | 932 proxyError("Unexpected message type: ${message.header.type}"); |
| 906 close(immediate: true); | 933 close(immediate: true); |
| 907 break; | 934 break; |
| 908 } | 935 } |
| 909 } | 936 } |
| 910 | 937 |
| 911 ContactsService get impl => null; | 938 ContactsService get impl => null; |
| 912 set impl(ContactsService _) { | 939 set impl(ContactsService _) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 935 ContactsServiceProxy.unbound() | 962 ContactsServiceProxy.unbound() |
| 936 : super(new _ContactsServiceProxyControl.unbound()); | 963 : super(new _ContactsServiceProxyControl.unbound()); |
| 937 | 964 |
| 938 static ContactsServiceProxy newFromEndpoint( | 965 static ContactsServiceProxy newFromEndpoint( |
| 939 core.MojoMessagePipeEndpoint endpoint) { | 966 core.MojoMessagePipeEndpoint endpoint) { |
| 940 assert(endpoint.setDescription("For ContactsServiceProxy")); | 967 assert(endpoint.setDescription("For ContactsServiceProxy")); |
| 941 return new ContactsServiceProxy.fromEndpoint(endpoint); | 968 return new ContactsServiceProxy.fromEndpoint(endpoint); |
| 942 } | 969 } |
| 943 | 970 |
| 944 | 971 |
| 945 dynamic getCount(String filter,[Function responseFactory = null]) { | 972 void getCount(String filter,void callback(int count)) { |
| 946 var params = new _ContactsServiceGetCountParams(); | 973 var params = new _ContactsServiceGetCountParams(); |
| 947 params.filter = filter; | 974 params.filter = filter; |
| 948 return ctrl.sendMessageWithRequestId( | 975 ctrl.sendMessageWithRequestId( |
| 949 params, | 976 params, |
| 950 _contactsServiceMethodGetCountName, | 977 _contactsServiceMethodGetCountName, |
| 951 -1, | 978 -1, |
| 952 bindings.MessageHeader.kMessageExpectsResponse); | 979 bindings.MessageHeader.kMessageExpectsResponse, |
| 980 callback); |
| 953 } | 981 } |
| 954 dynamic get(String filter,int offset,int limit,[Function responseFactory = nul
l]) { | 982 void get(String filter,int offset,int limit,void callback(List<Contact> contac
ts)) { |
| 955 var params = new _ContactsServiceGetParams(); | 983 var params = new _ContactsServiceGetParams(); |
| 956 params.filter = filter; | 984 params.filter = filter; |
| 957 params.offset = offset; | 985 params.offset = offset; |
| 958 params.limit = limit; | 986 params.limit = limit; |
| 959 return ctrl.sendMessageWithRequestId( | 987 ctrl.sendMessageWithRequestId( |
| 960 params, | 988 params, |
| 961 _contactsServiceMethodGetName, | 989 _contactsServiceMethodGetName, |
| 962 -1, | 990 -1, |
| 963 bindings.MessageHeader.kMessageExpectsResponse); | 991 bindings.MessageHeader.kMessageExpectsResponse, |
| 992 callback); |
| 964 } | 993 } |
| 965 dynamic getEmails(int id,[Function responseFactory = null]) { | 994 void getEmails(int id,void callback(List<String> emails)) { |
| 966 var params = new _ContactsServiceGetEmailsParams(); | 995 var params = new _ContactsServiceGetEmailsParams(); |
| 967 params.id = id; | 996 params.id = id; |
| 968 return ctrl.sendMessageWithRequestId( | 997 ctrl.sendMessageWithRequestId( |
| 969 params, | 998 params, |
| 970 _contactsServiceMethodGetEmailsName, | 999 _contactsServiceMethodGetEmailsName, |
| 971 -1, | 1000 -1, |
| 972 bindings.MessageHeader.kMessageExpectsResponse); | 1001 bindings.MessageHeader.kMessageExpectsResponse, |
| 1002 callback); |
| 973 } | 1003 } |
| 974 dynamic getPhoto(int id,bool highResolution,[Function responseFactory = null])
{ | 1004 void getPhoto(int id,bool highResolution,void callback(String photoUrl)) { |
| 975 var params = new _ContactsServiceGetPhotoParams(); | 1005 var params = new _ContactsServiceGetPhotoParams(); |
| 976 params.id = id; | 1006 params.id = id; |
| 977 params.highResolution = highResolution; | 1007 params.highResolution = highResolution; |
| 978 return ctrl.sendMessageWithRequestId( | 1008 ctrl.sendMessageWithRequestId( |
| 979 params, | 1009 params, |
| 980 _contactsServiceMethodGetPhotoName, | 1010 _contactsServiceMethodGetPhotoName, |
| 981 -1, | 1011 -1, |
| 982 bindings.MessageHeader.kMessageExpectsResponse); | 1012 bindings.MessageHeader.kMessageExpectsResponse, |
| 1013 callback); |
| 983 } | 1014 } |
| 984 } | 1015 } |
| 985 | 1016 |
| 986 class _ContactsServiceStubControl | 1017 class _ContactsServiceStubControl |
| 987 extends bindings.StubMessageHandler | 1018 extends bindings.StubMessageHandler |
| 988 implements bindings.StubControl<ContactsService> { | 1019 implements bindings.StubControl<ContactsService> { |
| 989 ContactsService _impl; | 1020 ContactsService _impl; |
| 990 | 1021 |
| 991 _ContactsServiceStubControl.fromEndpoint( | 1022 _ContactsServiceStubControl.fromEndpoint( |
| 992 core.MojoMessagePipeEndpoint endpoint, [ContactsService impl]) | 1023 core.MojoMessagePipeEndpoint endpoint, [ContactsService impl]) |
| 993 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 1024 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| 994 _impl = impl; | 1025 _impl = impl; |
| 995 } | 1026 } |
| 996 | 1027 |
| 997 _ContactsServiceStubControl.fromHandle( | 1028 _ContactsServiceStubControl.fromHandle( |
| 998 core.MojoHandle handle, [ContactsService impl]) | 1029 core.MojoHandle handle, [ContactsService impl]) |
| 999 : super.fromHandle(handle, autoBegin: impl != null) { | 1030 : super.fromHandle(handle, autoBegin: impl != null) { |
| 1000 _impl = impl; | 1031 _impl = impl; |
| 1001 } | 1032 } |
| 1002 | 1033 |
| 1003 _ContactsServiceStubControl.unbound([this._impl]) : super.unbound(); | 1034 _ContactsServiceStubControl.unbound([this._impl]) : super.unbound(); |
| 1004 | 1035 |
| 1005 String get serviceName => ContactsService.serviceName; | 1036 String get serviceName => ContactsService.serviceName; |
| 1006 | 1037 |
| 1007 | 1038 |
| 1008 ContactsServiceGetCountResponseParams _contactsServiceGetCountResponseParamsFa
ctory(int count) { | 1039 Function _contactsServiceGetCountResponseParamsResponder( |
| 1009 var result = new ContactsServiceGetCountResponseParams(); | 1040 int requestId) { |
| 1010 result.count = count; | 1041 return (int count) { |
| 1011 return result; | 1042 var result = new ContactsServiceGetCountResponseParams(); |
| 1043 result.count = count; |
| 1044 sendResponse(buildResponseWithId( |
| 1045 result, |
| 1046 _contactsServiceMethodGetCountName, |
| 1047 requestId, |
| 1048 bindings.MessageHeader.kMessageIsResponse)); |
| 1049 }; |
| 1012 } | 1050 } |
| 1013 ContactsServiceGetResponseParams _contactsServiceGetResponseParamsFactory(List
<Contact> contacts) { | 1051 Function _contactsServiceGetResponseParamsResponder( |
| 1014 var result = new ContactsServiceGetResponseParams(); | 1052 int requestId) { |
| 1015 result.contacts = contacts; | 1053 return (List<Contact> contacts) { |
| 1016 return result; | 1054 var result = new ContactsServiceGetResponseParams(); |
| 1055 result.contacts = contacts; |
| 1056 sendResponse(buildResponseWithId( |
| 1057 result, |
| 1058 _contactsServiceMethodGetName, |
| 1059 requestId, |
| 1060 bindings.MessageHeader.kMessageIsResponse)); |
| 1061 }; |
| 1017 } | 1062 } |
| 1018 ContactsServiceGetEmailsResponseParams _contactsServiceGetEmailsResponseParams
Factory(List<String> emails) { | 1063 Function _contactsServiceGetEmailsResponseParamsResponder( |
| 1019 var result = new ContactsServiceGetEmailsResponseParams(); | 1064 int requestId) { |
| 1020 result.emails = emails; | 1065 return (List<String> emails) { |
| 1021 return result; | 1066 var result = new ContactsServiceGetEmailsResponseParams(); |
| 1067 result.emails = emails; |
| 1068 sendResponse(buildResponseWithId( |
| 1069 result, |
| 1070 _contactsServiceMethodGetEmailsName, |
| 1071 requestId, |
| 1072 bindings.MessageHeader.kMessageIsResponse)); |
| 1073 }; |
| 1022 } | 1074 } |
| 1023 ContactsServiceGetPhotoResponseParams _contactsServiceGetPhotoResponseParamsFa
ctory(String photoUrl) { | 1075 Function _contactsServiceGetPhotoResponseParamsResponder( |
| 1024 var result = new ContactsServiceGetPhotoResponseParams(); | 1076 int requestId) { |
| 1025 result.photoUrl = photoUrl; | 1077 return (String photoUrl) { |
| 1026 return result; | 1078 var result = new ContactsServiceGetPhotoResponseParams(); |
| 1079 result.photoUrl = photoUrl; |
| 1080 sendResponse(buildResponseWithId( |
| 1081 result, |
| 1082 _contactsServiceMethodGetPhotoName, |
| 1083 requestId, |
| 1084 bindings.MessageHeader.kMessageIsResponse)); |
| 1085 }; |
| 1027 } | 1086 } |
| 1028 | 1087 |
| 1029 dynamic handleMessage(bindings.ServiceMessage message) { | 1088 void handleMessage(bindings.ServiceMessage message) { |
| 1030 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 1089 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 1031 return bindings.ControlMessageHandler.handleMessage(this, | 1090 bindings.ControlMessageHandler.handleMessage( |
| 1032 0, | 1091 this, 0, message); |
| 1033 message); | 1092 return; |
| 1034 } | 1093 } |
| 1035 if (_impl == null) { | 1094 if (_impl == null) { |
| 1036 throw new core.MojoApiError("$this has no implementation set"); | 1095 throw new core.MojoApiError("$this has no implementation set"); |
| 1037 } | 1096 } |
| 1038 switch (message.header.type) { | 1097 switch (message.header.type) { |
| 1039 case _contactsServiceMethodGetCountName: | 1098 case _contactsServiceMethodGetCountName: |
| 1040 var params = _ContactsServiceGetCountParams.deserialize( | 1099 var params = _ContactsServiceGetCountParams.deserialize( |
| 1041 message.payload); | 1100 message.payload); |
| 1042 var response = _impl.getCount(params.filter,_contactsServiceGetCountResp
onseParamsFactory); | 1101 _impl.getCount(params.filter, _contactsServiceGetCountResponseParamsResp
onder(message.header.requestId)); |
| 1043 if (response is Future) { | |
| 1044 return response.then((response) { | |
| 1045 if (response != null) { | |
| 1046 return buildResponseWithId( | |
| 1047 response, | |
| 1048 _contactsServiceMethodGetCountName, | |
| 1049 message.header.requestId, | |
| 1050 bindings.MessageHeader.kMessageIsResponse); | |
| 1051 } | |
| 1052 }); | |
| 1053 } else if (response != null) { | |
| 1054 return buildResponseWithId( | |
| 1055 response, | |
| 1056 _contactsServiceMethodGetCountName, | |
| 1057 message.header.requestId, | |
| 1058 bindings.MessageHeader.kMessageIsResponse); | |
| 1059 } | |
| 1060 break; | 1102 break; |
| 1061 case _contactsServiceMethodGetName: | 1103 case _contactsServiceMethodGetName: |
| 1062 var params = _ContactsServiceGetParams.deserialize( | 1104 var params = _ContactsServiceGetParams.deserialize( |
| 1063 message.payload); | 1105 message.payload); |
| 1064 var response = _impl.get(params.filter,params.offset,params.limit,_conta
ctsServiceGetResponseParamsFactory); | 1106 _impl.get(params.filter, params.offset, params.limit, _contactsServiceGe
tResponseParamsResponder(message.header.requestId)); |
| 1065 if (response is Future) { | |
| 1066 return response.then((response) { | |
| 1067 if (response != null) { | |
| 1068 return buildResponseWithId( | |
| 1069 response, | |
| 1070 _contactsServiceMethodGetName, | |
| 1071 message.header.requestId, | |
| 1072 bindings.MessageHeader.kMessageIsResponse); | |
| 1073 } | |
| 1074 }); | |
| 1075 } else if (response != null) { | |
| 1076 return buildResponseWithId( | |
| 1077 response, | |
| 1078 _contactsServiceMethodGetName, | |
| 1079 message.header.requestId, | |
| 1080 bindings.MessageHeader.kMessageIsResponse); | |
| 1081 } | |
| 1082 break; | 1107 break; |
| 1083 case _contactsServiceMethodGetEmailsName: | 1108 case _contactsServiceMethodGetEmailsName: |
| 1084 var params = _ContactsServiceGetEmailsParams.deserialize( | 1109 var params = _ContactsServiceGetEmailsParams.deserialize( |
| 1085 message.payload); | 1110 message.payload); |
| 1086 var response = _impl.getEmails(params.id,_contactsServiceGetEmailsRespon
seParamsFactory); | 1111 _impl.getEmails(params.id, _contactsServiceGetEmailsResponseParamsRespon
der(message.header.requestId)); |
| 1087 if (response is Future) { | |
| 1088 return response.then((response) { | |
| 1089 if (response != null) { | |
| 1090 return buildResponseWithId( | |
| 1091 response, | |
| 1092 _contactsServiceMethodGetEmailsName, | |
| 1093 message.header.requestId, | |
| 1094 bindings.MessageHeader.kMessageIsResponse); | |
| 1095 } | |
| 1096 }); | |
| 1097 } else if (response != null) { | |
| 1098 return buildResponseWithId( | |
| 1099 response, | |
| 1100 _contactsServiceMethodGetEmailsName, | |
| 1101 message.header.requestId, | |
| 1102 bindings.MessageHeader.kMessageIsResponse); | |
| 1103 } | |
| 1104 break; | 1112 break; |
| 1105 case _contactsServiceMethodGetPhotoName: | 1113 case _contactsServiceMethodGetPhotoName: |
| 1106 var params = _ContactsServiceGetPhotoParams.deserialize( | 1114 var params = _ContactsServiceGetPhotoParams.deserialize( |
| 1107 message.payload); | 1115 message.payload); |
| 1108 var response = _impl.getPhoto(params.id,params.highResolution,_contactsS
erviceGetPhotoResponseParamsFactory); | 1116 _impl.getPhoto(params.id, params.highResolution, _contactsServiceGetPhot
oResponseParamsResponder(message.header.requestId)); |
| 1109 if (response is Future) { | |
| 1110 return response.then((response) { | |
| 1111 if (response != null) { | |
| 1112 return buildResponseWithId( | |
| 1113 response, | |
| 1114 _contactsServiceMethodGetPhotoName, | |
| 1115 message.header.requestId, | |
| 1116 bindings.MessageHeader.kMessageIsResponse); | |
| 1117 } | |
| 1118 }); | |
| 1119 } else if (response != null) { | |
| 1120 return buildResponseWithId( | |
| 1121 response, | |
| 1122 _contactsServiceMethodGetPhotoName, | |
| 1123 message.header.requestId, | |
| 1124 bindings.MessageHeader.kMessageIsResponse); | |
| 1125 } | |
| 1126 break; | 1117 break; |
| 1127 default: | 1118 default: |
| 1128 throw new bindings.MojoCodecError("Unexpected message name"); | 1119 throw new bindings.MojoCodecError("Unexpected message name"); |
| 1129 break; | 1120 break; |
| 1130 } | 1121 } |
| 1131 return null; | |
| 1132 } | 1122 } |
| 1133 | 1123 |
| 1134 ContactsService get impl => _impl; | 1124 ContactsService get impl => _impl; |
| 1135 set impl(ContactsService d) { | 1125 set impl(ContactsService d) { |
| 1136 if (d == null) { | 1126 if (d == null) { |
| 1137 throw new core.MojoApiError("$this: Cannot set a null implementation"); | 1127 throw new core.MojoApiError("$this: Cannot set a null implementation"); |
| 1138 } | 1128 } |
| 1139 if (isBound && (_impl == null)) { | 1129 if (isBound && (_impl == null)) { |
| 1140 beginHandlingEvents(); | 1130 beginHandlingEvents(); |
| 1141 } | 1131 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 core.MojoHandle handle, [ContactsService impl]) | 1165 core.MojoHandle handle, [ContactsService impl]) |
| 1176 : super(new _ContactsServiceStubControl.fromHandle(handle, impl)); | 1166 : super(new _ContactsServiceStubControl.fromHandle(handle, impl)); |
| 1177 | 1167 |
| 1178 static ContactsServiceStub newFromEndpoint( | 1168 static ContactsServiceStub newFromEndpoint( |
| 1179 core.MojoMessagePipeEndpoint endpoint) { | 1169 core.MojoMessagePipeEndpoint endpoint) { |
| 1180 assert(endpoint.setDescription("For ContactsServiceStub")); | 1170 assert(endpoint.setDescription("For ContactsServiceStub")); |
| 1181 return new ContactsServiceStub.fromEndpoint(endpoint); | 1171 return new ContactsServiceStub.fromEndpoint(endpoint); |
| 1182 } | 1172 } |
| 1183 | 1173 |
| 1184 | 1174 |
| 1185 dynamic getCount(String filter,[Function responseFactory = null]) { | 1175 void getCount(String filter,void callback(int count)) { |
| 1186 return impl.getCount(filter,responseFactory); | 1176 return impl.getCount(filter,callback); |
| 1187 } | 1177 } |
| 1188 dynamic get(String filter,int offset,int limit,[Function responseFactory = nul
l]) { | 1178 void get(String filter,int offset,int limit,void callback(List<Contact> contac
ts)) { |
| 1189 return impl.get(filter,offset,limit,responseFactory); | 1179 return impl.get(filter,offset,limit,callback); |
| 1190 } | 1180 } |
| 1191 dynamic getEmails(int id,[Function responseFactory = null]) { | 1181 void getEmails(int id,void callback(List<String> emails)) { |
| 1192 return impl.getEmails(id,responseFactory); | 1182 return impl.getEmails(id,callback); |
| 1193 } | 1183 } |
| 1194 dynamic getPhoto(int id,bool highResolution,[Function responseFactory = null])
{ | 1184 void getPhoto(int id,bool highResolution,void callback(String photoUrl)) { |
| 1195 return impl.getPhoto(id,highResolution,responseFactory); | 1185 return impl.getPhoto(id,highResolution,callback); |
| 1196 } | 1186 } |
| 1197 } | 1187 } |
| 1198 | 1188 |
| 1199 | 1189 |
| 1200 | 1190 |
| OLD | NEW |