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

Side by Side Diff: mojo/dart/packages/mojo_services/lib/mojo/web_socket.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 web_socket_mojom; 5 library web_socket_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
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 931
932 abstract class WebSocket { 932 abstract class WebSocket {
933 static const String serviceName = null; 933 static const String serviceName = null;
934 void connect(String url, List<String> protocols, String origin, core.MojoDataP ipeConsumer sendStream, Object client); 934 void connect(String url, List<String> protocols, String origin, core.MojoDataP ipeConsumer sendStream, Object client);
935 void send(bool fin, WebSocketMessageType type, int numBytes); 935 void send(bool fin, WebSocketMessageType type, int numBytes);
936 void flowControl(int quota); 936 void flowControl(int quota);
937 void close_(int code, String reason); 937 void close_(int code, String reason);
938 static const int kAbnormalCloseCode = 1006; 938 static const int kAbnormalCloseCode = 1006;
939 } 939 }
940 940
941 941 class _WebSocketProxyControl
942 class _WebSocketProxyControl extends bindings.ProxyMessageHandler 942 extends bindings.ProxyMessageHandler
943 implements bindings.ProxyControl { 943 implements bindings.ProxyControl {
944 _WebSocketProxyControl.fromEndpoint( 944 _WebSocketProxyControl.fromEndpoint(
945 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 945 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
946 946
947 _WebSocketProxyControl.fromHandle( 947 _WebSocketProxyControl.fromHandle(
948 core.MojoHandle handle) : super.fromHandle(handle); 948 core.MojoHandle handle) : super.fromHandle(handle);
949 949
950 _WebSocketProxyControl.unbound() : super.unbound(); 950 _WebSocketProxyControl.unbound() : super.unbound();
951 951
952 service_describer.ServiceDescription get serviceDescription => 952 service_describer.ServiceDescription get serviceDescription =>
953 new _WebSocketServiceDescription(); 953 new _WebSocketServiceDescription();
954 954
955 String get serviceName => WebSocket.serviceName; 955 String get serviceName => WebSocket.serviceName;
956 956
957 @override
958 void handleResponse(bindings.ServiceMessage message) { 957 void handleResponse(bindings.ServiceMessage message) {
959 switch (message.header.type) { 958 switch (message.header.type) {
960 default: 959 default:
961 proxyError("Unexpected message type: ${message.header.type}"); 960 proxyError("Unexpected message type: ${message.header.type}");
962 close(immediate: true); 961 close(immediate: true);
963 break; 962 break;
964 } 963 }
965 } 964 }
966 965
967 @override 966 @override
968 String toString() { 967 String toString() {
969 var superString = super.toString(); 968 var superString = super.toString();
970 return "_WebSocketProxyControl($superString)"; 969 return "_WebSocketProxyControl($superString)";
971 } 970 }
972 } 971 }
973 972
974 973 class WebSocketProxy
975 class WebSocketProxy extends bindings.Proxy 974 extends bindings.Proxy
976 implements WebSocket { 975 implements WebSocket {
977 WebSocketProxy.fromEndpoint( 976 WebSocketProxy.fromEndpoint(
978 core.MojoMessagePipeEndpoint endpoint) 977 core.MojoMessagePipeEndpoint endpoint)
979 : super(new _WebSocketProxyControl.fromEndpoint(endpoint)); 978 : super(new _WebSocketProxyControl.fromEndpoint(endpoint));
980 979
981 WebSocketProxy.fromHandle(core.MojoHandle handle) 980 WebSocketProxy.fromHandle(core.MojoHandle handle)
982 : super(new _WebSocketProxyControl.fromHandle(handle)); 981 : super(new _WebSocketProxyControl.fromHandle(handle));
983 982
984 WebSocketProxy.unbound() 983 WebSocketProxy.unbound()
985 : super(new _WebSocketProxyControl.unbound()); 984 : super(new _WebSocketProxyControl.unbound());
986 985
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 return; 1039 return;
1041 } 1040 }
1042 var params = new _WebSocketCloseParams(); 1041 var params = new _WebSocketCloseParams();
1043 params.code = code; 1042 params.code = code;
1044 params.reason = reason; 1043 params.reason = reason;
1045 ctrl.sendMessage(params, 1044 ctrl.sendMessage(params,
1046 _webSocketMethodCloseName); 1045 _webSocketMethodCloseName);
1047 } 1046 }
1048 } 1047 }
1049 1048
1050 1049 class _WebSocketStubControl
1051 class WebSocketStub extends bindings.Stub { 1050 extends bindings.StubMessageHandler
1051 implements bindings.StubControl<WebSocket> {
1052 WebSocket _impl; 1052 WebSocket _impl;
1053 1053
1054 WebSocketStub.fromEndpoint( 1054 _WebSocketStubControl.fromEndpoint(
1055 core.MojoMessagePipeEndpoint endpoint, [WebSocket impl]) 1055 core.MojoMessagePipeEndpoint endpoint, [WebSocket impl])
1056 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 1056 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
1057 _impl = impl; 1057 _impl = impl;
1058 } 1058 }
1059 1059
1060 WebSocketStub.fromHandle( 1060 _WebSocketStubControl.fromHandle(
1061 core.MojoHandle handle, [WebSocket impl]) 1061 core.MojoHandle handle, [WebSocket impl])
1062 : super.fromHandle(handle, autoBegin: impl != null) { 1062 : super.fromHandle(handle, autoBegin: impl != null) {
1063 _impl = impl; 1063 _impl = impl;
1064 } 1064 }
1065 1065
1066 WebSocketStub.unbound([this._impl]) : super.unbound(); 1066 _WebSocketStubControl.unbound([this._impl]) : super.unbound();
1067
1068 static WebSocketStub newFromEndpoint(
1069 core.MojoMessagePipeEndpoint endpoint) {
1070 assert(endpoint.setDescription("For WebSocketStub"));
1071 return new WebSocketStub.fromEndpoint(endpoint);
1072 }
1073 1067
1074 1068
1075 1069
1076 dynamic handleMessage(bindings.ServiceMessage message) { 1070 dynamic handleMessage(bindings.ServiceMessage message) {
1077 if (bindings.ControlMessageHandler.isControlMessage(message)) { 1071 if (bindings.ControlMessageHandler.isControlMessage(message)) {
1078 return bindings.ControlMessageHandler.handleMessage(this, 1072 return bindings.ControlMessageHandler.handleMessage(this,
1079 0, 1073 0,
1080 message); 1074 message);
1081 } 1075 }
1082 if (_impl == null) { 1076 if (_impl == null) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 } 1116 }
1123 1117
1124 @override 1118 @override
1125 void bind(core.MojoMessagePipeEndpoint endpoint) { 1119 void bind(core.MojoMessagePipeEndpoint endpoint) {
1126 super.bind(endpoint); 1120 super.bind(endpoint);
1127 if (!isOpen && (_impl != null)) { 1121 if (!isOpen && (_impl != null)) {
1128 beginHandlingEvents(); 1122 beginHandlingEvents();
1129 } 1123 }
1130 } 1124 }
1131 1125
1126 @override
1132 String toString() { 1127 String toString() {
1133 var superString = super.toString(); 1128 var superString = super.toString();
1134 return "WebSocketStub($superString)"; 1129 return "_WebSocketStubControl($superString)";
1135 } 1130 }
1136 1131
1137 int get version => 0; 1132 int get version => 0;
1138 1133
1139 static service_describer.ServiceDescription _cachedServiceDescription; 1134 static service_describer.ServiceDescription _cachedServiceDescription;
1140 static service_describer.ServiceDescription get serviceDescription { 1135 static service_describer.ServiceDescription get serviceDescription {
1141 if (_cachedServiceDescription == null) { 1136 if (_cachedServiceDescription == null) {
1142 _cachedServiceDescription = new _WebSocketServiceDescription(); 1137 _cachedServiceDescription = new _WebSocketServiceDescription();
1143 } 1138 }
1144 return _cachedServiceDescription; 1139 return _cachedServiceDescription;
1145 } 1140 }
1146 } 1141 }
1147 1142
1143 class WebSocketStub
1144 extends bindings.Stub<WebSocket>
1145 implements WebSocket {
1146 WebSocketStub.fromEndpoint(
1147 core.MojoMessagePipeEndpoint endpoint, [WebSocket impl])
1148 : super(new _WebSocketStubControl.fromEndpoint(endpoint, impl));
1149
1150 WebSocketStub.fromHandle(
1151 core.MojoHandle handle, [WebSocket impl])
1152 : super(new _WebSocketStubControl.fromHandle(handle, impl));
1153
1154 WebSocketStub.unbound([WebSocket impl])
1155 : super(new _WebSocketStubControl.unbound(impl));
1156
1157 static WebSocketStub newFromEndpoint(
1158 core.MojoMessagePipeEndpoint endpoint) {
1159 assert(endpoint.setDescription("For WebSocketStub"));
1160 return new WebSocketStub.fromEndpoint(endpoint);
1161 }
1162
1163 static service_describer.ServiceDescription get serviceDescription =>
1164 _WebSocketStubControl.serviceDescription;
1165
1166
1167 void connect(String url, List<String> protocols, String origin, core.MojoDataP ipeConsumer sendStream, Object client) {
1168 return impl.connect(url, protocols, origin, sendStream, client);
1169 }
1170 void send(bool fin, WebSocketMessageType type, int numBytes) {
1171 return impl.send(fin, type, numBytes);
1172 }
1173 void flowControl(int quota) {
1174 return impl.flowControl(quota);
1175 }
1176 void close_(int code, String reason) {
1177 return impl.close_(code, reason);
1178 }
1179 }
1180
1148 const int _webSocketClientMethodDidConnectName = 0; 1181 const int _webSocketClientMethodDidConnectName = 0;
1149 const int _webSocketClientMethodDidReceiveDataName = 1; 1182 const int _webSocketClientMethodDidReceiveDataName = 1;
1150 const int _webSocketClientMethodDidReceiveFlowControlName = 2; 1183 const int _webSocketClientMethodDidReceiveFlowControlName = 2;
1151 const int _webSocketClientMethodDidFailName = 3; 1184 const int _webSocketClientMethodDidFailName = 3;
1152 const int _webSocketClientMethodDidCloseName = 4; 1185 const int _webSocketClientMethodDidCloseName = 4;
1153 1186
1154 class _WebSocketClientServiceDescription implements service_describer.ServiceDes cription { 1187 class _WebSocketClientServiceDescription implements service_describer.ServiceDes cription {
1155 dynamic getTopLevelInterface([Function responseFactory]) => 1188 dynamic getTopLevelInterface([Function responseFactory]) =>
1156 responseFactory(null); 1189 responseFactory(null);
1157 1190
1158 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 1191 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) =>
1159 responseFactory(null); 1192 responseFactory(null);
1160 1193
1161 dynamic getAllTypeDefinitions([Function responseFactory]) => 1194 dynamic getAllTypeDefinitions([Function responseFactory]) =>
1162 responseFactory(null); 1195 responseFactory(null);
1163 } 1196 }
1164 1197
1165 abstract class WebSocketClient { 1198 abstract class WebSocketClient {
1166 static const String serviceName = null; 1199 static const String serviceName = null;
1167 void didConnect(String selectedSubprotocol, String extensions, core.MojoDataPi peConsumer receiveStream); 1200 void didConnect(String selectedSubprotocol, String extensions, core.MojoDataPi peConsumer receiveStream);
1168 void didReceiveData(bool fin, WebSocketMessageType type, int numBytes); 1201 void didReceiveData(bool fin, WebSocketMessageType type, int numBytes);
1169 void didReceiveFlowControl(int quota); 1202 void didReceiveFlowControl(int quota);
1170 void didFail(String message); 1203 void didFail(String message);
1171 void didClose(bool wasClean, int code, String reason); 1204 void didClose(bool wasClean, int code, String reason);
1172 } 1205 }
1173 1206
1174 1207 class _WebSocketClientProxyControl
1175 class _WebSocketClientProxyControl extends bindings.ProxyMessageHandler 1208 extends bindings.ProxyMessageHandler
1176 implements bindings.ProxyControl { 1209 implements bindings.ProxyControl {
1177 _WebSocketClientProxyControl.fromEndpoint( 1210 _WebSocketClientProxyControl.fromEndpoint(
1178 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 1211 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
1179 1212
1180 _WebSocketClientProxyControl.fromHandle( 1213 _WebSocketClientProxyControl.fromHandle(
1181 core.MojoHandle handle) : super.fromHandle(handle); 1214 core.MojoHandle handle) : super.fromHandle(handle);
1182 1215
1183 _WebSocketClientProxyControl.unbound() : super.unbound(); 1216 _WebSocketClientProxyControl.unbound() : super.unbound();
1184 1217
1185 service_describer.ServiceDescription get serviceDescription => 1218 service_describer.ServiceDescription get serviceDescription =>
1186 new _WebSocketClientServiceDescription(); 1219 new _WebSocketClientServiceDescription();
1187 1220
1188 String get serviceName => WebSocketClient.serviceName; 1221 String get serviceName => WebSocketClient.serviceName;
1189 1222
1190 @override
1191 void handleResponse(bindings.ServiceMessage message) { 1223 void handleResponse(bindings.ServiceMessage message) {
1192 switch (message.header.type) { 1224 switch (message.header.type) {
1193 default: 1225 default:
1194 proxyError("Unexpected message type: ${message.header.type}"); 1226 proxyError("Unexpected message type: ${message.header.type}");
1195 close(immediate: true); 1227 close(immediate: true);
1196 break; 1228 break;
1197 } 1229 }
1198 } 1230 }
1199 1231
1200 @override 1232 @override
1201 String toString() { 1233 String toString() {
1202 var superString = super.toString(); 1234 var superString = super.toString();
1203 return "_WebSocketClientProxyControl($superString)"; 1235 return "_WebSocketClientProxyControl($superString)";
1204 } 1236 }
1205 } 1237 }
1206 1238
1207 1239 class WebSocketClientProxy
1208 class WebSocketClientProxy extends bindings.Proxy 1240 extends bindings.Proxy
1209 implements WebSocketClient { 1241 implements WebSocketClient {
1210 WebSocketClientProxy.fromEndpoint( 1242 WebSocketClientProxy.fromEndpoint(
1211 core.MojoMessagePipeEndpoint endpoint) 1243 core.MojoMessagePipeEndpoint endpoint)
1212 : super(new _WebSocketClientProxyControl.fromEndpoint(endpoint)); 1244 : super(new _WebSocketClientProxyControl.fromEndpoint(endpoint));
1213 1245
1214 WebSocketClientProxy.fromHandle(core.MojoHandle handle) 1246 WebSocketClientProxy.fromHandle(core.MojoHandle handle)
1215 : super(new _WebSocketClientProxyControl.fromHandle(handle)); 1247 : super(new _WebSocketClientProxyControl.fromHandle(handle));
1216 1248
1217 WebSocketClientProxy.unbound() 1249 WebSocketClientProxy.unbound()
1218 : super(new _WebSocketClientProxyControl.unbound()); 1250 : super(new _WebSocketClientProxyControl.unbound());
1219 1251
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 } 1314 }
1283 var params = new _WebSocketClientDidCloseParams(); 1315 var params = new _WebSocketClientDidCloseParams();
1284 params.wasClean = wasClean; 1316 params.wasClean = wasClean;
1285 params.code = code; 1317 params.code = code;
1286 params.reason = reason; 1318 params.reason = reason;
1287 ctrl.sendMessage(params, 1319 ctrl.sendMessage(params,
1288 _webSocketClientMethodDidCloseName); 1320 _webSocketClientMethodDidCloseName);
1289 } 1321 }
1290 } 1322 }
1291 1323
1292 1324 class _WebSocketClientStubControl
1293 class WebSocketClientStub extends bindings.Stub { 1325 extends bindings.StubMessageHandler
1326 implements bindings.StubControl<WebSocketClient> {
1294 WebSocketClient _impl; 1327 WebSocketClient _impl;
1295 1328
1296 WebSocketClientStub.fromEndpoint( 1329 _WebSocketClientStubControl.fromEndpoint(
1297 core.MojoMessagePipeEndpoint endpoint, [WebSocketClient impl]) 1330 core.MojoMessagePipeEndpoint endpoint, [WebSocketClient impl])
1298 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 1331 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
1299 _impl = impl; 1332 _impl = impl;
1300 } 1333 }
1301 1334
1302 WebSocketClientStub.fromHandle( 1335 _WebSocketClientStubControl.fromHandle(
1303 core.MojoHandle handle, [WebSocketClient impl]) 1336 core.MojoHandle handle, [WebSocketClient impl])
1304 : super.fromHandle(handle, autoBegin: impl != null) { 1337 : super.fromHandle(handle, autoBegin: impl != null) {
1305 _impl = impl; 1338 _impl = impl;
1306 } 1339 }
1307 1340
1308 WebSocketClientStub.unbound([this._impl]) : super.unbound(); 1341 _WebSocketClientStubControl.unbound([this._impl]) : super.unbound();
1309
1310 static WebSocketClientStub newFromEndpoint(
1311 core.MojoMessagePipeEndpoint endpoint) {
1312 assert(endpoint.setDescription("For WebSocketClientStub"));
1313 return new WebSocketClientStub.fromEndpoint(endpoint);
1314 }
1315 1342
1316 1343
1317 1344
1318 dynamic handleMessage(bindings.ServiceMessage message) { 1345 dynamic handleMessage(bindings.ServiceMessage message) {
1319 if (bindings.ControlMessageHandler.isControlMessage(message)) { 1346 if (bindings.ControlMessageHandler.isControlMessage(message)) {
1320 return bindings.ControlMessageHandler.handleMessage(this, 1347 return bindings.ControlMessageHandler.handleMessage(this,
1321 0, 1348 0,
1322 message); 1349 message);
1323 } 1350 }
1324 if (_impl == null) { 1351 if (_impl == null) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 } 1396 }
1370 1397
1371 @override 1398 @override
1372 void bind(core.MojoMessagePipeEndpoint endpoint) { 1399 void bind(core.MojoMessagePipeEndpoint endpoint) {
1373 super.bind(endpoint); 1400 super.bind(endpoint);
1374 if (!isOpen && (_impl != null)) { 1401 if (!isOpen && (_impl != null)) {
1375 beginHandlingEvents(); 1402 beginHandlingEvents();
1376 } 1403 }
1377 } 1404 }
1378 1405
1406 @override
1379 String toString() { 1407 String toString() {
1380 var superString = super.toString(); 1408 var superString = super.toString();
1381 return "WebSocketClientStub($superString)"; 1409 return "_WebSocketClientStubControl($superString)";
1382 } 1410 }
1383 1411
1384 int get version => 0; 1412 int get version => 0;
1385 1413
1386 static service_describer.ServiceDescription _cachedServiceDescription; 1414 static service_describer.ServiceDescription _cachedServiceDescription;
1387 static service_describer.ServiceDescription get serviceDescription { 1415 static service_describer.ServiceDescription get serviceDescription {
1388 if (_cachedServiceDescription == null) { 1416 if (_cachedServiceDescription == null) {
1389 _cachedServiceDescription = new _WebSocketClientServiceDescription(); 1417 _cachedServiceDescription = new _WebSocketClientServiceDescription();
1390 } 1418 }
1391 return _cachedServiceDescription; 1419 return _cachedServiceDescription;
1392 } 1420 }
1393 } 1421 }
1394 1422
1423 class WebSocketClientStub
1424 extends bindings.Stub<WebSocketClient>
1425 implements WebSocketClient {
1426 WebSocketClientStub.fromEndpoint(
1427 core.MojoMessagePipeEndpoint endpoint, [WebSocketClient impl])
1428 : super(new _WebSocketClientStubControl.fromEndpoint(endpoint, impl));
1429
1430 WebSocketClientStub.fromHandle(
1431 core.MojoHandle handle, [WebSocketClient impl])
1432 : super(new _WebSocketClientStubControl.fromHandle(handle, impl));
1433
1434 WebSocketClientStub.unbound([WebSocketClient impl])
1435 : super(new _WebSocketClientStubControl.unbound(impl));
1436
1437 static WebSocketClientStub newFromEndpoint(
1438 core.MojoMessagePipeEndpoint endpoint) {
1439 assert(endpoint.setDescription("For WebSocketClientStub"));
1440 return new WebSocketClientStub.fromEndpoint(endpoint);
1441 }
1442
1443 static service_describer.ServiceDescription get serviceDescription =>
1444 _WebSocketClientStubControl.serviceDescription;
1445
1446
1447 void didConnect(String selectedSubprotocol, String extensions, core.MojoDataPi peConsumer receiveStream) {
1448 return impl.didConnect(selectedSubprotocol, extensions, receiveStream);
1449 }
1450 void didReceiveData(bool fin, WebSocketMessageType type, int numBytes) {
1451 return impl.didReceiveData(fin, type, numBytes);
1452 }
1453 void didReceiveFlowControl(int quota) {
1454 return impl.didReceiveFlowControl(quota);
1455 }
1456 void didFail(String message) {
1457 return impl.didFail(message);
1458 }
1459 void didClose(bool wasClean, int code, String reason) {
1460 return impl.didClose(wasClean, code, reason);
1461 }
1462 }
1463
1395 1464
1396 1465
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698