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 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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
823 class _ProcessProxyImpl extends bindings.Proxy { | 823 class _ProcessProxyControl extends bindings.ProxyMessageHandler |
824 _ProcessProxyImpl.fromEndpoint( | 824 implements bindings.ProxyControl { |
| 825 _ProcessProxyControl.fromEndpoint( |
825 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 826 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
826 | 827 |
827 _ProcessProxyImpl.fromHandle(core.MojoHandle handle) : | 828 _ProcessProxyControl.fromHandle( |
828 super.fromHandle(handle); | 829 core.MojoHandle handle) : super.fromHandle(handle); |
829 | 830 |
830 _ProcessProxyImpl.unbound() : super.unbound(); | 831 _ProcessProxyControl.unbound() : super.unbound(); |
831 | |
832 static _ProcessProxyImpl newFromEndpoint( | |
833 core.MojoMessagePipeEndpoint endpoint) { | |
834 assert(endpoint.setDescription("For _ProcessProxyImpl")); | |
835 return new _ProcessProxyImpl.fromEndpoint(endpoint); | |
836 } | |
837 | 832 |
838 service_describer.ServiceDescription get serviceDescription => | 833 service_describer.ServiceDescription get serviceDescription => |
839 new _ProcessServiceDescription(); | 834 new _ProcessServiceDescription(); |
840 | 835 |
| 836 String get serviceName => Process.serviceName; |
| 837 |
| 838 @override |
841 void handleResponse(bindings.ServiceMessage message) { | 839 void handleResponse(bindings.ServiceMessage message) { |
842 switch (message.header.type) { | 840 switch (message.header.type) { |
843 case _processMethodSpawnName: | 841 case _processMethodSpawnName: |
844 var r = ProcessSpawnResponseParams.deserialize( | 842 var r = ProcessSpawnResponseParams.deserialize( |
845 message.payload); | 843 message.payload); |
846 if (!message.header.hasRequestId) { | 844 if (!message.header.hasRequestId) { |
847 proxyError("Expected a message with a valid request Id."); | 845 proxyError("Expected a message with a valid request Id."); |
848 return; | 846 return; |
849 } | 847 } |
850 Completer c = completerMap[message.header.requestId]; | 848 Completer c = completerMap[message.header.requestId]; |
(...skipping 29 matching lines...) Expand all Loading... |
880 } | 878 } |
881 c.complete(r); | 879 c.complete(r); |
882 break; | 880 break; |
883 default: | 881 default: |
884 proxyError("Unexpected message type: ${message.header.type}"); | 882 proxyError("Unexpected message type: ${message.header.type}"); |
885 close(immediate: true); | 883 close(immediate: true); |
886 break; | 884 break; |
887 } | 885 } |
888 } | 886 } |
889 | 887 |
| 888 @override |
890 String toString() { | 889 String toString() { |
891 var superString = super.toString(); | 890 var superString = super.toString(); |
892 return "_ProcessProxyImpl($superString)"; | 891 return "_ProcessProxyControl($superString)"; |
893 } | 892 } |
894 } | 893 } |
895 | 894 |
896 | 895 |
897 class _ProcessProxyCalls implements Process { | 896 class ProcessProxy extends bindings.Proxy |
898 _ProcessProxyImpl _proxyImpl; | 897 implements Process { |
| 898 ProcessProxy.fromEndpoint( |
| 899 core.MojoMessagePipeEndpoint endpoint) |
| 900 : super(new _ProcessProxyControl.fromEndpoint(endpoint)); |
899 | 901 |
900 _ProcessProxyCalls(this._proxyImpl); | 902 ProcessProxy.fromHandle(core.MojoHandle handle) |
901 dynamic spawn(List<int> path,List<List<int>> argv,List<List<int>> envp,Objec
t stdinFile,Object stdoutFile,Object stderrFile,Object processController,[Functi
on responseFactory = null]) { | 903 : super(new _ProcessProxyControl.fromHandle(handle)); |
902 var params = new _ProcessSpawnParams(); | |
903 params.path = path; | |
904 params.argv = argv; | |
905 params.envp = envp; | |
906 params.stdinFile = stdinFile; | |
907 params.stdoutFile = stdoutFile; | |
908 params.stderrFile = stderrFile; | |
909 params.processController = processController; | |
910 return _proxyImpl.sendMessageWithRequestId( | |
911 params, | |
912 _processMethodSpawnName, | |
913 -1, | |
914 bindings.MessageHeader.kMessageExpectsResponse); | |
915 } | |
916 dynamic spawnWithTerminal(List<int> path,List<List<int>> argv,List<List<int>
> envp,Object terminalFile,Object processController,[Function responseFactory =
null]) { | |
917 var params = new _ProcessSpawnWithTerminalParams(); | |
918 params.path = path; | |
919 params.argv = argv; | |
920 params.envp = envp; | |
921 params.terminalFile = terminalFile; | |
922 params.processController = processController; | |
923 return _proxyImpl.sendMessageWithRequestId( | |
924 params, | |
925 _processMethodSpawnWithTerminalName, | |
926 -1, | |
927 bindings.MessageHeader.kMessageExpectsResponse); | |
928 } | |
929 } | |
930 | 904 |
| 905 ProcessProxy.unbound() |
| 906 : super(new _ProcessProxyControl.unbound()); |
931 | 907 |
932 class ProcessProxy implements bindings.ProxyBase { | 908 static ProcessProxy newFromEndpoint( |
933 final bindings.Proxy impl; | 909 core.MojoMessagePipeEndpoint endpoint) { |
934 Process ptr; | 910 assert(endpoint.setDescription("For ProcessProxy")); |
935 | 911 return new ProcessProxy.fromEndpoint(endpoint); |
936 ProcessProxy(_ProcessProxyImpl proxyImpl) : | |
937 impl = proxyImpl, | |
938 ptr = new _ProcessProxyCalls(proxyImpl); | |
939 | |
940 ProcessProxy.fromEndpoint( | |
941 core.MojoMessagePipeEndpoint endpoint) : | |
942 impl = new _ProcessProxyImpl.fromEndpoint(endpoint) { | |
943 ptr = new _ProcessProxyCalls(impl); | |
944 } | |
945 | |
946 ProcessProxy.fromHandle(core.MojoHandle handle) : | |
947 impl = new _ProcessProxyImpl.fromHandle(handle) { | |
948 ptr = new _ProcessProxyCalls(impl); | |
949 } | |
950 | |
951 ProcessProxy.unbound() : | |
952 impl = new _ProcessProxyImpl.unbound() { | |
953 ptr = new _ProcessProxyCalls(impl); | |
954 } | 912 } |
955 | 913 |
956 factory ProcessProxy.connectToService( | 914 factory ProcessProxy.connectToService( |
957 bindings.ServiceConnector s, String url, [String serviceName]) { | 915 bindings.ServiceConnector s, String url, [String serviceName]) { |
958 ProcessProxy p = new ProcessProxy.unbound(); | 916 ProcessProxy p = new ProcessProxy.unbound(); |
959 s.connectToService(url, p, serviceName); | 917 s.connectToService(url, p, serviceName); |
960 return p; | 918 return p; |
961 } | 919 } |
962 | 920 |
963 static ProcessProxy newFromEndpoint( | 921 |
964 core.MojoMessagePipeEndpoint endpoint) { | 922 dynamic spawn(List<int> path,List<List<int>> argv,List<List<int>> envp,Object
stdinFile,Object stdoutFile,Object stderrFile,Object processController,[Function
responseFactory = null]) { |
965 assert(endpoint.setDescription("For ProcessProxy")); | 923 var params = new _ProcessSpawnParams(); |
966 return new ProcessProxy.fromEndpoint(endpoint); | 924 params.path = path; |
| 925 params.argv = argv; |
| 926 params.envp = envp; |
| 927 params.stdinFile = stdinFile; |
| 928 params.stdoutFile = stdoutFile; |
| 929 params.stderrFile = stderrFile; |
| 930 params.processController = processController; |
| 931 return ctrl.sendMessageWithRequestId( |
| 932 params, |
| 933 _processMethodSpawnName, |
| 934 -1, |
| 935 bindings.MessageHeader.kMessageExpectsResponse); |
967 } | 936 } |
968 | 937 dynamic spawnWithTerminal(List<int> path,List<List<int>> argv,List<List<int>>
envp,Object terminalFile,Object processController,[Function responseFactory = nu
ll]) { |
969 String get serviceName => Process.serviceName; | 938 var params = new _ProcessSpawnWithTerminalParams(); |
970 | 939 params.path = path; |
971 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 940 params.argv = argv; |
972 | 941 params.envp = envp; |
973 Future responseOrError(Future f) => impl.responseOrError(f); | 942 params.terminalFile = terminalFile; |
974 | 943 params.processController = processController; |
975 Future get errorFuture => impl.errorFuture; | 944 return ctrl.sendMessageWithRequestId( |
976 | 945 params, |
977 int get version => impl.version; | 946 _processMethodSpawnWithTerminalName, |
978 | 947 -1, |
979 Future<int> queryVersion() => impl.queryVersion(); | 948 bindings.MessageHeader.kMessageExpectsResponse); |
980 | |
981 void requireVersion(int requiredVersion) { | |
982 impl.requireVersion(requiredVersion); | |
983 } | |
984 | |
985 String toString() { | |
986 return "ProcessProxy($impl)"; | |
987 } | 949 } |
988 } | 950 } |
989 | 951 |
990 | 952 |
991 class ProcessStub extends bindings.Stub { | 953 class ProcessStub extends bindings.Stub { |
992 Process _impl; | 954 Process _impl; |
993 | 955 |
994 ProcessStub.fromEndpoint( | 956 ProcessStub.fromEndpoint( |
995 core.MojoMessagePipeEndpoint endpoint, [Process impl]) | 957 core.MojoMessagePipeEndpoint endpoint, [Process impl]) |
996 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 958 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 responseFactory(null); | 1095 responseFactory(null); |
1134 } | 1096 } |
1135 | 1097 |
1136 abstract class ProcessController { | 1098 abstract class ProcessController { |
1137 static const String serviceName = null; | 1099 static const String serviceName = null; |
1138 dynamic wait([Function responseFactory = null]); | 1100 dynamic wait([Function responseFactory = null]); |
1139 dynamic kill(int signal,[Function responseFactory = null]); | 1101 dynamic kill(int signal,[Function responseFactory = null]); |
1140 } | 1102 } |
1141 | 1103 |
1142 | 1104 |
1143 class _ProcessControllerProxyImpl extends bindings.Proxy { | 1105 class _ProcessControllerProxyControl extends bindings.ProxyMessageHandler |
1144 _ProcessControllerProxyImpl.fromEndpoint( | 1106 implements bindings.ProxyControl { |
| 1107 _ProcessControllerProxyControl.fromEndpoint( |
1145 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 1108 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
1146 | 1109 |
1147 _ProcessControllerProxyImpl.fromHandle(core.MojoHandle handle) : | 1110 _ProcessControllerProxyControl.fromHandle( |
1148 super.fromHandle(handle); | 1111 core.MojoHandle handle) : super.fromHandle(handle); |
1149 | 1112 |
1150 _ProcessControllerProxyImpl.unbound() : super.unbound(); | 1113 _ProcessControllerProxyControl.unbound() : super.unbound(); |
1151 | |
1152 static _ProcessControllerProxyImpl newFromEndpoint( | |
1153 core.MojoMessagePipeEndpoint endpoint) { | |
1154 assert(endpoint.setDescription("For _ProcessControllerProxyImpl")); | |
1155 return new _ProcessControllerProxyImpl.fromEndpoint(endpoint); | |
1156 } | |
1157 | 1114 |
1158 service_describer.ServiceDescription get serviceDescription => | 1115 service_describer.ServiceDescription get serviceDescription => |
1159 new _ProcessControllerServiceDescription(); | 1116 new _ProcessControllerServiceDescription(); |
1160 | 1117 |
| 1118 String get serviceName => ProcessController.serviceName; |
| 1119 |
| 1120 @override |
1161 void handleResponse(bindings.ServiceMessage message) { | 1121 void handleResponse(bindings.ServiceMessage message) { |
1162 switch (message.header.type) { | 1122 switch (message.header.type) { |
1163 case _processControllerMethodWaitName: | 1123 case _processControllerMethodWaitName: |
1164 var r = ProcessControllerWaitResponseParams.deserialize( | 1124 var r = ProcessControllerWaitResponseParams.deserialize( |
1165 message.payload); | 1125 message.payload); |
1166 if (!message.header.hasRequestId) { | 1126 if (!message.header.hasRequestId) { |
1167 proxyError("Expected a message with a valid request Id."); | 1127 proxyError("Expected a message with a valid request Id."); |
1168 return; | 1128 return; |
1169 } | 1129 } |
1170 Completer c = completerMap[message.header.requestId]; | 1130 Completer c = completerMap[message.header.requestId]; |
(...skipping 29 matching lines...) Expand all Loading... |
1200 } | 1160 } |
1201 c.complete(r); | 1161 c.complete(r); |
1202 break; | 1162 break; |
1203 default: | 1163 default: |
1204 proxyError("Unexpected message type: ${message.header.type}"); | 1164 proxyError("Unexpected message type: ${message.header.type}"); |
1205 close(immediate: true); | 1165 close(immediate: true); |
1206 break; | 1166 break; |
1207 } | 1167 } |
1208 } | 1168 } |
1209 | 1169 |
| 1170 @override |
1210 String toString() { | 1171 String toString() { |
1211 var superString = super.toString(); | 1172 var superString = super.toString(); |
1212 return "_ProcessControllerProxyImpl($superString)"; | 1173 return "_ProcessControllerProxyControl($superString)"; |
1213 } | 1174 } |
1214 } | 1175 } |
1215 | 1176 |
1216 | 1177 |
1217 class _ProcessControllerProxyCalls implements ProcessController { | 1178 class ProcessControllerProxy extends bindings.Proxy |
1218 _ProcessControllerProxyImpl _proxyImpl; | 1179 implements ProcessController { |
| 1180 ProcessControllerProxy.fromEndpoint( |
| 1181 core.MojoMessagePipeEndpoint endpoint) |
| 1182 : super(new _ProcessControllerProxyControl.fromEndpoint(endpoint)); |
1219 | 1183 |
1220 _ProcessControllerProxyCalls(this._proxyImpl); | 1184 ProcessControllerProxy.fromHandle(core.MojoHandle handle) |
1221 dynamic wait([Function responseFactory = null]) { | 1185 : super(new _ProcessControllerProxyControl.fromHandle(handle)); |
1222 var params = new _ProcessControllerWaitParams(); | |
1223 return _proxyImpl.sendMessageWithRequestId( | |
1224 params, | |
1225 _processControllerMethodWaitName, | |
1226 -1, | |
1227 bindings.MessageHeader.kMessageExpectsResponse); | |
1228 } | |
1229 dynamic kill(int signal,[Function responseFactory = null]) { | |
1230 var params = new _ProcessControllerKillParams(); | |
1231 params.signal = signal; | |
1232 return _proxyImpl.sendMessageWithRequestId( | |
1233 params, | |
1234 _processControllerMethodKillName, | |
1235 -1, | |
1236 bindings.MessageHeader.kMessageExpectsResponse); | |
1237 } | |
1238 } | |
1239 | 1186 |
| 1187 ProcessControllerProxy.unbound() |
| 1188 : super(new _ProcessControllerProxyControl.unbound()); |
1240 | 1189 |
1241 class ProcessControllerProxy implements bindings.ProxyBase { | 1190 static ProcessControllerProxy newFromEndpoint( |
1242 final bindings.Proxy impl; | 1191 core.MojoMessagePipeEndpoint endpoint) { |
1243 ProcessController ptr; | 1192 assert(endpoint.setDescription("For ProcessControllerProxy")); |
1244 | 1193 return new ProcessControllerProxy.fromEndpoint(endpoint); |
1245 ProcessControllerProxy(_ProcessControllerProxyImpl proxyImpl) : | |
1246 impl = proxyImpl, | |
1247 ptr = new _ProcessControllerProxyCalls(proxyImpl); | |
1248 | |
1249 ProcessControllerProxy.fromEndpoint( | |
1250 core.MojoMessagePipeEndpoint endpoint) : | |
1251 impl = new _ProcessControllerProxyImpl.fromEndpoint(endpoint) { | |
1252 ptr = new _ProcessControllerProxyCalls(impl); | |
1253 } | |
1254 | |
1255 ProcessControllerProxy.fromHandle(core.MojoHandle handle) : | |
1256 impl = new _ProcessControllerProxyImpl.fromHandle(handle) { | |
1257 ptr = new _ProcessControllerProxyCalls(impl); | |
1258 } | |
1259 | |
1260 ProcessControllerProxy.unbound() : | |
1261 impl = new _ProcessControllerProxyImpl.unbound() { | |
1262 ptr = new _ProcessControllerProxyCalls(impl); | |
1263 } | 1194 } |
1264 | 1195 |
1265 factory ProcessControllerProxy.connectToService( | 1196 factory ProcessControllerProxy.connectToService( |
1266 bindings.ServiceConnector s, String url, [String serviceName]) { | 1197 bindings.ServiceConnector s, String url, [String serviceName]) { |
1267 ProcessControllerProxy p = new ProcessControllerProxy.unbound(); | 1198 ProcessControllerProxy p = new ProcessControllerProxy.unbound(); |
1268 s.connectToService(url, p, serviceName); | 1199 s.connectToService(url, p, serviceName); |
1269 return p; | 1200 return p; |
1270 } | 1201 } |
1271 | 1202 |
1272 static ProcessControllerProxy newFromEndpoint( | 1203 |
1273 core.MojoMessagePipeEndpoint endpoint) { | 1204 dynamic wait([Function responseFactory = null]) { |
1274 assert(endpoint.setDescription("For ProcessControllerProxy")); | 1205 var params = new _ProcessControllerWaitParams(); |
1275 return new ProcessControllerProxy.fromEndpoint(endpoint); | 1206 return ctrl.sendMessageWithRequestId( |
| 1207 params, |
| 1208 _processControllerMethodWaitName, |
| 1209 -1, |
| 1210 bindings.MessageHeader.kMessageExpectsResponse); |
1276 } | 1211 } |
1277 | 1212 dynamic kill(int signal,[Function responseFactory = null]) { |
1278 String get serviceName => ProcessController.serviceName; | 1213 var params = new _ProcessControllerKillParams(); |
1279 | 1214 params.signal = signal; |
1280 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 1215 return ctrl.sendMessageWithRequestId( |
1281 | 1216 params, |
1282 Future responseOrError(Future f) => impl.responseOrError(f); | 1217 _processControllerMethodKillName, |
1283 | 1218 -1, |
1284 Future get errorFuture => impl.errorFuture; | 1219 bindings.MessageHeader.kMessageExpectsResponse); |
1285 | |
1286 int get version => impl.version; | |
1287 | |
1288 Future<int> queryVersion() => impl.queryVersion(); | |
1289 | |
1290 void requireVersion(int requiredVersion) { | |
1291 impl.requireVersion(requiredVersion); | |
1292 } | |
1293 | |
1294 String toString() { | |
1295 return "ProcessControllerProxy($impl)"; | |
1296 } | 1220 } |
1297 } | 1221 } |
1298 | 1222 |
1299 | 1223 |
1300 class ProcessControllerStub extends bindings.Stub { | 1224 class ProcessControllerStub extends bindings.Stub { |
1301 ProcessController _impl; | 1225 ProcessController _impl; |
1302 | 1226 |
1303 ProcessControllerStub.fromEndpoint( | 1227 ProcessControllerStub.fromEndpoint( |
1304 core.MojoMessagePipeEndpoint endpoint, [ProcessController impl]) | 1228 core.MojoMessagePipeEndpoint endpoint, [ProcessController impl]) |
1305 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 1229 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1422 static service_describer.ServiceDescription get serviceDescription { | 1346 static service_describer.ServiceDescription get serviceDescription { |
1423 if (_cachedServiceDescription == null) { | 1347 if (_cachedServiceDescription == null) { |
1424 _cachedServiceDescription = new _ProcessControllerServiceDescription(); | 1348 _cachedServiceDescription = new _ProcessControllerServiceDescription(); |
1425 } | 1349 } |
1426 return _cachedServiceDescription; | 1350 return _cachedServiceDescription; |
1427 } | 1351 } |
1428 } | 1352 } |
1429 | 1353 |
1430 | 1354 |
1431 | 1355 |
OLD | NEW |