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

Side by Side Diff: mojo/dart/packages/mojo/lib/mojo/bindings/types/service_describer.mojom.dart

Issue 1983453002: Dart: Refactor Stubs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge 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 service_describer_mojom; 5 library service_describer_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 9
10 import 'package:mojo/mojo/bindings/types/mojom_types.mojom.dart' as mojom_types_ mojom; 10 import 'package:mojo/mojo/bindings/types/mojom_types.mojom.dart' as mojom_types_ mojom;
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 567
568 dynamic getAllTypeDefinitions([Function responseFactory]) => 568 dynamic getAllTypeDefinitions([Function responseFactory]) =>
569 responseFactory(null); 569 responseFactory(null);
570 } 570 }
571 571
572 abstract class ServiceDescriber { 572 abstract class ServiceDescriber {
573 static const String serviceName = "mojo::bindings::types::ServiceDescriber"; 573 static const String serviceName = "mojo::bindings::types::ServiceDescriber";
574 void describeService(String interfaceName, Object descriptionRequest); 574 void describeService(String interfaceName, Object descriptionRequest);
575 } 575 }
576 576
577 577 class _ServiceDescriberProxyControl
578 class _ServiceDescriberProxyControl extends bindings.ProxyMessageHandler 578 extends bindings.ProxyMessageHandler
579 implements bindings.ProxyControl { 579 implements bindings.ProxyControl {
580 _ServiceDescriberProxyControl.fromEndpoint( 580 _ServiceDescriberProxyControl.fromEndpoint(
581 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 581 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
582 582
583 _ServiceDescriberProxyControl.fromHandle( 583 _ServiceDescriberProxyControl.fromHandle(
584 core.MojoHandle handle) : super.fromHandle(handle); 584 core.MojoHandle handle) : super.fromHandle(handle);
585 585
586 _ServiceDescriberProxyControl.unbound() : super.unbound(); 586 _ServiceDescriberProxyControl.unbound() : super.unbound();
587 587
588 ServiceDescription get serviceDescription => 588 ServiceDescription get serviceDescription =>
589 new _ServiceDescriberServiceDescription(); 589 new _ServiceDescriberServiceDescription();
590 590
591 String get serviceName => ServiceDescriber.serviceName; 591 String get serviceName => ServiceDescriber.serviceName;
592 592
593 @override
594 void handleResponse(bindings.ServiceMessage message) { 593 void handleResponse(bindings.ServiceMessage message) {
595 switch (message.header.type) { 594 switch (message.header.type) {
596 default: 595 default:
597 proxyError("Unexpected message type: ${message.header.type}"); 596 proxyError("Unexpected message type: ${message.header.type}");
598 close(immediate: true); 597 close(immediate: true);
599 break; 598 break;
600 } 599 }
601 } 600 }
602 601
603 @override 602 @override
604 String toString() { 603 String toString() {
605 var superString = super.toString(); 604 var superString = super.toString();
606 return "_ServiceDescriberProxyControl($superString)"; 605 return "_ServiceDescriberProxyControl($superString)";
607 } 606 }
608 } 607 }
609 608
610 609 class ServiceDescriberProxy
611 class ServiceDescriberProxy extends bindings.Proxy 610 extends bindings.Proxy
612 implements ServiceDescriber { 611 implements ServiceDescriber {
613 ServiceDescriberProxy.fromEndpoint( 612 ServiceDescriberProxy.fromEndpoint(
614 core.MojoMessagePipeEndpoint endpoint) 613 core.MojoMessagePipeEndpoint endpoint)
615 : super(new _ServiceDescriberProxyControl.fromEndpoint(endpoint)); 614 : super(new _ServiceDescriberProxyControl.fromEndpoint(endpoint));
616 615
617 ServiceDescriberProxy.fromHandle(core.MojoHandle handle) 616 ServiceDescriberProxy.fromHandle(core.MojoHandle handle)
618 : super(new _ServiceDescriberProxyControl.fromHandle(handle)); 617 : super(new _ServiceDescriberProxyControl.fromHandle(handle));
619 618
620 ServiceDescriberProxy.unbound() 619 ServiceDescriberProxy.unbound()
621 : super(new _ServiceDescriberProxyControl.unbound()); 620 : super(new _ServiceDescriberProxyControl.unbound());
622 621
(...skipping 17 matching lines...) Expand all
640 return; 639 return;
641 } 640 }
642 var params = new _ServiceDescriberDescribeServiceParams(); 641 var params = new _ServiceDescriberDescribeServiceParams();
643 params.interfaceName = interfaceName; 642 params.interfaceName = interfaceName;
644 params.descriptionRequest = descriptionRequest; 643 params.descriptionRequest = descriptionRequest;
645 ctrl.sendMessage(params, 644 ctrl.sendMessage(params,
646 _serviceDescriberMethodDescribeServiceName); 645 _serviceDescriberMethodDescribeServiceName);
647 } 646 }
648 } 647 }
649 648
650 649 class _ServiceDescriberStubControl
651 class ServiceDescriberStub extends bindings.Stub { 650 extends bindings.StubMessageHandler
651 implements bindings.StubControl<ServiceDescriber> {
652 ServiceDescriber _impl; 652 ServiceDescriber _impl;
653 653
654 ServiceDescriberStub.fromEndpoint( 654 _ServiceDescriberStubControl.fromEndpoint(
655 core.MojoMessagePipeEndpoint endpoint, [ServiceDescriber impl]) 655 core.MojoMessagePipeEndpoint endpoint, [ServiceDescriber impl])
656 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 656 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
657 _impl = impl; 657 _impl = impl;
658 } 658 }
659 659
660 ServiceDescriberStub.fromHandle( 660 _ServiceDescriberStubControl.fromHandle(
661 core.MojoHandle handle, [ServiceDescriber impl]) 661 core.MojoHandle handle, [ServiceDescriber impl])
662 : super.fromHandle(handle, autoBegin: impl != null) { 662 : super.fromHandle(handle, autoBegin: impl != null) {
663 _impl = impl; 663 _impl = impl;
664 } 664 }
665 665
666 ServiceDescriberStub.unbound([this._impl]) : super.unbound(); 666 _ServiceDescriberStubControl.unbound([this._impl]) : super.unbound();
667
668 static ServiceDescriberStub newFromEndpoint(
669 core.MojoMessagePipeEndpoint endpoint) {
670 assert(endpoint.setDescription("For ServiceDescriberStub"));
671 return new ServiceDescriberStub.fromEndpoint(endpoint);
672 }
673 667
674 668
675 669
676 dynamic handleMessage(bindings.ServiceMessage message) { 670 dynamic handleMessage(bindings.ServiceMessage message) {
677 if (bindings.ControlMessageHandler.isControlMessage(message)) { 671 if (bindings.ControlMessageHandler.isControlMessage(message)) {
678 return bindings.ControlMessageHandler.handleMessage(this, 672 return bindings.ControlMessageHandler.handleMessage(this,
679 0, 673 0,
680 message); 674 message);
681 } 675 }
682 if (_impl == null) { 676 if (_impl == null) {
(...skipping 24 matching lines...) Expand all
707 } 701 }
708 702
709 @override 703 @override
710 void bind(core.MojoMessagePipeEndpoint endpoint) { 704 void bind(core.MojoMessagePipeEndpoint endpoint) {
711 super.bind(endpoint); 705 super.bind(endpoint);
712 if (!isOpen && (_impl != null)) { 706 if (!isOpen && (_impl != null)) {
713 beginHandlingEvents(); 707 beginHandlingEvents();
714 } 708 }
715 } 709 }
716 710
711 @override
717 String toString() { 712 String toString() {
718 var superString = super.toString(); 713 var superString = super.toString();
719 return "ServiceDescriberStub($superString)"; 714 return "_ServiceDescriberStubControl($superString)";
720 } 715 }
721 716
722 int get version => 0; 717 int get version => 0;
723 718
724 static ServiceDescription _cachedServiceDescription; 719 static ServiceDescription _cachedServiceDescription;
725 static ServiceDescription get serviceDescription { 720 static ServiceDescription get serviceDescription {
726 if (_cachedServiceDescription == null) { 721 if (_cachedServiceDescription == null) {
727 _cachedServiceDescription = new _ServiceDescriberServiceDescription(); 722 _cachedServiceDescription = new _ServiceDescriberServiceDescription();
728 } 723 }
729 return _cachedServiceDescription; 724 return _cachedServiceDescription;
730 } 725 }
731 } 726 }
732 727
728 class ServiceDescriberStub
729 extends bindings.Stub<ServiceDescriber>
730 implements ServiceDescriber {
731 ServiceDescriberStub.fromEndpoint(
732 core.MojoMessagePipeEndpoint endpoint, [ServiceDescriber impl])
733 : super(new _ServiceDescriberStubControl.fromEndpoint(endpoint, impl));
734
735 ServiceDescriberStub.fromHandle(
736 core.MojoHandle handle, [ServiceDescriber impl])
737 : super(new _ServiceDescriberStubControl.fromHandle(handle, impl));
738
739 ServiceDescriberStub.unbound([ServiceDescriber impl])
740 : super(new _ServiceDescriberStubControl.unbound(impl));
741
742 static ServiceDescriberStub newFromEndpoint(
743 core.MojoMessagePipeEndpoint endpoint) {
744 assert(endpoint.setDescription("For ServiceDescriberStub"));
745 return new ServiceDescriberStub.fromEndpoint(endpoint);
746 }
747
748 static ServiceDescription get serviceDescription =>
749 _ServiceDescriberStubControl.serviceDescription;
750
751
752 void describeService(String interfaceName, Object descriptionRequest) {
753 return impl.describeService(interfaceName, descriptionRequest);
754 }
755 }
756
733 const int _serviceDescriptionMethodGetTopLevelInterfaceName = 0; 757 const int _serviceDescriptionMethodGetTopLevelInterfaceName = 0;
734 const int _serviceDescriptionMethodGetTypeDefinitionName = 1; 758 const int _serviceDescriptionMethodGetTypeDefinitionName = 1;
735 const int _serviceDescriptionMethodGetAllTypeDefinitionsName = 2; 759 const int _serviceDescriptionMethodGetAllTypeDefinitionsName = 2;
736 760
737 class _ServiceDescriptionServiceDescription implements ServiceDescription { 761 class _ServiceDescriptionServiceDescription implements ServiceDescription {
738 dynamic getTopLevelInterface([Function responseFactory]) => 762 dynamic getTopLevelInterface([Function responseFactory]) =>
739 responseFactory(null); 763 responseFactory(null);
740 764
741 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 765 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) =>
742 responseFactory(null); 766 responseFactory(null);
743 767
744 dynamic getAllTypeDefinitions([Function responseFactory]) => 768 dynamic getAllTypeDefinitions([Function responseFactory]) =>
745 responseFactory(null); 769 responseFactory(null);
746 } 770 }
747 771
748 abstract class ServiceDescription { 772 abstract class ServiceDescription {
749 static const String serviceName = null; 773 static const String serviceName = null;
750 dynamic getTopLevelInterface([Function responseFactory = null]); 774 dynamic getTopLevelInterface([Function responseFactory = null]);
751 dynamic getTypeDefinition(String typeKey,[Function responseFactory = null]); 775 dynamic getTypeDefinition(String typeKey,[Function responseFactory = null]);
752 dynamic getAllTypeDefinitions([Function responseFactory = null]); 776 dynamic getAllTypeDefinitions([Function responseFactory = null]);
753 } 777 }
754 778
755 779 class _ServiceDescriptionProxyControl
756 class _ServiceDescriptionProxyControl extends bindings.ProxyMessageHandler 780 extends bindings.ProxyMessageHandler
757 implements bindings.ProxyControl { 781 implements bindings.ProxyControl {
758 _ServiceDescriptionProxyControl.fromEndpoint( 782 _ServiceDescriptionProxyControl.fromEndpoint(
759 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 783 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
760 784
761 _ServiceDescriptionProxyControl.fromHandle( 785 _ServiceDescriptionProxyControl.fromHandle(
762 core.MojoHandle handle) : super.fromHandle(handle); 786 core.MojoHandle handle) : super.fromHandle(handle);
763 787
764 _ServiceDescriptionProxyControl.unbound() : super.unbound(); 788 _ServiceDescriptionProxyControl.unbound() : super.unbound();
765 789
766 ServiceDescription get serviceDescription => 790 ServiceDescription get serviceDescription =>
767 new _ServiceDescriptionServiceDescription(); 791 new _ServiceDescriptionServiceDescription();
768 792
769 String get serviceName => ServiceDescription.serviceName; 793 String get serviceName => ServiceDescription.serviceName;
770 794
771 @override
772 void handleResponse(bindings.ServiceMessage message) { 795 void handleResponse(bindings.ServiceMessage message) {
773 switch (message.header.type) { 796 switch (message.header.type) {
774 case _serviceDescriptionMethodGetTopLevelInterfaceName: 797 case _serviceDescriptionMethodGetTopLevelInterfaceName:
775 var r = ServiceDescriptionGetTopLevelInterfaceResponseParams.deserialize ( 798 var r = ServiceDescriptionGetTopLevelInterfaceResponseParams.deserialize (
776 message.payload); 799 message.payload);
777 if (!message.header.hasRequestId) { 800 if (!message.header.hasRequestId) {
778 proxyError("Expected a message with a valid request Id."); 801 proxyError("Expected a message with a valid request Id.");
779 return; 802 return;
780 } 803 }
781 Completer c = completerMap[message.header.requestId]; 804 Completer c = completerMap[message.header.requestId];
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 } 861 }
839 } 862 }
840 863
841 @override 864 @override
842 String toString() { 865 String toString() {
843 var superString = super.toString(); 866 var superString = super.toString();
844 return "_ServiceDescriptionProxyControl($superString)"; 867 return "_ServiceDescriptionProxyControl($superString)";
845 } 868 }
846 } 869 }
847 870
848 871 class ServiceDescriptionProxy
849 class ServiceDescriptionProxy extends bindings.Proxy 872 extends bindings.Proxy
850 implements ServiceDescription { 873 implements ServiceDescription {
851 ServiceDescriptionProxy.fromEndpoint( 874 ServiceDescriptionProxy.fromEndpoint(
852 core.MojoMessagePipeEndpoint endpoint) 875 core.MojoMessagePipeEndpoint endpoint)
853 : super(new _ServiceDescriptionProxyControl.fromEndpoint(endpoint)); 876 : super(new _ServiceDescriptionProxyControl.fromEndpoint(endpoint));
854 877
855 ServiceDescriptionProxy.fromHandle(core.MojoHandle handle) 878 ServiceDescriptionProxy.fromHandle(core.MojoHandle handle)
856 : super(new _ServiceDescriptionProxyControl.fromHandle(handle)); 879 : super(new _ServiceDescriptionProxyControl.fromHandle(handle));
857 880
858 ServiceDescriptionProxy.unbound() 881 ServiceDescriptionProxy.unbound()
859 : super(new _ServiceDescriptionProxyControl.unbound()); 882 : super(new _ServiceDescriptionProxyControl.unbound());
860 883
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 dynamic getAllTypeDefinitions([Function responseFactory = null]) { 915 dynamic getAllTypeDefinitions([Function responseFactory = null]) {
893 var params = new _ServiceDescriptionGetAllTypeDefinitionsParams(); 916 var params = new _ServiceDescriptionGetAllTypeDefinitionsParams();
894 return ctrl.sendMessageWithRequestId( 917 return ctrl.sendMessageWithRequestId(
895 params, 918 params,
896 _serviceDescriptionMethodGetAllTypeDefinitionsName, 919 _serviceDescriptionMethodGetAllTypeDefinitionsName,
897 -1, 920 -1,
898 bindings.MessageHeader.kMessageExpectsResponse); 921 bindings.MessageHeader.kMessageExpectsResponse);
899 } 922 }
900 } 923 }
901 924
902 925 class _ServiceDescriptionStubControl
903 class ServiceDescriptionStub extends bindings.Stub { 926 extends bindings.StubMessageHandler
927 implements bindings.StubControl<ServiceDescription> {
904 ServiceDescription _impl; 928 ServiceDescription _impl;
905 929
906 ServiceDescriptionStub.fromEndpoint( 930 _ServiceDescriptionStubControl.fromEndpoint(
907 core.MojoMessagePipeEndpoint endpoint, [ServiceDescription impl]) 931 core.MojoMessagePipeEndpoint endpoint, [ServiceDescription impl])
908 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 932 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
909 _impl = impl; 933 _impl = impl;
910 } 934 }
911 935
912 ServiceDescriptionStub.fromHandle( 936 _ServiceDescriptionStubControl.fromHandle(
913 core.MojoHandle handle, [ServiceDescription impl]) 937 core.MojoHandle handle, [ServiceDescription impl])
914 : super.fromHandle(handle, autoBegin: impl != null) { 938 : super.fromHandle(handle, autoBegin: impl != null) {
915 _impl = impl; 939 _impl = impl;
916 } 940 }
917 941
918 ServiceDescriptionStub.unbound([this._impl]) : super.unbound(); 942 _ServiceDescriptionStubControl.unbound([this._impl]) : super.unbound();
919
920 static ServiceDescriptionStub newFromEndpoint(
921 core.MojoMessagePipeEndpoint endpoint) {
922 assert(endpoint.setDescription("For ServiceDescriptionStub"));
923 return new ServiceDescriptionStub.fromEndpoint(endpoint);
924 }
925 943
926 944
927 ServiceDescriptionGetTopLevelInterfaceResponseParams _serviceDescriptionGetTop LevelInterfaceResponseParamsFactory(mojom_types_mojom.MojomInterface mojomInterf ace) { 945 ServiceDescriptionGetTopLevelInterfaceResponseParams _serviceDescriptionGetTop LevelInterfaceResponseParamsFactory(mojom_types_mojom.MojomInterface mojomInterf ace) {
928 var result = new ServiceDescriptionGetTopLevelInterfaceResponseParams(); 946 var result = new ServiceDescriptionGetTopLevelInterfaceResponseParams();
929 result.mojomInterface = mojomInterface; 947 result.mojomInterface = mojomInterface;
930 return result; 948 return result;
931 } 949 }
932 ServiceDescriptionGetTypeDefinitionResponseParams _serviceDescriptionGetTypeDe finitionResponseParamsFactory(mojom_types_mojom.UserDefinedType type) { 950 ServiceDescriptionGetTypeDefinitionResponseParams _serviceDescriptionGetTypeDe finitionResponseParamsFactory(mojom_types_mojom.UserDefinedType type) {
933 var result = new ServiceDescriptionGetTypeDefinitionResponseParams(); 951 var result = new ServiceDescriptionGetTypeDefinitionResponseParams();
934 result.type = type; 952 result.type = type;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 } 1049 }
1032 1050
1033 @override 1051 @override
1034 void bind(core.MojoMessagePipeEndpoint endpoint) { 1052 void bind(core.MojoMessagePipeEndpoint endpoint) {
1035 super.bind(endpoint); 1053 super.bind(endpoint);
1036 if (!isOpen && (_impl != null)) { 1054 if (!isOpen && (_impl != null)) {
1037 beginHandlingEvents(); 1055 beginHandlingEvents();
1038 } 1056 }
1039 } 1057 }
1040 1058
1059 @override
1041 String toString() { 1060 String toString() {
1042 var superString = super.toString(); 1061 var superString = super.toString();
1043 return "ServiceDescriptionStub($superString)"; 1062 return "_ServiceDescriptionStubControl($superString)";
1044 } 1063 }
1045 1064
1046 int get version => 0; 1065 int get version => 0;
1047 1066
1048 static ServiceDescription _cachedServiceDescription; 1067 static ServiceDescription _cachedServiceDescription;
1049 static ServiceDescription get serviceDescription { 1068 static ServiceDescription get serviceDescription {
1050 if (_cachedServiceDescription == null) { 1069 if (_cachedServiceDescription == null) {
1051 _cachedServiceDescription = new _ServiceDescriptionServiceDescription(); 1070 _cachedServiceDescription = new _ServiceDescriptionServiceDescription();
1052 } 1071 }
1053 return _cachedServiceDescription; 1072 return _cachedServiceDescription;
1054 } 1073 }
1055 } 1074 }
1056 1075
1076 class ServiceDescriptionStub
1077 extends bindings.Stub<ServiceDescription>
1078 implements ServiceDescription {
1079 ServiceDescriptionStub.fromEndpoint(
1080 core.MojoMessagePipeEndpoint endpoint, [ServiceDescription impl])
1081 : super(new _ServiceDescriptionStubControl.fromEndpoint(endpoint, impl));
1082
1083 ServiceDescriptionStub.fromHandle(
1084 core.MojoHandle handle, [ServiceDescription impl])
1085 : super(new _ServiceDescriptionStubControl.fromHandle(handle, impl));
1086
1087 ServiceDescriptionStub.unbound([ServiceDescription impl])
1088 : super(new _ServiceDescriptionStubControl.unbound(impl));
1089
1090 static ServiceDescriptionStub newFromEndpoint(
1091 core.MojoMessagePipeEndpoint endpoint) {
1092 assert(endpoint.setDescription("For ServiceDescriptionStub"));
1093 return new ServiceDescriptionStub.fromEndpoint(endpoint);
1094 }
1095
1096 static ServiceDescription get serviceDescription =>
1097 _ServiceDescriptionStubControl.serviceDescription;
1098
1099
1100 dynamic getTopLevelInterface([Function responseFactory = null]) {
1101 return impl.getTopLevelInterface(responseFactory);
1102 }
1103 dynamic getTypeDefinition(String typeKey,[Function responseFactory = null]) {
1104 return impl.getTypeDefinition(typeKey,responseFactory);
1105 }
1106 dynamic getAllTypeDefinitions([Function responseFactory = null]) {
1107 return impl.getAllTypeDefinitions(responseFactory);
1108 }
1109 }
1110
1057 1111
1058 1112
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698