| 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 hit_tests_mojom; | 5 library hit_tests_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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 dynamic getAllTypeDefinitions([Function responseFactory]) => | 718 dynamic getAllTypeDefinitions([Function responseFactory]) => |
| 719 responseFactory(null); | 719 responseFactory(null); |
| 720 } | 720 } |
| 721 | 721 |
| 722 abstract class HitTester { | 722 abstract class HitTester { |
| 723 static const String serviceName = null; | 723 static const String serviceName = null; |
| 724 dynamic hitTest(geometry_mojom.PointF point,[Function responseFactory = null])
; | 724 dynamic hitTest(geometry_mojom.PointF point,[Function responseFactory = null])
; |
| 725 } | 725 } |
| 726 | 726 |
| 727 | 727 |
| 728 class _HitTesterProxyImpl extends bindings.Proxy { | 728 class _HitTesterProxyControl extends bindings.ProxyMessageHandler |
| 729 _HitTesterProxyImpl.fromEndpoint( | 729 implements bindings.ProxyControl { |
| 730 _HitTesterProxyControl.fromEndpoint( |
| 730 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 731 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 731 | 732 |
| 732 _HitTesterProxyImpl.fromHandle(core.MojoHandle handle) : | 733 _HitTesterProxyControl.fromHandle( |
| 733 super.fromHandle(handle); | 734 core.MojoHandle handle) : super.fromHandle(handle); |
| 734 | 735 |
| 735 _HitTesterProxyImpl.unbound() : super.unbound(); | 736 _HitTesterProxyControl.unbound() : super.unbound(); |
| 736 | |
| 737 static _HitTesterProxyImpl newFromEndpoint( | |
| 738 core.MojoMessagePipeEndpoint endpoint) { | |
| 739 assert(endpoint.setDescription("For _HitTesterProxyImpl")); | |
| 740 return new _HitTesterProxyImpl.fromEndpoint(endpoint); | |
| 741 } | |
| 742 | 737 |
| 743 service_describer.ServiceDescription get serviceDescription => | 738 service_describer.ServiceDescription get serviceDescription => |
| 744 new _HitTesterServiceDescription(); | 739 new _HitTesterServiceDescription(); |
| 745 | 740 |
| 741 String get serviceName => HitTester.serviceName; |
| 742 |
| 743 @override |
| 746 void handleResponse(bindings.ServiceMessage message) { | 744 void handleResponse(bindings.ServiceMessage message) { |
| 747 switch (message.header.type) { | 745 switch (message.header.type) { |
| 748 case _hitTesterMethodHitTestName: | 746 case _hitTesterMethodHitTestName: |
| 749 var r = HitTesterHitTestResponseParams.deserialize( | 747 var r = HitTesterHitTestResponseParams.deserialize( |
| 750 message.payload); | 748 message.payload); |
| 751 if (!message.header.hasRequestId) { | 749 if (!message.header.hasRequestId) { |
| 752 proxyError("Expected a message with a valid request Id."); | 750 proxyError("Expected a message with a valid request Id."); |
| 753 return; | 751 return; |
| 754 } | 752 } |
| 755 Completer c = completerMap[message.header.requestId]; | 753 Completer c = completerMap[message.header.requestId]; |
| 756 if (c == null) { | 754 if (c == null) { |
| 757 proxyError( | 755 proxyError( |
| 758 "Message had unknown request Id: ${message.header.requestId}"); | 756 "Message had unknown request Id: ${message.header.requestId}"); |
| 759 return; | 757 return; |
| 760 } | 758 } |
| 761 completerMap.remove(message.header.requestId); | 759 completerMap.remove(message.header.requestId); |
| 762 if (c.isCompleted) { | 760 if (c.isCompleted) { |
| 763 proxyError("Response completer already completed"); | 761 proxyError("Response completer already completed"); |
| 764 return; | 762 return; |
| 765 } | 763 } |
| 766 c.complete(r); | 764 c.complete(r); |
| 767 break; | 765 break; |
| 768 default: | 766 default: |
| 769 proxyError("Unexpected message type: ${message.header.type}"); | 767 proxyError("Unexpected message type: ${message.header.type}"); |
| 770 close(immediate: true); | 768 close(immediate: true); |
| 771 break; | 769 break; |
| 772 } | 770 } |
| 773 } | 771 } |
| 774 | 772 |
| 773 @override |
| 775 String toString() { | 774 String toString() { |
| 776 var superString = super.toString(); | 775 var superString = super.toString(); |
| 777 return "_HitTesterProxyImpl($superString)"; | 776 return "_HitTesterProxyControl($superString)"; |
| 778 } | 777 } |
| 779 } | 778 } |
| 780 | 779 |
| 781 | 780 |
| 782 class _HitTesterProxyCalls implements HitTester { | 781 class HitTesterProxy extends bindings.Proxy |
| 783 _HitTesterProxyImpl _proxyImpl; | 782 implements HitTester { |
| 783 HitTesterProxy.fromEndpoint( |
| 784 core.MojoMessagePipeEndpoint endpoint) |
| 785 : super(new _HitTesterProxyControl.fromEndpoint(endpoint)); |
| 784 | 786 |
| 785 _HitTesterProxyCalls(this._proxyImpl); | 787 HitTesterProxy.fromHandle(core.MojoHandle handle) |
| 786 dynamic hitTest(geometry_mojom.PointF point,[Function responseFactory = null
]) { | 788 : super(new _HitTesterProxyControl.fromHandle(handle)); |
| 787 var params = new _HitTesterHitTestParams(); | |
| 788 params.point = point; | |
| 789 return _proxyImpl.sendMessageWithRequestId( | |
| 790 params, | |
| 791 _hitTesterMethodHitTestName, | |
| 792 -1, | |
| 793 bindings.MessageHeader.kMessageExpectsResponse); | |
| 794 } | |
| 795 } | |
| 796 | 789 |
| 790 HitTesterProxy.unbound() |
| 791 : super(new _HitTesterProxyControl.unbound()); |
| 797 | 792 |
| 798 class HitTesterProxy implements bindings.ProxyBase { | 793 static HitTesterProxy newFromEndpoint( |
| 799 final bindings.Proxy impl; | 794 core.MojoMessagePipeEndpoint endpoint) { |
| 800 HitTester ptr; | 795 assert(endpoint.setDescription("For HitTesterProxy")); |
| 801 | 796 return new HitTesterProxy.fromEndpoint(endpoint); |
| 802 HitTesterProxy(_HitTesterProxyImpl proxyImpl) : | |
| 803 impl = proxyImpl, | |
| 804 ptr = new _HitTesterProxyCalls(proxyImpl); | |
| 805 | |
| 806 HitTesterProxy.fromEndpoint( | |
| 807 core.MojoMessagePipeEndpoint endpoint) : | |
| 808 impl = new _HitTesterProxyImpl.fromEndpoint(endpoint) { | |
| 809 ptr = new _HitTesterProxyCalls(impl); | |
| 810 } | |
| 811 | |
| 812 HitTesterProxy.fromHandle(core.MojoHandle handle) : | |
| 813 impl = new _HitTesterProxyImpl.fromHandle(handle) { | |
| 814 ptr = new _HitTesterProxyCalls(impl); | |
| 815 } | |
| 816 | |
| 817 HitTesterProxy.unbound() : | |
| 818 impl = new _HitTesterProxyImpl.unbound() { | |
| 819 ptr = new _HitTesterProxyCalls(impl); | |
| 820 } | 797 } |
| 821 | 798 |
| 822 factory HitTesterProxy.connectToService( | 799 factory HitTesterProxy.connectToService( |
| 823 bindings.ServiceConnector s, String url, [String serviceName]) { | 800 bindings.ServiceConnector s, String url, [String serviceName]) { |
| 824 HitTesterProxy p = new HitTesterProxy.unbound(); | 801 HitTesterProxy p = new HitTesterProxy.unbound(); |
| 825 s.connectToService(url, p, serviceName); | 802 s.connectToService(url, p, serviceName); |
| 826 return p; | 803 return p; |
| 827 } | 804 } |
| 828 | 805 |
| 829 static HitTesterProxy newFromEndpoint( | |
| 830 core.MojoMessagePipeEndpoint endpoint) { | |
| 831 assert(endpoint.setDescription("For HitTesterProxy")); | |
| 832 return new HitTesterProxy.fromEndpoint(endpoint); | |
| 833 } | |
| 834 | 806 |
| 835 String get serviceName => HitTester.serviceName; | 807 dynamic hitTest(geometry_mojom.PointF point,[Function responseFactory = null])
{ |
| 836 | 808 var params = new _HitTesterHitTestParams(); |
| 837 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 809 params.point = point; |
| 838 | 810 return ctrl.sendMessageWithRequestId( |
| 839 Future responseOrError(Future f) => impl.responseOrError(f); | 811 params, |
| 840 | 812 _hitTesterMethodHitTestName, |
| 841 Future get errorFuture => impl.errorFuture; | 813 -1, |
| 842 | 814 bindings.MessageHeader.kMessageExpectsResponse); |
| 843 int get version => impl.version; | |
| 844 | |
| 845 Future<int> queryVersion() => impl.queryVersion(); | |
| 846 | |
| 847 void requireVersion(int requiredVersion) { | |
| 848 impl.requireVersion(requiredVersion); | |
| 849 } | |
| 850 | |
| 851 String toString() { | |
| 852 return "HitTesterProxy($impl)"; | |
| 853 } | 815 } |
| 854 } | 816 } |
| 855 | 817 |
| 856 | 818 |
| 857 class HitTesterStub extends bindings.Stub { | 819 class HitTesterStub extends bindings.Stub { |
| 858 HitTester _impl; | 820 HitTester _impl; |
| 859 | 821 |
| 860 HitTesterStub.fromEndpoint( | 822 HitTesterStub.fromEndpoint( |
| 861 core.MojoMessagePipeEndpoint endpoint, [HitTester impl]) | 823 core.MojoMessagePipeEndpoint endpoint, [HitTester impl]) |
| 862 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 824 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 static service_describer.ServiceDescription get serviceDescription { | 915 static service_describer.ServiceDescription get serviceDescription { |
| 954 if (_cachedServiceDescription == null) { | 916 if (_cachedServiceDescription == null) { |
| 955 _cachedServiceDescription = new _HitTesterServiceDescription(); | 917 _cachedServiceDescription = new _HitTesterServiceDescription(); |
| 956 } | 918 } |
| 957 return _cachedServiceDescription; | 919 return _cachedServiceDescription; |
| 958 } | 920 } |
| 959 } | 921 } |
| 960 | 922 |
| 961 | 923 |
| 962 | 924 |
| OLD | NEW |