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

Side by Side Diff: mojo/dart/packages/mojo_services/lib/native_support/process.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 process_mojom; 5 library process_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 import 'package:mojo_services/mojo/files/file.mojom.dart' as file_mojom; 10 import 'package:mojo_services/mojo/files/file.mojom.dart' as file_mojom;
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 dynamic getAllTypeDefinitions([Function responseFactory]) => 812 dynamic getAllTypeDefinitions([Function responseFactory]) =>
813 responseFactory(null); 813 responseFactory(null);
814 } 814 }
815 815
816 abstract class Process { 816 abstract class Process {
817 static const String serviceName = "native_support::Process"; 817 static const String serviceName = "native_support::Process";
818 dynamic spawn(List<int> path,List<List<int>> argv,List<List<int>> envp,Object stdinFile,Object stdoutFile,Object stderrFile,Object processController,[Function responseFactory = null]); 818 dynamic spawn(List<int> path,List<List<int>> argv,List<List<int>> envp,Object stdinFile,Object stdoutFile,Object stderrFile,Object processController,[Function responseFactory = null]);
819 dynamic spawnWithTerminal(List<int> path,List<List<int>> argv,List<List<int>> envp,Object terminalFile,Object processController,[Function responseFactory = nu ll]); 819 dynamic spawnWithTerminal(List<int> path,List<List<int>> argv,List<List<int>> envp,Object terminalFile,Object processController,[Function responseFactory = nu ll]);
820 } 820 }
821 821
822 822 class _ProcessProxyControl
823 class _ProcessProxyControl extends bindings.ProxyMessageHandler 823 extends bindings.ProxyMessageHandler
824 implements bindings.ProxyControl { 824 implements bindings.ProxyControl {
825 _ProcessProxyControl.fromEndpoint( 825 _ProcessProxyControl.fromEndpoint(
826 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 826 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
827 827
828 _ProcessProxyControl.fromHandle( 828 _ProcessProxyControl.fromHandle(
829 core.MojoHandle handle) : super.fromHandle(handle); 829 core.MojoHandle handle) : super.fromHandle(handle);
830 830
831 _ProcessProxyControl.unbound() : super.unbound(); 831 _ProcessProxyControl.unbound() : super.unbound();
832 832
833 service_describer.ServiceDescription get serviceDescription => 833 service_describer.ServiceDescription get serviceDescription =>
834 new _ProcessServiceDescription(); 834 new _ProcessServiceDescription();
835 835
836 String get serviceName => Process.serviceName; 836 String get serviceName => Process.serviceName;
837 837
838 @override
839 void handleResponse(bindings.ServiceMessage message) { 838 void handleResponse(bindings.ServiceMessage message) {
840 switch (message.header.type) { 839 switch (message.header.type) {
841 case _processMethodSpawnName: 840 case _processMethodSpawnName:
842 var r = ProcessSpawnResponseParams.deserialize( 841 var r = ProcessSpawnResponseParams.deserialize(
843 message.payload); 842 message.payload);
844 if (!message.header.hasRequestId) { 843 if (!message.header.hasRequestId) {
845 proxyError("Expected a message with a valid request Id."); 844 proxyError("Expected a message with a valid request Id.");
846 return; 845 return;
847 } 846 }
848 Completer c = completerMap[message.header.requestId]; 847 Completer c = completerMap[message.header.requestId];
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 } 884 }
886 } 885 }
887 886
888 @override 887 @override
889 String toString() { 888 String toString() {
890 var superString = super.toString(); 889 var superString = super.toString();
891 return "_ProcessProxyControl($superString)"; 890 return "_ProcessProxyControl($superString)";
892 } 891 }
893 } 892 }
894 893
895 894 class ProcessProxy
896 class ProcessProxy extends bindings.Proxy 895 extends bindings.Proxy
897 implements Process { 896 implements Process {
898 ProcessProxy.fromEndpoint( 897 ProcessProxy.fromEndpoint(
899 core.MojoMessagePipeEndpoint endpoint) 898 core.MojoMessagePipeEndpoint endpoint)
900 : super(new _ProcessProxyControl.fromEndpoint(endpoint)); 899 : super(new _ProcessProxyControl.fromEndpoint(endpoint));
901 900
902 ProcessProxy.fromHandle(core.MojoHandle handle) 901 ProcessProxy.fromHandle(core.MojoHandle handle)
903 : super(new _ProcessProxyControl.fromHandle(handle)); 902 : super(new _ProcessProxyControl.fromHandle(handle));
904 903
905 ProcessProxy.unbound() 904 ProcessProxy.unbound()
906 : super(new _ProcessProxyControl.unbound()); 905 : super(new _ProcessProxyControl.unbound());
907 906
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 params.terminalFile = terminalFile; 941 params.terminalFile = terminalFile;
943 params.processController = processController; 942 params.processController = processController;
944 return ctrl.sendMessageWithRequestId( 943 return ctrl.sendMessageWithRequestId(
945 params, 944 params,
946 _processMethodSpawnWithTerminalName, 945 _processMethodSpawnWithTerminalName,
947 -1, 946 -1,
948 bindings.MessageHeader.kMessageExpectsResponse); 947 bindings.MessageHeader.kMessageExpectsResponse);
949 } 948 }
950 } 949 }
951 950
952 951 class _ProcessStubControl
953 class ProcessStub extends bindings.Stub { 952 extends bindings.StubMessageHandler
953 implements bindings.StubControl<Process> {
954 Process _impl; 954 Process _impl;
955 955
956 ProcessStub.fromEndpoint( 956 _ProcessStubControl.fromEndpoint(
957 core.MojoMessagePipeEndpoint endpoint, [Process impl]) 957 core.MojoMessagePipeEndpoint endpoint, [Process impl])
958 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 958 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
959 _impl = impl; 959 _impl = impl;
960 } 960 }
961 961
962 ProcessStub.fromHandle( 962 _ProcessStubControl.fromHandle(
963 core.MojoHandle handle, [Process impl]) 963 core.MojoHandle handle, [Process impl])
964 : super.fromHandle(handle, autoBegin: impl != null) { 964 : super.fromHandle(handle, autoBegin: impl != null) {
965 _impl = impl; 965 _impl = impl;
966 } 966 }
967 967
968 ProcessStub.unbound([this._impl]) : super.unbound(); 968 _ProcessStubControl.unbound([this._impl]) : super.unbound();
969
970 static ProcessStub newFromEndpoint(
971 core.MojoMessagePipeEndpoint endpoint) {
972 assert(endpoint.setDescription("For ProcessStub"));
973 return new ProcessStub.fromEndpoint(endpoint);
974 }
975 969
976 970
977 ProcessSpawnResponseParams _processSpawnResponseParamsFactory(types_mojom.Erro r error) { 971 ProcessSpawnResponseParams _processSpawnResponseParamsFactory(types_mojom.Erro r error) {
978 var result = new ProcessSpawnResponseParams(); 972 var result = new ProcessSpawnResponseParams();
979 result.error = error; 973 result.error = error;
980 return result; 974 return result;
981 } 975 }
982 ProcessSpawnWithTerminalResponseParams _processSpawnWithTerminalResponseParams Factory(types_mojom.Error error) { 976 ProcessSpawnWithTerminalResponseParams _processSpawnWithTerminalResponseParams Factory(types_mojom.Error error) {
983 var result = new ProcessSpawnWithTerminalResponseParams(); 977 var result = new ProcessSpawnWithTerminalResponseParams();
984 result.error = error; 978 result.error = error;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 } 1052 }
1059 1053
1060 @override 1054 @override
1061 void bind(core.MojoMessagePipeEndpoint endpoint) { 1055 void bind(core.MojoMessagePipeEndpoint endpoint) {
1062 super.bind(endpoint); 1056 super.bind(endpoint);
1063 if (!isOpen && (_impl != null)) { 1057 if (!isOpen && (_impl != null)) {
1064 beginHandlingEvents(); 1058 beginHandlingEvents();
1065 } 1059 }
1066 } 1060 }
1067 1061
1062 @override
1068 String toString() { 1063 String toString() {
1069 var superString = super.toString(); 1064 var superString = super.toString();
1070 return "ProcessStub($superString)"; 1065 return "_ProcessStubControl($superString)";
1071 } 1066 }
1072 1067
1073 int get version => 0; 1068 int get version => 0;
1074 1069
1075 static service_describer.ServiceDescription _cachedServiceDescription; 1070 static service_describer.ServiceDescription _cachedServiceDescription;
1076 static service_describer.ServiceDescription get serviceDescription { 1071 static service_describer.ServiceDescription get serviceDescription {
1077 if (_cachedServiceDescription == null) { 1072 if (_cachedServiceDescription == null) {
1078 _cachedServiceDescription = new _ProcessServiceDescription(); 1073 _cachedServiceDescription = new _ProcessServiceDescription();
1079 } 1074 }
1080 return _cachedServiceDescription; 1075 return _cachedServiceDescription;
1081 } 1076 }
1082 } 1077 }
1083 1078
1079 class ProcessStub
1080 extends bindings.Stub<Process>
1081 implements Process {
1082 ProcessStub.fromEndpoint(
1083 core.MojoMessagePipeEndpoint endpoint, [Process impl])
1084 : super(new _ProcessStubControl.fromEndpoint(endpoint, impl));
1085
1086 ProcessStub.fromHandle(
1087 core.MojoHandle handle, [Process impl])
1088 : super(new _ProcessStubControl.fromHandle(handle, impl));
1089
1090 ProcessStub.unbound([Process impl])
1091 : super(new _ProcessStubControl.unbound(impl));
1092
1093 static ProcessStub newFromEndpoint(
1094 core.MojoMessagePipeEndpoint endpoint) {
1095 assert(endpoint.setDescription("For ProcessStub"));
1096 return new ProcessStub.fromEndpoint(endpoint);
1097 }
1098
1099 static service_describer.ServiceDescription get serviceDescription =>
1100 _ProcessStubControl.serviceDescription;
1101
1102
1103 dynamic spawn(List<int> path,List<List<int>> argv,List<List<int>> envp,Object stdinFile,Object stdoutFile,Object stderrFile,Object processController,[Function responseFactory = null]) {
1104 return impl.spawn(path,argv,envp,stdinFile,stdoutFile,stderrFile,processCont roller,responseFactory);
1105 }
1106 dynamic spawnWithTerminal(List<int> path,List<List<int>> argv,List<List<int>> envp,Object terminalFile,Object processController,[Function responseFactory = nu ll]) {
1107 return impl.spawnWithTerminal(path,argv,envp,terminalFile,processController, responseFactory);
1108 }
1109 }
1110
1084 const int _processControllerMethodWaitName = 0; 1111 const int _processControllerMethodWaitName = 0;
1085 const int _processControllerMethodKillName = 1; 1112 const int _processControllerMethodKillName = 1;
1086 1113
1087 class _ProcessControllerServiceDescription implements service_describer.ServiceD escription { 1114 class _ProcessControllerServiceDescription implements service_describer.ServiceD escription {
1088 dynamic getTopLevelInterface([Function responseFactory]) => 1115 dynamic getTopLevelInterface([Function responseFactory]) =>
1089 responseFactory(null); 1116 responseFactory(null);
1090 1117
1091 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 1118 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) =>
1092 responseFactory(null); 1119 responseFactory(null);
1093 1120
1094 dynamic getAllTypeDefinitions([Function responseFactory]) => 1121 dynamic getAllTypeDefinitions([Function responseFactory]) =>
1095 responseFactory(null); 1122 responseFactory(null);
1096 } 1123 }
1097 1124
1098 abstract class ProcessController { 1125 abstract class ProcessController {
1099 static const String serviceName = null; 1126 static const String serviceName = null;
1100 dynamic wait([Function responseFactory = null]); 1127 dynamic wait([Function responseFactory = null]);
1101 dynamic kill(int signal,[Function responseFactory = null]); 1128 dynamic kill(int signal,[Function responseFactory = null]);
1102 } 1129 }
1103 1130
1104 1131 class _ProcessControllerProxyControl
1105 class _ProcessControllerProxyControl extends bindings.ProxyMessageHandler 1132 extends bindings.ProxyMessageHandler
1106 implements bindings.ProxyControl { 1133 implements bindings.ProxyControl {
1107 _ProcessControllerProxyControl.fromEndpoint( 1134 _ProcessControllerProxyControl.fromEndpoint(
1108 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 1135 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
1109 1136
1110 _ProcessControllerProxyControl.fromHandle( 1137 _ProcessControllerProxyControl.fromHandle(
1111 core.MojoHandle handle) : super.fromHandle(handle); 1138 core.MojoHandle handle) : super.fromHandle(handle);
1112 1139
1113 _ProcessControllerProxyControl.unbound() : super.unbound(); 1140 _ProcessControllerProxyControl.unbound() : super.unbound();
1114 1141
1115 service_describer.ServiceDescription get serviceDescription => 1142 service_describer.ServiceDescription get serviceDescription =>
1116 new _ProcessControllerServiceDescription(); 1143 new _ProcessControllerServiceDescription();
1117 1144
1118 String get serviceName => ProcessController.serviceName; 1145 String get serviceName => ProcessController.serviceName;
1119 1146
1120 @override
1121 void handleResponse(bindings.ServiceMessage message) { 1147 void handleResponse(bindings.ServiceMessage message) {
1122 switch (message.header.type) { 1148 switch (message.header.type) {
1123 case _processControllerMethodWaitName: 1149 case _processControllerMethodWaitName:
1124 var r = ProcessControllerWaitResponseParams.deserialize( 1150 var r = ProcessControllerWaitResponseParams.deserialize(
1125 message.payload); 1151 message.payload);
1126 if (!message.header.hasRequestId) { 1152 if (!message.header.hasRequestId) {
1127 proxyError("Expected a message with a valid request Id."); 1153 proxyError("Expected a message with a valid request Id.");
1128 return; 1154 return;
1129 } 1155 }
1130 Completer c = completerMap[message.header.requestId]; 1156 Completer c = completerMap[message.header.requestId];
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 } 1193 }
1168 } 1194 }
1169 1195
1170 @override 1196 @override
1171 String toString() { 1197 String toString() {
1172 var superString = super.toString(); 1198 var superString = super.toString();
1173 return "_ProcessControllerProxyControl($superString)"; 1199 return "_ProcessControllerProxyControl($superString)";
1174 } 1200 }
1175 } 1201 }
1176 1202
1177 1203 class ProcessControllerProxy
1178 class ProcessControllerProxy extends bindings.Proxy 1204 extends bindings.Proxy
1179 implements ProcessController { 1205 implements ProcessController {
1180 ProcessControllerProxy.fromEndpoint( 1206 ProcessControllerProxy.fromEndpoint(
1181 core.MojoMessagePipeEndpoint endpoint) 1207 core.MojoMessagePipeEndpoint endpoint)
1182 : super(new _ProcessControllerProxyControl.fromEndpoint(endpoint)); 1208 : super(new _ProcessControllerProxyControl.fromEndpoint(endpoint));
1183 1209
1184 ProcessControllerProxy.fromHandle(core.MojoHandle handle) 1210 ProcessControllerProxy.fromHandle(core.MojoHandle handle)
1185 : super(new _ProcessControllerProxyControl.fromHandle(handle)); 1211 : super(new _ProcessControllerProxyControl.fromHandle(handle));
1186 1212
1187 ProcessControllerProxy.unbound() 1213 ProcessControllerProxy.unbound()
1188 : super(new _ProcessControllerProxyControl.unbound()); 1214 : super(new _ProcessControllerProxyControl.unbound());
1189 1215
(...skipping 23 matching lines...) Expand all
1213 var params = new _ProcessControllerKillParams(); 1239 var params = new _ProcessControllerKillParams();
1214 params.signal = signal; 1240 params.signal = signal;
1215 return ctrl.sendMessageWithRequestId( 1241 return ctrl.sendMessageWithRequestId(
1216 params, 1242 params,
1217 _processControllerMethodKillName, 1243 _processControllerMethodKillName,
1218 -1, 1244 -1,
1219 bindings.MessageHeader.kMessageExpectsResponse); 1245 bindings.MessageHeader.kMessageExpectsResponse);
1220 } 1246 }
1221 } 1247 }
1222 1248
1223 1249 class _ProcessControllerStubControl
1224 class ProcessControllerStub extends bindings.Stub { 1250 extends bindings.StubMessageHandler
1251 implements bindings.StubControl<ProcessController> {
1225 ProcessController _impl; 1252 ProcessController _impl;
1226 1253
1227 ProcessControllerStub.fromEndpoint( 1254 _ProcessControllerStubControl.fromEndpoint(
1228 core.MojoMessagePipeEndpoint endpoint, [ProcessController impl]) 1255 core.MojoMessagePipeEndpoint endpoint, [ProcessController impl])
1229 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 1256 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
1230 _impl = impl; 1257 _impl = impl;
1231 } 1258 }
1232 1259
1233 ProcessControllerStub.fromHandle( 1260 _ProcessControllerStubControl.fromHandle(
1234 core.MojoHandle handle, [ProcessController impl]) 1261 core.MojoHandle handle, [ProcessController impl])
1235 : super.fromHandle(handle, autoBegin: impl != null) { 1262 : super.fromHandle(handle, autoBegin: impl != null) {
1236 _impl = impl; 1263 _impl = impl;
1237 } 1264 }
1238 1265
1239 ProcessControllerStub.unbound([this._impl]) : super.unbound(); 1266 _ProcessControllerStubControl.unbound([this._impl]) : super.unbound();
1240
1241 static ProcessControllerStub newFromEndpoint(
1242 core.MojoMessagePipeEndpoint endpoint) {
1243 assert(endpoint.setDescription("For ProcessControllerStub"));
1244 return new ProcessControllerStub.fromEndpoint(endpoint);
1245 }
1246 1267
1247 1268
1248 ProcessControllerWaitResponseParams _processControllerWaitResponseParamsFactor y(types_mojom.Error error, int exitStatus) { 1269 ProcessControllerWaitResponseParams _processControllerWaitResponseParamsFactor y(types_mojom.Error error, int exitStatus) {
1249 var result = new ProcessControllerWaitResponseParams(); 1270 var result = new ProcessControllerWaitResponseParams();
1250 result.error = error; 1271 result.error = error;
1251 result.exitStatus = exitStatus; 1272 result.exitStatus = exitStatus;
1252 return result; 1273 return result;
1253 } 1274 }
1254 ProcessControllerKillResponseParams _processControllerKillResponseParamsFactor y(types_mojom.Error error) { 1275 ProcessControllerKillResponseParams _processControllerKillResponseParamsFactor y(types_mojom.Error error) {
1255 var result = new ProcessControllerKillResponseParams(); 1276 var result = new ProcessControllerKillResponseParams();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 } 1349 }
1329 1350
1330 @override 1351 @override
1331 void bind(core.MojoMessagePipeEndpoint endpoint) { 1352 void bind(core.MojoMessagePipeEndpoint endpoint) {
1332 super.bind(endpoint); 1353 super.bind(endpoint);
1333 if (!isOpen && (_impl != null)) { 1354 if (!isOpen && (_impl != null)) {
1334 beginHandlingEvents(); 1355 beginHandlingEvents();
1335 } 1356 }
1336 } 1357 }
1337 1358
1359 @override
1338 String toString() { 1360 String toString() {
1339 var superString = super.toString(); 1361 var superString = super.toString();
1340 return "ProcessControllerStub($superString)"; 1362 return "_ProcessControllerStubControl($superString)";
1341 } 1363 }
1342 1364
1343 int get version => 0; 1365 int get version => 0;
1344 1366
1345 static service_describer.ServiceDescription _cachedServiceDescription; 1367 static service_describer.ServiceDescription _cachedServiceDescription;
1346 static service_describer.ServiceDescription get serviceDescription { 1368 static service_describer.ServiceDescription get serviceDescription {
1347 if (_cachedServiceDescription == null) { 1369 if (_cachedServiceDescription == null) {
1348 _cachedServiceDescription = new _ProcessControllerServiceDescription(); 1370 _cachedServiceDescription = new _ProcessControllerServiceDescription();
1349 } 1371 }
1350 return _cachedServiceDescription; 1372 return _cachedServiceDescription;
1351 } 1373 }
1352 } 1374 }
1353 1375
1376 class ProcessControllerStub
1377 extends bindings.Stub<ProcessController>
1378 implements ProcessController {
1379 ProcessControllerStub.fromEndpoint(
1380 core.MojoMessagePipeEndpoint endpoint, [ProcessController impl])
1381 : super(new _ProcessControllerStubControl.fromEndpoint(endpoint, impl));
1382
1383 ProcessControllerStub.fromHandle(
1384 core.MojoHandle handle, [ProcessController impl])
1385 : super(new _ProcessControllerStubControl.fromHandle(handle, impl));
1386
1387 ProcessControllerStub.unbound([ProcessController impl])
1388 : super(new _ProcessControllerStubControl.unbound(impl));
1389
1390 static ProcessControllerStub newFromEndpoint(
1391 core.MojoMessagePipeEndpoint endpoint) {
1392 assert(endpoint.setDescription("For ProcessControllerStub"));
1393 return new ProcessControllerStub.fromEndpoint(endpoint);
1394 }
1395
1396 static service_describer.ServiceDescription get serviceDescription =>
1397 _ProcessControllerStubControl.serviceDescription;
1398
1399
1400 dynamic wait([Function responseFactory = null]) {
1401 return impl.wait(responseFactory);
1402 }
1403 dynamic kill(int signal,[Function responseFactory = null]) {
1404 return impl.kill(signal,responseFactory);
1405 }
1406 }
1407
1354 1408
1355 1409
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698