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

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

Issue 2006093002: Dart: Futures -> Callbacks. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Move code from mojo_patch to proxy.dart Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 library authentication_mojom; 5 library authentication_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 _AuthenticationServiceSelectAccountParams extends bindings.Struct { 13 class _AuthenticationServiceSelectAccountParams 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 bool returnLastSelected = false; 17 bool returnLastSelected = false;
18 18
19 _AuthenticationServiceSelectAccountParams() : super(kVersions.last.size); 19 _AuthenticationServiceSelectAccountParams() : super(kVersions.last.size);
20 20
21 _AuthenticationServiceSelectAccountParams.init(
22 bool this.returnLastSelected
23 ) : super(kVersions.last.size);
24
21 static _AuthenticationServiceSelectAccountParams deserialize(bindings.Message message) { 25 static _AuthenticationServiceSelectAccountParams 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 _AuthenticationServiceSelectAccountParams decode(bindings.Decoder decod er0) { 34 static _AuthenticationServiceSelectAccountParams decode(bindings.Decoder decod er0) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 88
85 class AuthenticationServiceSelectAccountResponseParams extends bindings.Struct { 89 class AuthenticationServiceSelectAccountResponseParams extends bindings.Struct {
86 static const List<bindings.StructDataHeader> kVersions = const [ 90 static const List<bindings.StructDataHeader> kVersions = const [
87 const bindings.StructDataHeader(24, 0) 91 const bindings.StructDataHeader(24, 0)
88 ]; 92 ];
89 String username = null; 93 String username = null;
90 String error = null; 94 String error = null;
91 95
92 AuthenticationServiceSelectAccountResponseParams() : super(kVersions.last.size ); 96 AuthenticationServiceSelectAccountResponseParams() : super(kVersions.last.size );
93 97
98 AuthenticationServiceSelectAccountResponseParams.init(
99 String this.username,
100 String this.error
101 ) : super(kVersions.last.size);
102
94 static AuthenticationServiceSelectAccountResponseParams deserialize(bindings.M essage message) { 103 static AuthenticationServiceSelectAccountResponseParams deserialize(bindings.M essage message) {
95 var decoder = new bindings.Decoder(message); 104 var decoder = new bindings.Decoder(message);
96 var result = decode(decoder); 105 var result = decode(decoder);
97 if (decoder.excessHandles != null) { 106 if (decoder.excessHandles != null) {
98 decoder.excessHandles.forEach((h) => h.close()); 107 decoder.excessHandles.forEach((h) => h.close());
99 } 108 }
100 return result; 109 return result;
101 } 110 }
102 111
103 static AuthenticationServiceSelectAccountResponseParams decode(bindings.Decode r decoder0) { 112 static AuthenticationServiceSelectAccountResponseParams decode(bindings.Decode r decoder0) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 179
171 class _AuthenticationServiceGetOAuth2TokenParams extends bindings.Struct { 180 class _AuthenticationServiceGetOAuth2TokenParams extends bindings.Struct {
172 static const List<bindings.StructDataHeader> kVersions = const [ 181 static const List<bindings.StructDataHeader> kVersions = const [
173 const bindings.StructDataHeader(24, 0) 182 const bindings.StructDataHeader(24, 0)
174 ]; 183 ];
175 String username = null; 184 String username = null;
176 List<String> scopes = null; 185 List<String> scopes = null;
177 186
178 _AuthenticationServiceGetOAuth2TokenParams() : super(kVersions.last.size); 187 _AuthenticationServiceGetOAuth2TokenParams() : super(kVersions.last.size);
179 188
189 _AuthenticationServiceGetOAuth2TokenParams.init(
190 String this.username,
191 List<String> this.scopes
192 ) : super(kVersions.last.size);
193
180 static _AuthenticationServiceGetOAuth2TokenParams deserialize(bindings.Message message) { 194 static _AuthenticationServiceGetOAuth2TokenParams deserialize(bindings.Message message) {
181 var decoder = new bindings.Decoder(message); 195 var decoder = new bindings.Decoder(message);
182 var result = decode(decoder); 196 var result = decode(decoder);
183 if (decoder.excessHandles != null) { 197 if (decoder.excessHandles != null) {
184 decoder.excessHandles.forEach((h) => h.close()); 198 decoder.excessHandles.forEach((h) => h.close());
185 } 199 }
186 return result; 200 return result;
187 } 201 }
188 202
189 static _AuthenticationServiceGetOAuth2TokenParams decode(bindings.Decoder deco der0) { 203 static _AuthenticationServiceGetOAuth2TokenParams decode(bindings.Decoder deco der0) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 285
272 class AuthenticationServiceGetOAuth2TokenResponseParams extends bindings.Struct { 286 class AuthenticationServiceGetOAuth2TokenResponseParams extends bindings.Struct {
273 static const List<bindings.StructDataHeader> kVersions = const [ 287 static const List<bindings.StructDataHeader> kVersions = const [
274 const bindings.StructDataHeader(24, 0) 288 const bindings.StructDataHeader(24, 0)
275 ]; 289 ];
276 String token = null; 290 String token = null;
277 String error = null; 291 String error = null;
278 292
279 AuthenticationServiceGetOAuth2TokenResponseParams() : super(kVersions.last.siz e); 293 AuthenticationServiceGetOAuth2TokenResponseParams() : super(kVersions.last.siz e);
280 294
295 AuthenticationServiceGetOAuth2TokenResponseParams.init(
296 String this.token,
297 String this.error
298 ) : super(kVersions.last.size);
299
281 static AuthenticationServiceGetOAuth2TokenResponseParams deserialize(bindings. Message message) { 300 static AuthenticationServiceGetOAuth2TokenResponseParams deserialize(bindings. Message message) {
282 var decoder = new bindings.Decoder(message); 301 var decoder = new bindings.Decoder(message);
283 var result = decode(decoder); 302 var result = decode(decoder);
284 if (decoder.excessHandles != null) { 303 if (decoder.excessHandles != null) {
285 decoder.excessHandles.forEach((h) => h.close()); 304 decoder.excessHandles.forEach((h) => h.close());
286 } 305 }
287 return result; 306 return result;
288 } 307 }
289 308
290 static AuthenticationServiceGetOAuth2TokenResponseParams decode(bindings.Decod er decoder0) { 309 static AuthenticationServiceGetOAuth2TokenResponseParams decode(bindings.Decod er decoder0) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 375
357 376
358 class _AuthenticationServiceClearOAuth2TokenParams extends bindings.Struct { 377 class _AuthenticationServiceClearOAuth2TokenParams extends bindings.Struct {
359 static const List<bindings.StructDataHeader> kVersions = const [ 378 static const List<bindings.StructDataHeader> kVersions = const [
360 const bindings.StructDataHeader(16, 0) 379 const bindings.StructDataHeader(16, 0)
361 ]; 380 ];
362 String token = null; 381 String token = null;
363 382
364 _AuthenticationServiceClearOAuth2TokenParams() : super(kVersions.last.size); 383 _AuthenticationServiceClearOAuth2TokenParams() : super(kVersions.last.size);
365 384
385 _AuthenticationServiceClearOAuth2TokenParams.init(
386 String this.token
387 ) : super(kVersions.last.size);
388
366 static _AuthenticationServiceClearOAuth2TokenParams deserialize(bindings.Messa ge message) { 389 static _AuthenticationServiceClearOAuth2TokenParams deserialize(bindings.Messa ge message) {
367 var decoder = new bindings.Decoder(message); 390 var decoder = new bindings.Decoder(message);
368 var result = decode(decoder); 391 var result = decode(decoder);
369 if (decoder.excessHandles != null) { 392 if (decoder.excessHandles != null) {
370 decoder.excessHandles.forEach((h) => h.close()); 393 decoder.excessHandles.forEach((h) => h.close());
371 } 394 }
372 return result; 395 return result;
373 } 396 }
374 397
375 static _AuthenticationServiceClearOAuth2TokenParams decode(bindings.Decoder de coder0) { 398 static _AuthenticationServiceClearOAuth2TokenParams decode(bindings.Decoder de coder0) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 451
429 452
430 class _AuthenticationServiceGetOAuth2DeviceCodeParams extends bindings.Struct { 453 class _AuthenticationServiceGetOAuth2DeviceCodeParams extends bindings.Struct {
431 static const List<bindings.StructDataHeader> kVersions = const [ 454 static const List<bindings.StructDataHeader> kVersions = const [
432 const bindings.StructDataHeader(16, 0) 455 const bindings.StructDataHeader(16, 0)
433 ]; 456 ];
434 List<String> scopes = null; 457 List<String> scopes = null;
435 458
436 _AuthenticationServiceGetOAuth2DeviceCodeParams() : super(kVersions.last.size) ; 459 _AuthenticationServiceGetOAuth2DeviceCodeParams() : super(kVersions.last.size) ;
437 460
461 _AuthenticationServiceGetOAuth2DeviceCodeParams.init(
462 List<String> this.scopes
463 ) : super(kVersions.last.size);
464
438 static _AuthenticationServiceGetOAuth2DeviceCodeParams deserialize(bindings.Me ssage message) { 465 static _AuthenticationServiceGetOAuth2DeviceCodeParams deserialize(bindings.Me ssage message) {
439 var decoder = new bindings.Decoder(message); 466 var decoder = new bindings.Decoder(message);
440 var result = decode(decoder); 467 var result = decode(decoder);
441 if (decoder.excessHandles != null) { 468 if (decoder.excessHandles != null) {
442 decoder.excessHandles.forEach((h) => h.close()); 469 decoder.excessHandles.forEach((h) => h.close());
443 } 470 }
444 return result; 471 return result;
445 } 472 }
446 473
447 static _AuthenticationServiceGetOAuth2DeviceCodeParams decode(bindings.Decoder decoder0) { 474 static _AuthenticationServiceGetOAuth2DeviceCodeParams decode(bindings.Decoder decoder0) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 static const List<bindings.StructDataHeader> kVersions = const [ 545 static const List<bindings.StructDataHeader> kVersions = const [
519 const bindings.StructDataHeader(40, 0) 546 const bindings.StructDataHeader(40, 0)
520 ]; 547 ];
521 String verificationUrl = null; 548 String verificationUrl = null;
522 String deviceCode = null; 549 String deviceCode = null;
523 String userCode = null; 550 String userCode = null;
524 String error = null; 551 String error = null;
525 552
526 AuthenticationServiceGetOAuth2DeviceCodeResponseParams() : super(kVersions.las t.size); 553 AuthenticationServiceGetOAuth2DeviceCodeResponseParams() : super(kVersions.las t.size);
527 554
555 AuthenticationServiceGetOAuth2DeviceCodeResponseParams.init(
556 String this.verificationUrl,
557 String this.deviceCode,
558 String this.userCode,
559 String this.error
560 ) : super(kVersions.last.size);
561
528 static AuthenticationServiceGetOAuth2DeviceCodeResponseParams deserialize(bind ings.Message message) { 562 static AuthenticationServiceGetOAuth2DeviceCodeResponseParams deserialize(bind ings.Message message) {
529 var decoder = new bindings.Decoder(message); 563 var decoder = new bindings.Decoder(message);
530 var result = decode(decoder); 564 var result = decode(decoder);
531 if (decoder.excessHandles != null) { 565 if (decoder.excessHandles != null) {
532 decoder.excessHandles.forEach((h) => h.close()); 566 decoder.excessHandles.forEach((h) => h.close());
533 } 567 }
534 return result; 568 return result;
535 } 569 }
536 570
537 static AuthenticationServiceGetOAuth2DeviceCodeResponseParams decode(bindings. Decoder decoder0) { 571 static AuthenticationServiceGetOAuth2DeviceCodeResponseParams decode(bindings. Decoder decoder0) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 663
630 664
631 class _AuthenticationServiceAddAccountParams extends bindings.Struct { 665 class _AuthenticationServiceAddAccountParams extends bindings.Struct {
632 static const List<bindings.StructDataHeader> kVersions = const [ 666 static const List<bindings.StructDataHeader> kVersions = const [
633 const bindings.StructDataHeader(16, 0) 667 const bindings.StructDataHeader(16, 0)
634 ]; 668 ];
635 String deviceCode = null; 669 String deviceCode = null;
636 670
637 _AuthenticationServiceAddAccountParams() : super(kVersions.last.size); 671 _AuthenticationServiceAddAccountParams() : super(kVersions.last.size);
638 672
673 _AuthenticationServiceAddAccountParams.init(
674 String this.deviceCode
675 ) : super(kVersions.last.size);
676
639 static _AuthenticationServiceAddAccountParams deserialize(bindings.Message mes sage) { 677 static _AuthenticationServiceAddAccountParams deserialize(bindings.Message mes sage) {
640 var decoder = new bindings.Decoder(message); 678 var decoder = new bindings.Decoder(message);
641 var result = decode(decoder); 679 var result = decode(decoder);
642 if (decoder.excessHandles != null) { 680 if (decoder.excessHandles != null) {
643 decoder.excessHandles.forEach((h) => h.close()); 681 decoder.excessHandles.forEach((h) => h.close());
644 } 682 }
645 return result; 683 return result;
646 } 684 }
647 685
648 static _AuthenticationServiceAddAccountParams decode(bindings.Decoder decoder0 ) { 686 static _AuthenticationServiceAddAccountParams decode(bindings.Decoder decoder0 ) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 740
703 class AuthenticationServiceAddAccountResponseParams extends bindings.Struct { 741 class AuthenticationServiceAddAccountResponseParams extends bindings.Struct {
704 static const List<bindings.StructDataHeader> kVersions = const [ 742 static const List<bindings.StructDataHeader> kVersions = const [
705 const bindings.StructDataHeader(24, 0) 743 const bindings.StructDataHeader(24, 0)
706 ]; 744 ];
707 String username = null; 745 String username = null;
708 String error = null; 746 String error = null;
709 747
710 AuthenticationServiceAddAccountResponseParams() : super(kVersions.last.size); 748 AuthenticationServiceAddAccountResponseParams() : super(kVersions.last.size);
711 749
750 AuthenticationServiceAddAccountResponseParams.init(
751 String this.username,
752 String this.error
753 ) : super(kVersions.last.size);
754
712 static AuthenticationServiceAddAccountResponseParams deserialize(bindings.Mess age message) { 755 static AuthenticationServiceAddAccountResponseParams deserialize(bindings.Mess age message) {
713 var decoder = new bindings.Decoder(message); 756 var decoder = new bindings.Decoder(message);
714 var result = decode(decoder); 757 var result = decode(decoder);
715 if (decoder.excessHandles != null) { 758 if (decoder.excessHandles != null) {
716 decoder.excessHandles.forEach((h) => h.close()); 759 decoder.excessHandles.forEach((h) => h.close());
717 } 760 }
718 return result; 761 return result;
719 } 762 }
720 763
721 static AuthenticationServiceAddAccountResponseParams decode(bindings.Decoder d ecoder0) { 764 static AuthenticationServiceAddAccountResponseParams decode(bindings.Decoder d ecoder0) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 } 828 }
786 } 829 }
787 830
788 const int _authenticationServiceMethodSelectAccountName = 0; 831 const int _authenticationServiceMethodSelectAccountName = 0;
789 const int _authenticationServiceMethodGetOAuth2TokenName = 1; 832 const int _authenticationServiceMethodGetOAuth2TokenName = 1;
790 const int _authenticationServiceMethodClearOAuth2TokenName = 2; 833 const int _authenticationServiceMethodClearOAuth2TokenName = 2;
791 const int _authenticationServiceMethodGetOAuth2DeviceCodeName = 3; 834 const int _authenticationServiceMethodGetOAuth2DeviceCodeName = 3;
792 const int _authenticationServiceMethodAddAccountName = 4; 835 const int _authenticationServiceMethodAddAccountName = 4;
793 836
794 class _AuthenticationServiceServiceDescription implements service_describer.Serv iceDescription { 837 class _AuthenticationServiceServiceDescription implements service_describer.Serv iceDescription {
795 dynamic getTopLevelInterface([Function responseFactory]) => 838 void getTopLevelInterface(Function responder) {
796 responseFactory(null); 839 responder(null);
840 }
797 841
798 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 842 void getTypeDefinition(String typeKey, Function responder) {
799 responseFactory(null); 843 responder(null);
844 }
800 845
801 dynamic getAllTypeDefinitions([Function responseFactory]) => 846 void getAllTypeDefinitions(Function responder) {
802 responseFactory(null); 847 responder(null);
848 }
803 } 849 }
804 850
805 abstract class AuthenticationService { 851 abstract class AuthenticationService {
806 static const String serviceName = "authentication::AuthenticationService"; 852 static const String serviceName = "authentication::AuthenticationService";
807 853
808 static service_describer.ServiceDescription _cachedServiceDescription; 854 static service_describer.ServiceDescription _cachedServiceDescription;
809 static service_describer.ServiceDescription get serviceDescription { 855 static service_describer.ServiceDescription get serviceDescription {
810 if (_cachedServiceDescription == null) { 856 if (_cachedServiceDescription == null) {
811 _cachedServiceDescription = new _AuthenticationServiceServiceDescription() ; 857 _cachedServiceDescription = new _AuthenticationServiceServiceDescription() ;
812 } 858 }
813 return _cachedServiceDescription; 859 return _cachedServiceDescription;
814 } 860 }
815 861
816 static AuthenticationServiceProxy connectToService( 862 static AuthenticationServiceProxy connectToService(
817 bindings.ServiceConnector s, String url, [String serviceName]) { 863 bindings.ServiceConnector s, String url, [String serviceName]) {
818 AuthenticationServiceProxy p = new AuthenticationServiceProxy.unbound(); 864 AuthenticationServiceProxy p = new AuthenticationServiceProxy.unbound();
819 String name = serviceName ?? AuthenticationService.serviceName; 865 String name = serviceName ?? AuthenticationService.serviceName;
820 if ((name == null) || name.isEmpty) { 866 if ((name == null) || name.isEmpty) {
821 throw new core.MojoApiError( 867 throw new core.MojoApiError(
822 "If an interface has no ServiceName, then one must be provided."); 868 "If an interface has no ServiceName, then one must be provided.");
823 } 869 }
824 s.connectToService(url, p, name); 870 s.connectToService(url, p, name);
825 return p; 871 return p;
826 } 872 }
827 dynamic selectAccount(bool returnLastSelected,[Function responseFactory = null ]); 873 void selectAccount(bool returnLastSelected,void callback(String username, Stri ng error));
828 dynamic getOAuth2Token(String username,List<String> scopes,[Function responseF actory = null]); 874 void getOAuth2Token(String username,List<String> scopes,void callback(String t oken, String error));
829 void clearOAuth2Token(String token); 875 void clearOAuth2Token(String token);
830 dynamic getOAuth2DeviceCode(List<String> scopes,[Function responseFactory = nu ll]); 876 void getOAuth2DeviceCode(List<String> scopes,void callback(String verification Url, String deviceCode, String userCode, String error));
831 dynamic addAccount(String deviceCode,[Function responseFactory = null]); 877 void addAccount(String deviceCode,void callback(String username, String error) );
832 } 878 }
833 879
834 abstract class AuthenticationServiceInterface 880 abstract class AuthenticationServiceInterface
835 implements bindings.MojoInterface<AuthenticationService>, 881 implements bindings.MojoInterface<AuthenticationService>,
836 AuthenticationService { 882 AuthenticationService {
837 factory AuthenticationServiceInterface([AuthenticationService impl]) => 883 factory AuthenticationServiceInterface([AuthenticationService impl]) =>
838 new AuthenticationServiceStub.unbound(impl); 884 new AuthenticationServiceStub.unbound(impl);
839 factory AuthenticationServiceInterface.fromEndpoint( 885 factory AuthenticationServiceInterface.fromEndpoint(
840 core.MojoMessagePipeEndpoint endpoint, 886 core.MojoMessagePipeEndpoint endpoint,
841 [AuthenticationService impl]) => 887 [AuthenticationService impl]) =>
(...skipping 22 matching lines...) Expand all
864 910
865 void handleResponse(bindings.ServiceMessage message) { 911 void handleResponse(bindings.ServiceMessage message) {
866 switch (message.header.type) { 912 switch (message.header.type) {
867 case _authenticationServiceMethodSelectAccountName: 913 case _authenticationServiceMethodSelectAccountName:
868 var r = AuthenticationServiceSelectAccountResponseParams.deserialize( 914 var r = AuthenticationServiceSelectAccountResponseParams.deserialize(
869 message.payload); 915 message.payload);
870 if (!message.header.hasRequestId) { 916 if (!message.header.hasRequestId) {
871 proxyError("Expected a message with a valid request Id."); 917 proxyError("Expected a message with a valid request Id.");
872 return; 918 return;
873 } 919 }
874 Completer c = completerMap[message.header.requestId]; 920 Function callback = callbackMap[message.header.requestId];
875 if (c == null) { 921 if (callback == null) {
876 proxyError( 922 proxyError(
877 "Message had unknown request Id: ${message.header.requestId}"); 923 "Message had unknown request Id: ${message.header.requestId}");
878 return; 924 return;
879 } 925 }
880 completerMap.remove(message.header.requestId); 926 callbackMap.remove(message.header.requestId);
881 if (c.isCompleted) { 927 callback(r.username , r.error );
882 proxyError("Response completer already completed");
883 return;
884 }
885 c.complete(r);
886 break; 928 break;
887 case _authenticationServiceMethodGetOAuth2TokenName: 929 case _authenticationServiceMethodGetOAuth2TokenName:
888 var r = AuthenticationServiceGetOAuth2TokenResponseParams.deserialize( 930 var r = AuthenticationServiceGetOAuth2TokenResponseParams.deserialize(
889 message.payload); 931 message.payload);
890 if (!message.header.hasRequestId) { 932 if (!message.header.hasRequestId) {
891 proxyError("Expected a message with a valid request Id."); 933 proxyError("Expected a message with a valid request Id.");
892 return; 934 return;
893 } 935 }
894 Completer c = completerMap[message.header.requestId]; 936 Function callback = callbackMap[message.header.requestId];
895 if (c == null) { 937 if (callback == null) {
896 proxyError( 938 proxyError(
897 "Message had unknown request Id: ${message.header.requestId}"); 939 "Message had unknown request Id: ${message.header.requestId}");
898 return; 940 return;
899 } 941 }
900 completerMap.remove(message.header.requestId); 942 callbackMap.remove(message.header.requestId);
901 if (c.isCompleted) { 943 callback(r.token , r.error );
902 proxyError("Response completer already completed");
903 return;
904 }
905 c.complete(r);
906 break; 944 break;
907 case _authenticationServiceMethodGetOAuth2DeviceCodeName: 945 case _authenticationServiceMethodGetOAuth2DeviceCodeName:
908 var r = AuthenticationServiceGetOAuth2DeviceCodeResponseParams.deseriali ze( 946 var r = AuthenticationServiceGetOAuth2DeviceCodeResponseParams.deseriali ze(
909 message.payload); 947 message.payload);
910 if (!message.header.hasRequestId) { 948 if (!message.header.hasRequestId) {
911 proxyError("Expected a message with a valid request Id."); 949 proxyError("Expected a message with a valid request Id.");
912 return; 950 return;
913 } 951 }
914 Completer c = completerMap[message.header.requestId]; 952 Function callback = callbackMap[message.header.requestId];
915 if (c == null) { 953 if (callback == null) {
916 proxyError( 954 proxyError(
917 "Message had unknown request Id: ${message.header.requestId}"); 955 "Message had unknown request Id: ${message.header.requestId}");
918 return; 956 return;
919 } 957 }
920 completerMap.remove(message.header.requestId); 958 callbackMap.remove(message.header.requestId);
921 if (c.isCompleted) { 959 callback(r.verificationUrl , r.deviceCode , r.userCode , r.error );
922 proxyError("Response completer already completed");
923 return;
924 }
925 c.complete(r);
926 break; 960 break;
927 case _authenticationServiceMethodAddAccountName: 961 case _authenticationServiceMethodAddAccountName:
928 var r = AuthenticationServiceAddAccountResponseParams.deserialize( 962 var r = AuthenticationServiceAddAccountResponseParams.deserialize(
929 message.payload); 963 message.payload);
930 if (!message.header.hasRequestId) { 964 if (!message.header.hasRequestId) {
931 proxyError("Expected a message with a valid request Id."); 965 proxyError("Expected a message with a valid request Id.");
932 return; 966 return;
933 } 967 }
934 Completer c = completerMap[message.header.requestId]; 968 Function callback = callbackMap[message.header.requestId];
935 if (c == null) { 969 if (callback == null) {
936 proxyError( 970 proxyError(
937 "Message had unknown request Id: ${message.header.requestId}"); 971 "Message had unknown request Id: ${message.header.requestId}");
938 return; 972 return;
939 } 973 }
940 completerMap.remove(message.header.requestId); 974 callbackMap.remove(message.header.requestId);
941 if (c.isCompleted) { 975 callback(r.username , r.error );
942 proxyError("Response completer already completed");
943 return;
944 }
945 c.complete(r);
946 break; 976 break;
947 default: 977 default:
948 proxyError("Unexpected message type: ${message.header.type}"); 978 proxyError("Unexpected message type: ${message.header.type}");
949 close(immediate: true); 979 close(immediate: true);
950 break; 980 break;
951 } 981 }
952 } 982 }
953 983
954 AuthenticationService get impl => null; 984 AuthenticationService get impl => null;
955 set impl(AuthenticationService _) { 985 set impl(AuthenticationService _) {
(...skipping 22 matching lines...) Expand all
978 AuthenticationServiceProxy.unbound() 1008 AuthenticationServiceProxy.unbound()
979 : super(new _AuthenticationServiceProxyControl.unbound()); 1009 : super(new _AuthenticationServiceProxyControl.unbound());
980 1010
981 static AuthenticationServiceProxy newFromEndpoint( 1011 static AuthenticationServiceProxy newFromEndpoint(
982 core.MojoMessagePipeEndpoint endpoint) { 1012 core.MojoMessagePipeEndpoint endpoint) {
983 assert(endpoint.setDescription("For AuthenticationServiceProxy")); 1013 assert(endpoint.setDescription("For AuthenticationServiceProxy"));
984 return new AuthenticationServiceProxy.fromEndpoint(endpoint); 1014 return new AuthenticationServiceProxy.fromEndpoint(endpoint);
985 } 1015 }
986 1016
987 1017
988 dynamic selectAccount(bool returnLastSelected,[Function responseFactory = null ]) { 1018 void selectAccount(bool returnLastSelected,void callback(String username, Stri ng error)) {
989 var params = new _AuthenticationServiceSelectAccountParams(); 1019 var params = new _AuthenticationServiceSelectAccountParams();
990 params.returnLastSelected = returnLastSelected; 1020 params.returnLastSelected = returnLastSelected;
991 return ctrl.sendMessageWithRequestId( 1021 ctrl.sendMessageWithRequestId(
992 params, 1022 params,
993 _authenticationServiceMethodSelectAccountName, 1023 _authenticationServiceMethodSelectAccountName,
994 -1, 1024 -1,
995 bindings.MessageHeader.kMessageExpectsResponse); 1025 bindings.MessageHeader.kMessageExpectsResponse,
1026 callback);
996 } 1027 }
997 dynamic getOAuth2Token(String username,List<String> scopes,[Function responseF actory = null]) { 1028 void getOAuth2Token(String username,List<String> scopes,void callback(String t oken, String error)) {
998 var params = new _AuthenticationServiceGetOAuth2TokenParams(); 1029 var params = new _AuthenticationServiceGetOAuth2TokenParams();
999 params.username = username; 1030 params.username = username;
1000 params.scopes = scopes; 1031 params.scopes = scopes;
1001 return ctrl.sendMessageWithRequestId( 1032 ctrl.sendMessageWithRequestId(
1002 params, 1033 params,
1003 _authenticationServiceMethodGetOAuth2TokenName, 1034 _authenticationServiceMethodGetOAuth2TokenName,
1004 -1, 1035 -1,
1005 bindings.MessageHeader.kMessageExpectsResponse); 1036 bindings.MessageHeader.kMessageExpectsResponse,
1037 callback);
1006 } 1038 }
1007 void clearOAuth2Token(String token) { 1039 void clearOAuth2Token(String token) {
1008 if (!ctrl.isBound) { 1040 if (!ctrl.isBound) {
1009 ctrl.proxyError("The Proxy is closed."); 1041 ctrl.proxyError("The Proxy is closed.");
1010 return; 1042 return;
1011 } 1043 }
1012 var params = new _AuthenticationServiceClearOAuth2TokenParams(); 1044 var params = new _AuthenticationServiceClearOAuth2TokenParams();
1013 params.token = token; 1045 params.token = token;
1014 ctrl.sendMessage(params, 1046 ctrl.sendMessage(params,
1015 _authenticationServiceMethodClearOAuth2TokenName); 1047 _authenticationServiceMethodClearOAuth2TokenName);
1016 } 1048 }
1017 dynamic getOAuth2DeviceCode(List<String> scopes,[Function responseFactory = nu ll]) { 1049 void getOAuth2DeviceCode(List<String> scopes,void callback(String verification Url, String deviceCode, String userCode, String error)) {
1018 var params = new _AuthenticationServiceGetOAuth2DeviceCodeParams(); 1050 var params = new _AuthenticationServiceGetOAuth2DeviceCodeParams();
1019 params.scopes = scopes; 1051 params.scopes = scopes;
1020 return ctrl.sendMessageWithRequestId( 1052 ctrl.sendMessageWithRequestId(
1021 params, 1053 params,
1022 _authenticationServiceMethodGetOAuth2DeviceCodeName, 1054 _authenticationServiceMethodGetOAuth2DeviceCodeName,
1023 -1, 1055 -1,
1024 bindings.MessageHeader.kMessageExpectsResponse); 1056 bindings.MessageHeader.kMessageExpectsResponse,
1057 callback);
1025 } 1058 }
1026 dynamic addAccount(String deviceCode,[Function responseFactory = null]) { 1059 void addAccount(String deviceCode,void callback(String username, String error) ) {
1027 var params = new _AuthenticationServiceAddAccountParams(); 1060 var params = new _AuthenticationServiceAddAccountParams();
1028 params.deviceCode = deviceCode; 1061 params.deviceCode = deviceCode;
1029 return ctrl.sendMessageWithRequestId( 1062 ctrl.sendMessageWithRequestId(
1030 params, 1063 params,
1031 _authenticationServiceMethodAddAccountName, 1064 _authenticationServiceMethodAddAccountName,
1032 -1, 1065 -1,
1033 bindings.MessageHeader.kMessageExpectsResponse); 1066 bindings.MessageHeader.kMessageExpectsResponse,
1067 callback);
1034 } 1068 }
1035 } 1069 }
1036 1070
1037 class _AuthenticationServiceStubControl 1071 class _AuthenticationServiceStubControl
1038 extends bindings.StubMessageHandler 1072 extends bindings.StubMessageHandler
1039 implements bindings.StubControl<AuthenticationService> { 1073 implements bindings.StubControl<AuthenticationService> {
1040 AuthenticationService _impl; 1074 AuthenticationService _impl;
1041 1075
1042 _AuthenticationServiceStubControl.fromEndpoint( 1076 _AuthenticationServiceStubControl.fromEndpoint(
1043 core.MojoMessagePipeEndpoint endpoint, [AuthenticationService impl]) 1077 core.MojoMessagePipeEndpoint endpoint, [AuthenticationService impl])
1044 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 1078 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
1045 _impl = impl; 1079 _impl = impl;
1046 } 1080 }
1047 1081
1048 _AuthenticationServiceStubControl.fromHandle( 1082 _AuthenticationServiceStubControl.fromHandle(
1049 core.MojoHandle handle, [AuthenticationService impl]) 1083 core.MojoHandle handle, [AuthenticationService impl])
1050 : super.fromHandle(handle, autoBegin: impl != null) { 1084 : super.fromHandle(handle, autoBegin: impl != null) {
1051 _impl = impl; 1085 _impl = impl;
1052 } 1086 }
1053 1087
1054 _AuthenticationServiceStubControl.unbound([this._impl]) : super.unbound(); 1088 _AuthenticationServiceStubControl.unbound([this._impl]) : super.unbound();
1055 1089
1056 String get serviceName => AuthenticationService.serviceName; 1090 String get serviceName => AuthenticationService.serviceName;
1057 1091
1058 1092
1059 AuthenticationServiceSelectAccountResponseParams _authenticationServiceSelectA ccountResponseParamsFactory(String username, String error) { 1093 Function _authenticationServiceSelectAccountResponseParamsResponder(
1060 var result = new AuthenticationServiceSelectAccountResponseParams(); 1094 int requestId) {
1061 result.username = username; 1095 return (String username, String error) {
1062 result.error = error; 1096 var result = new AuthenticationServiceSelectAccountResponseParams();
1063 return result; 1097 result.username = username;
1098 result.error = error;
1099 sendResponse(buildResponseWithId(
1100 result,
1101 _authenticationServiceMethodSelectAccountName,
1102 requestId,
1103 bindings.MessageHeader.kMessageIsResponse));
1104 };
1064 } 1105 }
1065 AuthenticationServiceGetOAuth2TokenResponseParams _authenticationServiceGetOAu th2TokenResponseParamsFactory(String token, String error) { 1106 Function _authenticationServiceGetOAuth2TokenResponseParamsResponder(
1066 var result = new AuthenticationServiceGetOAuth2TokenResponseParams(); 1107 int requestId) {
1067 result.token = token; 1108 return (String token, String error) {
1068 result.error = error; 1109 var result = new AuthenticationServiceGetOAuth2TokenResponseParams();
1069 return result; 1110 result.token = token;
1111 result.error = error;
1112 sendResponse(buildResponseWithId(
1113 result,
1114 _authenticationServiceMethodGetOAuth2TokenName,
1115 requestId,
1116 bindings.MessageHeader.kMessageIsResponse));
1117 };
1070 } 1118 }
1071 AuthenticationServiceGetOAuth2DeviceCodeResponseParams _authenticationServiceG etOAuth2DeviceCodeResponseParamsFactory(String verificationUrl, String deviceCod e, String userCode, String error) { 1119 Function _authenticationServiceGetOAuth2DeviceCodeResponseParamsResponder(
1072 var result = new AuthenticationServiceGetOAuth2DeviceCodeResponseParams(); 1120 int requestId) {
1073 result.verificationUrl = verificationUrl; 1121 return (String verificationUrl, String deviceCode, String userCode, String err or) {
1074 result.deviceCode = deviceCode; 1122 var result = new AuthenticationServiceGetOAuth2DeviceCodeResponseParams();
1075 result.userCode = userCode; 1123 result.verificationUrl = verificationUrl;
1076 result.error = error; 1124 result.deviceCode = deviceCode;
1077 return result; 1125 result.userCode = userCode;
1126 result.error = error;
1127 sendResponse(buildResponseWithId(
1128 result,
1129 _authenticationServiceMethodGetOAuth2DeviceCodeName,
1130 requestId,
1131 bindings.MessageHeader.kMessageIsResponse));
1132 };
1078 } 1133 }
1079 AuthenticationServiceAddAccountResponseParams _authenticationServiceAddAccount ResponseParamsFactory(String username, String error) { 1134 Function _authenticationServiceAddAccountResponseParamsResponder(
1080 var result = new AuthenticationServiceAddAccountResponseParams(); 1135 int requestId) {
1081 result.username = username; 1136 return (String username, String error) {
1082 result.error = error; 1137 var result = new AuthenticationServiceAddAccountResponseParams();
1083 return result; 1138 result.username = username;
1139 result.error = error;
1140 sendResponse(buildResponseWithId(
1141 result,
1142 _authenticationServiceMethodAddAccountName,
1143 requestId,
1144 bindings.MessageHeader.kMessageIsResponse));
1145 };
1084 } 1146 }
1085 1147
1086 dynamic handleMessage(bindings.ServiceMessage message) { 1148 void handleMessage(bindings.ServiceMessage message) {
1087 if (bindings.ControlMessageHandler.isControlMessage(message)) { 1149 if (bindings.ControlMessageHandler.isControlMessage(message)) {
1088 return bindings.ControlMessageHandler.handleMessage(this, 1150 bindings.ControlMessageHandler.handleMessage(
1089 0, 1151 this, 0, message);
1090 message); 1152 return;
1091 } 1153 }
1092 if (_impl == null) { 1154 if (_impl == null) {
1093 throw new core.MojoApiError("$this has no implementation set"); 1155 throw new core.MojoApiError("$this has no implementation set");
1094 } 1156 }
1095 switch (message.header.type) { 1157 switch (message.header.type) {
1096 case _authenticationServiceMethodSelectAccountName: 1158 case _authenticationServiceMethodSelectAccountName:
1097 var params = _AuthenticationServiceSelectAccountParams.deserialize( 1159 var params = _AuthenticationServiceSelectAccountParams.deserialize(
1098 message.payload); 1160 message.payload);
1099 var response = _impl.selectAccount(params.returnLastSelected,_authentica tionServiceSelectAccountResponseParamsFactory); 1161 _impl.selectAccount(params.returnLastSelected, _authenticationServiceSel ectAccountResponseParamsResponder(message.header.requestId));
1100 if (response is Future) {
1101 return response.then((response) {
1102 if (response != null) {
1103 return buildResponseWithId(
1104 response,
1105 _authenticationServiceMethodSelectAccountName,
1106 message.header.requestId,
1107 bindings.MessageHeader.kMessageIsResponse);
1108 }
1109 });
1110 } else if (response != null) {
1111 return buildResponseWithId(
1112 response,
1113 _authenticationServiceMethodSelectAccountName,
1114 message.header.requestId,
1115 bindings.MessageHeader.kMessageIsResponse);
1116 }
1117 break; 1162 break;
1118 case _authenticationServiceMethodGetOAuth2TokenName: 1163 case _authenticationServiceMethodGetOAuth2TokenName:
1119 var params = _AuthenticationServiceGetOAuth2TokenParams.deserialize( 1164 var params = _AuthenticationServiceGetOAuth2TokenParams.deserialize(
1120 message.payload); 1165 message.payload);
1121 var response = _impl.getOAuth2Token(params.username,params.scopes,_authe nticationServiceGetOAuth2TokenResponseParamsFactory); 1166 _impl.getOAuth2Token(params.username, params.scopes, _authenticationServ iceGetOAuth2TokenResponseParamsResponder(message.header.requestId));
1122 if (response is Future) {
1123 return response.then((response) {
1124 if (response != null) {
1125 return buildResponseWithId(
1126 response,
1127 _authenticationServiceMethodGetOAuth2TokenName,
1128 message.header.requestId,
1129 bindings.MessageHeader.kMessageIsResponse);
1130 }
1131 });
1132 } else if (response != null) {
1133 return buildResponseWithId(
1134 response,
1135 _authenticationServiceMethodGetOAuth2TokenName,
1136 message.header.requestId,
1137 bindings.MessageHeader.kMessageIsResponse);
1138 }
1139 break; 1167 break;
1140 case _authenticationServiceMethodClearOAuth2TokenName: 1168 case _authenticationServiceMethodClearOAuth2TokenName:
1141 var params = _AuthenticationServiceClearOAuth2TokenParams.deserialize( 1169 var params = _AuthenticationServiceClearOAuth2TokenParams.deserialize(
1142 message.payload); 1170 message.payload);
1143 _impl.clearOAuth2Token(params.token); 1171 _impl.clearOAuth2Token(params.token);
1144 break; 1172 break;
1145 case _authenticationServiceMethodGetOAuth2DeviceCodeName: 1173 case _authenticationServiceMethodGetOAuth2DeviceCodeName:
1146 var params = _AuthenticationServiceGetOAuth2DeviceCodeParams.deserialize ( 1174 var params = _AuthenticationServiceGetOAuth2DeviceCodeParams.deserialize (
1147 message.payload); 1175 message.payload);
1148 var response = _impl.getOAuth2DeviceCode(params.scopes,_authenticationSe rviceGetOAuth2DeviceCodeResponseParamsFactory); 1176 _impl.getOAuth2DeviceCode(params.scopes, _authenticationServiceGetOAuth2 DeviceCodeResponseParamsResponder(message.header.requestId));
1149 if (response is Future) {
1150 return response.then((response) {
1151 if (response != null) {
1152 return buildResponseWithId(
1153 response,
1154 _authenticationServiceMethodGetOAuth2DeviceCodeName,
1155 message.header.requestId,
1156 bindings.MessageHeader.kMessageIsResponse);
1157 }
1158 });
1159 } else if (response != null) {
1160 return buildResponseWithId(
1161 response,
1162 _authenticationServiceMethodGetOAuth2DeviceCodeName,
1163 message.header.requestId,
1164 bindings.MessageHeader.kMessageIsResponse);
1165 }
1166 break; 1177 break;
1167 case _authenticationServiceMethodAddAccountName: 1178 case _authenticationServiceMethodAddAccountName:
1168 var params = _AuthenticationServiceAddAccountParams.deserialize( 1179 var params = _AuthenticationServiceAddAccountParams.deserialize(
1169 message.payload); 1180 message.payload);
1170 var response = _impl.addAccount(params.deviceCode,_authenticationService AddAccountResponseParamsFactory); 1181 _impl.addAccount(params.deviceCode, _authenticationServiceAddAccountResp onseParamsResponder(message.header.requestId));
1171 if (response is Future) {
1172 return response.then((response) {
1173 if (response != null) {
1174 return buildResponseWithId(
1175 response,
1176 _authenticationServiceMethodAddAccountName,
1177 message.header.requestId,
1178 bindings.MessageHeader.kMessageIsResponse);
1179 }
1180 });
1181 } else if (response != null) {
1182 return buildResponseWithId(
1183 response,
1184 _authenticationServiceMethodAddAccountName,
1185 message.header.requestId,
1186 bindings.MessageHeader.kMessageIsResponse);
1187 }
1188 break; 1182 break;
1189 default: 1183 default:
1190 throw new bindings.MojoCodecError("Unexpected message name"); 1184 throw new bindings.MojoCodecError("Unexpected message name");
1191 break; 1185 break;
1192 } 1186 }
1193 return null;
1194 } 1187 }
1195 1188
1196 AuthenticationService get impl => _impl; 1189 AuthenticationService get impl => _impl;
1197 set impl(AuthenticationService d) { 1190 set impl(AuthenticationService d) {
1198 if (d == null) { 1191 if (d == null) {
1199 throw new core.MojoApiError("$this: Cannot set a null implementation"); 1192 throw new core.MojoApiError("$this: Cannot set a null implementation");
1200 } 1193 }
1201 if (isBound && (_impl == null)) { 1194 if (isBound && (_impl == null)) {
1202 beginHandlingEvents(); 1195 beginHandlingEvents();
1203 } 1196 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 core.MojoHandle handle, [AuthenticationService impl]) 1230 core.MojoHandle handle, [AuthenticationService impl])
1238 : super(new _AuthenticationServiceStubControl.fromHandle(handle, impl)); 1231 : super(new _AuthenticationServiceStubControl.fromHandle(handle, impl));
1239 1232
1240 static AuthenticationServiceStub newFromEndpoint( 1233 static AuthenticationServiceStub newFromEndpoint(
1241 core.MojoMessagePipeEndpoint endpoint) { 1234 core.MojoMessagePipeEndpoint endpoint) {
1242 assert(endpoint.setDescription("For AuthenticationServiceStub")); 1235 assert(endpoint.setDescription("For AuthenticationServiceStub"));
1243 return new AuthenticationServiceStub.fromEndpoint(endpoint); 1236 return new AuthenticationServiceStub.fromEndpoint(endpoint);
1244 } 1237 }
1245 1238
1246 1239
1247 dynamic selectAccount(bool returnLastSelected,[Function responseFactory = null ]) { 1240 void selectAccount(bool returnLastSelected,void callback(String username, Stri ng error)) {
1248 return impl.selectAccount(returnLastSelected,responseFactory); 1241 return impl.selectAccount(returnLastSelected,callback);
1249 } 1242 }
1250 dynamic getOAuth2Token(String username,List<String> scopes,[Function responseF actory = null]) { 1243 void getOAuth2Token(String username,List<String> scopes,void callback(String t oken, String error)) {
1251 return impl.getOAuth2Token(username,scopes,responseFactory); 1244 return impl.getOAuth2Token(username,scopes,callback);
1252 } 1245 }
1253 void clearOAuth2Token(String token) { 1246 void clearOAuth2Token(String token) {
1254 return impl.clearOAuth2Token(token); 1247 return impl.clearOAuth2Token(token);
1255 } 1248 }
1256 dynamic getOAuth2DeviceCode(List<String> scopes,[Function responseFactory = nu ll]) { 1249 void getOAuth2DeviceCode(List<String> scopes,void callback(String verification Url, String deviceCode, String userCode, String error)) {
1257 return impl.getOAuth2DeviceCode(scopes,responseFactory); 1250 return impl.getOAuth2DeviceCode(scopes,callback);
1258 } 1251 }
1259 dynamic addAccount(String deviceCode,[Function responseFactory = null]) { 1252 void addAccount(String deviceCode,void callback(String username, String error) ) {
1260 return impl.addAccount(deviceCode,responseFactory); 1253 return impl.addAccount(deviceCode,callback);
1261 } 1254 }
1262 } 1255 }
1263 1256
1264 1257
1265 1258
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698