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 surfaces_mojom; | 5 library surfaces_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/geometry.mojom.dart' as geometry_mojom; | 10 import 'package:mojo_services/mojo/geometry.mojom.dart' as geometry_mojom; |
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 dynamic getAllTypeDefinitions([Function responseFactory]) => | 1255 dynamic getAllTypeDefinitions([Function responseFactory]) => |
1256 responseFactory(null); | 1256 responseFactory(null); |
1257 } | 1257 } |
1258 | 1258 |
1259 abstract class ResourceReturner { | 1259 abstract class ResourceReturner { |
1260 static const String serviceName = null; | 1260 static const String serviceName = null; |
1261 void returnResources(List<ReturnedResource> resources); | 1261 void returnResources(List<ReturnedResource> resources); |
1262 } | 1262 } |
1263 | 1263 |
1264 | 1264 |
1265 class _ResourceReturnerProxyImpl extends bindings.Proxy { | 1265 class _ResourceReturnerProxyControl extends bindings.ProxyMessageHandler |
1266 _ResourceReturnerProxyImpl.fromEndpoint( | 1266 implements bindings.ProxyControl { |
| 1267 _ResourceReturnerProxyControl.fromEndpoint( |
1267 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 1268 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
1268 | 1269 |
1269 _ResourceReturnerProxyImpl.fromHandle(core.MojoHandle handle) : | 1270 _ResourceReturnerProxyControl.fromHandle( |
1270 super.fromHandle(handle); | 1271 core.MojoHandle handle) : super.fromHandle(handle); |
1271 | 1272 |
1272 _ResourceReturnerProxyImpl.unbound() : super.unbound(); | 1273 _ResourceReturnerProxyControl.unbound() : super.unbound(); |
1273 | |
1274 static _ResourceReturnerProxyImpl newFromEndpoint( | |
1275 core.MojoMessagePipeEndpoint endpoint) { | |
1276 assert(endpoint.setDescription("For _ResourceReturnerProxyImpl")); | |
1277 return new _ResourceReturnerProxyImpl.fromEndpoint(endpoint); | |
1278 } | |
1279 | 1274 |
1280 service_describer.ServiceDescription get serviceDescription => | 1275 service_describer.ServiceDescription get serviceDescription => |
1281 new _ResourceReturnerServiceDescription(); | 1276 new _ResourceReturnerServiceDescription(); |
1282 | 1277 |
| 1278 String get serviceName => ResourceReturner.serviceName; |
| 1279 |
| 1280 @override |
1283 void handleResponse(bindings.ServiceMessage message) { | 1281 void handleResponse(bindings.ServiceMessage message) { |
1284 switch (message.header.type) { | 1282 switch (message.header.type) { |
1285 default: | 1283 default: |
1286 proxyError("Unexpected message type: ${message.header.type}"); | 1284 proxyError("Unexpected message type: ${message.header.type}"); |
1287 close(immediate: true); | 1285 close(immediate: true); |
1288 break; | 1286 break; |
1289 } | 1287 } |
1290 } | 1288 } |
1291 | 1289 |
| 1290 @override |
1292 String toString() { | 1291 String toString() { |
1293 var superString = super.toString(); | 1292 var superString = super.toString(); |
1294 return "_ResourceReturnerProxyImpl($superString)"; | 1293 return "_ResourceReturnerProxyControl($superString)"; |
1295 } | 1294 } |
1296 } | 1295 } |
1297 | 1296 |
1298 | 1297 |
1299 class _ResourceReturnerProxyCalls implements ResourceReturner { | 1298 class ResourceReturnerProxy extends bindings.Proxy |
1300 _ResourceReturnerProxyImpl _proxyImpl; | 1299 implements ResourceReturner { |
| 1300 ResourceReturnerProxy.fromEndpoint( |
| 1301 core.MojoMessagePipeEndpoint endpoint) |
| 1302 : super(new _ResourceReturnerProxyControl.fromEndpoint(endpoint)); |
1301 | 1303 |
1302 _ResourceReturnerProxyCalls(this._proxyImpl); | 1304 ResourceReturnerProxy.fromHandle(core.MojoHandle handle) |
1303 void returnResources(List<ReturnedResource> resources) { | 1305 : super(new _ResourceReturnerProxyControl.fromHandle(handle)); |
1304 if (!_proxyImpl.isBound) { | |
1305 _proxyImpl.proxyError("The Proxy is closed."); | |
1306 return; | |
1307 } | |
1308 var params = new _ResourceReturnerReturnResourcesParams(); | |
1309 params.resources = resources; | |
1310 _proxyImpl.sendMessage(params, _resourceReturnerMethodReturnResourcesName)
; | |
1311 } | |
1312 } | |
1313 | 1306 |
| 1307 ResourceReturnerProxy.unbound() |
| 1308 : super(new _ResourceReturnerProxyControl.unbound()); |
1314 | 1309 |
1315 class ResourceReturnerProxy implements bindings.ProxyBase { | 1310 static ResourceReturnerProxy newFromEndpoint( |
1316 final bindings.Proxy impl; | 1311 core.MojoMessagePipeEndpoint endpoint) { |
1317 ResourceReturner ptr; | 1312 assert(endpoint.setDescription("For ResourceReturnerProxy")); |
1318 | 1313 return new ResourceReturnerProxy.fromEndpoint(endpoint); |
1319 ResourceReturnerProxy(_ResourceReturnerProxyImpl proxyImpl) : | |
1320 impl = proxyImpl, | |
1321 ptr = new _ResourceReturnerProxyCalls(proxyImpl); | |
1322 | |
1323 ResourceReturnerProxy.fromEndpoint( | |
1324 core.MojoMessagePipeEndpoint endpoint) : | |
1325 impl = new _ResourceReturnerProxyImpl.fromEndpoint(endpoint) { | |
1326 ptr = new _ResourceReturnerProxyCalls(impl); | |
1327 } | |
1328 | |
1329 ResourceReturnerProxy.fromHandle(core.MojoHandle handle) : | |
1330 impl = new _ResourceReturnerProxyImpl.fromHandle(handle) { | |
1331 ptr = new _ResourceReturnerProxyCalls(impl); | |
1332 } | |
1333 | |
1334 ResourceReturnerProxy.unbound() : | |
1335 impl = new _ResourceReturnerProxyImpl.unbound() { | |
1336 ptr = new _ResourceReturnerProxyCalls(impl); | |
1337 } | 1314 } |
1338 | 1315 |
1339 factory ResourceReturnerProxy.connectToService( | 1316 factory ResourceReturnerProxy.connectToService( |
1340 bindings.ServiceConnector s, String url, [String serviceName]) { | 1317 bindings.ServiceConnector s, String url, [String serviceName]) { |
1341 ResourceReturnerProxy p = new ResourceReturnerProxy.unbound(); | 1318 ResourceReturnerProxy p = new ResourceReturnerProxy.unbound(); |
1342 s.connectToService(url, p, serviceName); | 1319 s.connectToService(url, p, serviceName); |
1343 return p; | 1320 return p; |
1344 } | 1321 } |
1345 | 1322 |
1346 static ResourceReturnerProxy newFromEndpoint( | |
1347 core.MojoMessagePipeEndpoint endpoint) { | |
1348 assert(endpoint.setDescription("For ResourceReturnerProxy")); | |
1349 return new ResourceReturnerProxy.fromEndpoint(endpoint); | |
1350 } | |
1351 | 1323 |
1352 String get serviceName => ResourceReturner.serviceName; | 1324 void returnResources(List<ReturnedResource> resources) { |
1353 | 1325 if (!ctrl.isBound) { |
1354 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 1326 ctrl.proxyError("The Proxy is closed."); |
1355 | 1327 return; |
1356 Future responseOrError(Future f) => impl.responseOrError(f); | 1328 } |
1357 | 1329 var params = new _ResourceReturnerReturnResourcesParams(); |
1358 Future get errorFuture => impl.errorFuture; | 1330 params.resources = resources; |
1359 | 1331 ctrl.sendMessage(params, |
1360 int get version => impl.version; | 1332 _resourceReturnerMethodReturnResourcesName); |
1361 | |
1362 Future<int> queryVersion() => impl.queryVersion(); | |
1363 | |
1364 void requireVersion(int requiredVersion) { | |
1365 impl.requireVersion(requiredVersion); | |
1366 } | |
1367 | |
1368 String toString() { | |
1369 return "ResourceReturnerProxy($impl)"; | |
1370 } | 1333 } |
1371 } | 1334 } |
1372 | 1335 |
1373 | 1336 |
1374 class ResourceReturnerStub extends bindings.Stub { | 1337 class ResourceReturnerStub extends bindings.Stub { |
1375 ResourceReturner _impl; | 1338 ResourceReturner _impl; |
1376 | 1339 |
1377 ResourceReturnerStub.fromEndpoint( | 1340 ResourceReturnerStub.fromEndpoint( |
1378 core.MojoMessagePipeEndpoint endpoint, [ResourceReturner impl]) | 1341 core.MojoMessagePipeEndpoint endpoint, [ResourceReturner impl]) |
1379 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 1342 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 abstract class Surface { | 1436 abstract class Surface { |
1474 static const String serviceName = "mojo::Surface"; | 1437 static const String serviceName = "mojo::Surface"; |
1475 dynamic getIdNamespace([Function responseFactory = null]); | 1438 dynamic getIdNamespace([Function responseFactory = null]); |
1476 void setResourceReturner(Object returner); | 1439 void setResourceReturner(Object returner); |
1477 void createSurface(int idLocal); | 1440 void createSurface(int idLocal); |
1478 dynamic submitFrame(int idLocal,Frame frame,[Function responseFactory = null])
; | 1441 dynamic submitFrame(int idLocal,Frame frame,[Function responseFactory = null])
; |
1479 void destroySurface(int idLocal); | 1442 void destroySurface(int idLocal); |
1480 } | 1443 } |
1481 | 1444 |
1482 | 1445 |
1483 class _SurfaceProxyImpl extends bindings.Proxy { | 1446 class _SurfaceProxyControl extends bindings.ProxyMessageHandler |
1484 _SurfaceProxyImpl.fromEndpoint( | 1447 implements bindings.ProxyControl { |
| 1448 _SurfaceProxyControl.fromEndpoint( |
1485 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 1449 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
1486 | 1450 |
1487 _SurfaceProxyImpl.fromHandle(core.MojoHandle handle) : | 1451 _SurfaceProxyControl.fromHandle( |
1488 super.fromHandle(handle); | 1452 core.MojoHandle handle) : super.fromHandle(handle); |
1489 | 1453 |
1490 _SurfaceProxyImpl.unbound() : super.unbound(); | 1454 _SurfaceProxyControl.unbound() : super.unbound(); |
1491 | |
1492 static _SurfaceProxyImpl newFromEndpoint( | |
1493 core.MojoMessagePipeEndpoint endpoint) { | |
1494 assert(endpoint.setDescription("For _SurfaceProxyImpl")); | |
1495 return new _SurfaceProxyImpl.fromEndpoint(endpoint); | |
1496 } | |
1497 | 1455 |
1498 service_describer.ServiceDescription get serviceDescription => | 1456 service_describer.ServiceDescription get serviceDescription => |
1499 new _SurfaceServiceDescription(); | 1457 new _SurfaceServiceDescription(); |
1500 | 1458 |
| 1459 String get serviceName => Surface.serviceName; |
| 1460 |
| 1461 @override |
1501 void handleResponse(bindings.ServiceMessage message) { | 1462 void handleResponse(bindings.ServiceMessage message) { |
1502 switch (message.header.type) { | 1463 switch (message.header.type) { |
1503 case _surfaceMethodGetIdNamespaceName: | 1464 case _surfaceMethodGetIdNamespaceName: |
1504 var r = SurfaceGetIdNamespaceResponseParams.deserialize( | 1465 var r = SurfaceGetIdNamespaceResponseParams.deserialize( |
1505 message.payload); | 1466 message.payload); |
1506 if (!message.header.hasRequestId) { | 1467 if (!message.header.hasRequestId) { |
1507 proxyError("Expected a message with a valid request Id."); | 1468 proxyError("Expected a message with a valid request Id."); |
1508 return; | 1469 return; |
1509 } | 1470 } |
1510 Completer c = completerMap[message.header.requestId]; | 1471 Completer c = completerMap[message.header.requestId]; |
(...skipping 29 matching lines...) Expand all Loading... |
1540 } | 1501 } |
1541 c.complete(r); | 1502 c.complete(r); |
1542 break; | 1503 break; |
1543 default: | 1504 default: |
1544 proxyError("Unexpected message type: ${message.header.type}"); | 1505 proxyError("Unexpected message type: ${message.header.type}"); |
1545 close(immediate: true); | 1506 close(immediate: true); |
1546 break; | 1507 break; |
1547 } | 1508 } |
1548 } | 1509 } |
1549 | 1510 |
| 1511 @override |
1550 String toString() { | 1512 String toString() { |
1551 var superString = super.toString(); | 1513 var superString = super.toString(); |
1552 return "_SurfaceProxyImpl($superString)"; | 1514 return "_SurfaceProxyControl($superString)"; |
1553 } | 1515 } |
1554 } | 1516 } |
1555 | 1517 |
1556 | 1518 |
1557 class _SurfaceProxyCalls implements Surface { | 1519 class SurfaceProxy extends bindings.Proxy |
1558 _SurfaceProxyImpl _proxyImpl; | 1520 implements Surface { |
| 1521 SurfaceProxy.fromEndpoint( |
| 1522 core.MojoMessagePipeEndpoint endpoint) |
| 1523 : super(new _SurfaceProxyControl.fromEndpoint(endpoint)); |
1559 | 1524 |
1560 _SurfaceProxyCalls(this._proxyImpl); | 1525 SurfaceProxy.fromHandle(core.MojoHandle handle) |
1561 dynamic getIdNamespace([Function responseFactory = null]) { | 1526 : super(new _SurfaceProxyControl.fromHandle(handle)); |
1562 var params = new _SurfaceGetIdNamespaceParams(); | |
1563 return _proxyImpl.sendMessageWithRequestId( | |
1564 params, | |
1565 _surfaceMethodGetIdNamespaceName, | |
1566 -1, | |
1567 bindings.MessageHeader.kMessageExpectsResponse); | |
1568 } | |
1569 void setResourceReturner(Object returner) { | |
1570 if (!_proxyImpl.isBound) { | |
1571 _proxyImpl.proxyError("The Proxy is closed."); | |
1572 return; | |
1573 } | |
1574 var params = new _SurfaceSetResourceReturnerParams(); | |
1575 params.returner = returner; | |
1576 _proxyImpl.sendMessage(params, _surfaceMethodSetResourceReturnerName); | |
1577 } | |
1578 void createSurface(int idLocal) { | |
1579 if (!_proxyImpl.isBound) { | |
1580 _proxyImpl.proxyError("The Proxy is closed."); | |
1581 return; | |
1582 } | |
1583 var params = new _SurfaceCreateSurfaceParams(); | |
1584 params.idLocal = idLocal; | |
1585 _proxyImpl.sendMessage(params, _surfaceMethodCreateSurfaceName); | |
1586 } | |
1587 dynamic submitFrame(int idLocal,Frame frame,[Function responseFactory = null
]) { | |
1588 var params = new _SurfaceSubmitFrameParams(); | |
1589 params.idLocal = idLocal; | |
1590 params.frame = frame; | |
1591 return _proxyImpl.sendMessageWithRequestId( | |
1592 params, | |
1593 _surfaceMethodSubmitFrameName, | |
1594 -1, | |
1595 bindings.MessageHeader.kMessageExpectsResponse); | |
1596 } | |
1597 void destroySurface(int idLocal) { | |
1598 if (!_proxyImpl.isBound) { | |
1599 _proxyImpl.proxyError("The Proxy is closed."); | |
1600 return; | |
1601 } | |
1602 var params = new _SurfaceDestroySurfaceParams(); | |
1603 params.idLocal = idLocal; | |
1604 _proxyImpl.sendMessage(params, _surfaceMethodDestroySurfaceName); | |
1605 } | |
1606 } | |
1607 | 1527 |
| 1528 SurfaceProxy.unbound() |
| 1529 : super(new _SurfaceProxyControl.unbound()); |
1608 | 1530 |
1609 class SurfaceProxy implements bindings.ProxyBase { | 1531 static SurfaceProxy newFromEndpoint( |
1610 final bindings.Proxy impl; | 1532 core.MojoMessagePipeEndpoint endpoint) { |
1611 Surface ptr; | 1533 assert(endpoint.setDescription("For SurfaceProxy")); |
1612 | 1534 return new SurfaceProxy.fromEndpoint(endpoint); |
1613 SurfaceProxy(_SurfaceProxyImpl proxyImpl) : | |
1614 impl = proxyImpl, | |
1615 ptr = new _SurfaceProxyCalls(proxyImpl); | |
1616 | |
1617 SurfaceProxy.fromEndpoint( | |
1618 core.MojoMessagePipeEndpoint endpoint) : | |
1619 impl = new _SurfaceProxyImpl.fromEndpoint(endpoint) { | |
1620 ptr = new _SurfaceProxyCalls(impl); | |
1621 } | |
1622 | |
1623 SurfaceProxy.fromHandle(core.MojoHandle handle) : | |
1624 impl = new _SurfaceProxyImpl.fromHandle(handle) { | |
1625 ptr = new _SurfaceProxyCalls(impl); | |
1626 } | |
1627 | |
1628 SurfaceProxy.unbound() : | |
1629 impl = new _SurfaceProxyImpl.unbound() { | |
1630 ptr = new _SurfaceProxyCalls(impl); | |
1631 } | 1535 } |
1632 | 1536 |
1633 factory SurfaceProxy.connectToService( | 1537 factory SurfaceProxy.connectToService( |
1634 bindings.ServiceConnector s, String url, [String serviceName]) { | 1538 bindings.ServiceConnector s, String url, [String serviceName]) { |
1635 SurfaceProxy p = new SurfaceProxy.unbound(); | 1539 SurfaceProxy p = new SurfaceProxy.unbound(); |
1636 s.connectToService(url, p, serviceName); | 1540 s.connectToService(url, p, serviceName); |
1637 return p; | 1541 return p; |
1638 } | 1542 } |
1639 | 1543 |
1640 static SurfaceProxy newFromEndpoint( | 1544 |
1641 core.MojoMessagePipeEndpoint endpoint) { | 1545 dynamic getIdNamespace([Function responseFactory = null]) { |
1642 assert(endpoint.setDescription("For SurfaceProxy")); | 1546 var params = new _SurfaceGetIdNamespaceParams(); |
1643 return new SurfaceProxy.fromEndpoint(endpoint); | 1547 return ctrl.sendMessageWithRequestId( |
| 1548 params, |
| 1549 _surfaceMethodGetIdNamespaceName, |
| 1550 -1, |
| 1551 bindings.MessageHeader.kMessageExpectsResponse); |
1644 } | 1552 } |
1645 | 1553 void setResourceReturner(Object returner) { |
1646 String get serviceName => Surface.serviceName; | 1554 if (!ctrl.isBound) { |
1647 | 1555 ctrl.proxyError("The Proxy is closed."); |
1648 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 1556 return; |
1649 | 1557 } |
1650 Future responseOrError(Future f) => impl.responseOrError(f); | 1558 var params = new _SurfaceSetResourceReturnerParams(); |
1651 | 1559 params.returner = returner; |
1652 Future get errorFuture => impl.errorFuture; | 1560 ctrl.sendMessage(params, |
1653 | 1561 _surfaceMethodSetResourceReturnerName); |
1654 int get version => impl.version; | |
1655 | |
1656 Future<int> queryVersion() => impl.queryVersion(); | |
1657 | |
1658 void requireVersion(int requiredVersion) { | |
1659 impl.requireVersion(requiredVersion); | |
1660 } | 1562 } |
1661 | 1563 void createSurface(int idLocal) { |
1662 String toString() { | 1564 if (!ctrl.isBound) { |
1663 return "SurfaceProxy($impl)"; | 1565 ctrl.proxyError("The Proxy is closed."); |
| 1566 return; |
| 1567 } |
| 1568 var params = new _SurfaceCreateSurfaceParams(); |
| 1569 params.idLocal = idLocal; |
| 1570 ctrl.sendMessage(params, |
| 1571 _surfaceMethodCreateSurfaceName); |
| 1572 } |
| 1573 dynamic submitFrame(int idLocal,Frame frame,[Function responseFactory = null])
{ |
| 1574 var params = new _SurfaceSubmitFrameParams(); |
| 1575 params.idLocal = idLocal; |
| 1576 params.frame = frame; |
| 1577 return ctrl.sendMessageWithRequestId( |
| 1578 params, |
| 1579 _surfaceMethodSubmitFrameName, |
| 1580 -1, |
| 1581 bindings.MessageHeader.kMessageExpectsResponse); |
| 1582 } |
| 1583 void destroySurface(int idLocal) { |
| 1584 if (!ctrl.isBound) { |
| 1585 ctrl.proxyError("The Proxy is closed."); |
| 1586 return; |
| 1587 } |
| 1588 var params = new _SurfaceDestroySurfaceParams(); |
| 1589 params.idLocal = idLocal; |
| 1590 ctrl.sendMessage(params, |
| 1591 _surfaceMethodDestroySurfaceName); |
1664 } | 1592 } |
1665 } | 1593 } |
1666 | 1594 |
1667 | 1595 |
1668 class SurfaceStub extends bindings.Stub { | 1596 class SurfaceStub extends bindings.Stub { |
1669 Surface _impl; | 1597 Surface _impl; |
1670 | 1598 |
1671 SurfaceStub.fromEndpoint( | 1599 SurfaceStub.fromEndpoint( |
1672 core.MojoMessagePipeEndpoint endpoint, [Surface impl]) | 1600 core.MojoMessagePipeEndpoint endpoint, [Surface impl]) |
1673 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 1601 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1803 static service_describer.ServiceDescription get serviceDescription { | 1731 static service_describer.ServiceDescription get serviceDescription { |
1804 if (_cachedServiceDescription == null) { | 1732 if (_cachedServiceDescription == null) { |
1805 _cachedServiceDescription = new _SurfaceServiceDescription(); | 1733 _cachedServiceDescription = new _SurfaceServiceDescription(); |
1806 } | 1734 } |
1807 return _cachedServiceDescription; | 1735 return _cachedServiceDescription; |
1808 } | 1736 } |
1809 } | 1737 } |
1810 | 1738 |
1811 | 1739 |
1812 | 1740 |
OLD | NEW |