| 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 udp_socket_mojom; | 5 library udp_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 import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; | 10 import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; |
| (...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 impl.requireVersion(requiredVersion); | 1593 impl.requireVersion(requiredVersion); |
| 1594 } | 1594 } |
| 1595 | 1595 |
| 1596 String toString() { | 1596 String toString() { |
| 1597 return "UdpSocketProxy($impl)"; | 1597 return "UdpSocketProxy($impl)"; |
| 1598 } | 1598 } |
| 1599 } | 1599 } |
| 1600 | 1600 |
| 1601 | 1601 |
| 1602 class UdpSocketStub extends bindings.Stub { | 1602 class UdpSocketStub extends bindings.Stub { |
| 1603 UdpSocket _impl = null; | 1603 UdpSocket _impl; |
| 1604 | 1604 |
| 1605 UdpSocketStub.fromEndpoint( | 1605 UdpSocketStub.fromEndpoint( |
| 1606 core.MojoMessagePipeEndpoint endpoint, [this._impl]) | 1606 core.MojoMessagePipeEndpoint endpoint, [UdpSocket impl]) |
| 1607 : super.fromEndpoint(endpoint); | 1607 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| 1608 _impl = impl; |
| 1609 } |
| 1608 | 1610 |
| 1609 UdpSocketStub.fromHandle(core.MojoHandle handle, [this._impl]) | 1611 UdpSocketStub.fromHandle( |
| 1610 : super.fromHandle(handle); | 1612 core.MojoHandle handle, [UdpSocket impl]) |
| 1613 : super.fromHandle(handle, autoBegin: impl != null) { |
| 1614 _impl = impl; |
| 1615 } |
| 1611 | 1616 |
| 1612 UdpSocketStub.unbound() : super.unbound(); | 1617 UdpSocketStub.unbound() : super.unbound(); |
| 1613 | 1618 |
| 1614 static UdpSocketStub newFromEndpoint( | 1619 static UdpSocketStub newFromEndpoint( |
| 1615 core.MojoMessagePipeEndpoint endpoint) { | 1620 core.MojoMessagePipeEndpoint endpoint) { |
| 1616 assert(endpoint.setDescription("For UdpSocketStub")); | 1621 assert(endpoint.setDescription("For UdpSocketStub")); |
| 1617 return new UdpSocketStub.fromEndpoint(endpoint); | 1622 return new UdpSocketStub.fromEndpoint(endpoint); |
| 1618 } | 1623 } |
| 1619 | 1624 |
| 1620 | 1625 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 result.result = result; | 1662 result.result = result; |
| 1658 return result; | 1663 return result; |
| 1659 } | 1664 } |
| 1660 | 1665 |
| 1661 dynamic handleMessage(bindings.ServiceMessage message) { | 1666 dynamic handleMessage(bindings.ServiceMessage message) { |
| 1662 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 1667 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 1663 return bindings.ControlMessageHandler.handleMessage(this, | 1668 return bindings.ControlMessageHandler.handleMessage(this, |
| 1664 0, | 1669 0, |
| 1665 message); | 1670 message); |
| 1666 } | 1671 } |
| 1667 assert(_impl != null); | 1672 if (_impl == null) { |
| 1673 throw new core.MojoApiError("$this has no implementation set"); |
| 1674 } |
| 1668 switch (message.header.type) { | 1675 switch (message.header.type) { |
| 1669 case _udpSocketMethodAllowAddressReuseName: | 1676 case _udpSocketMethodAllowAddressReuseName: |
| 1670 var response = _impl.allowAddressReuse(_udpSocketAllowAddressReuseRespon
seParamsFactory); | 1677 var response = _impl.allowAddressReuse(_udpSocketAllowAddressReuseRespon
seParamsFactory); |
| 1671 if (response is Future) { | 1678 if (response is Future) { |
| 1672 return response.then((response) { | 1679 return response.then((response) { |
| 1673 if (response != null) { | 1680 if (response != null) { |
| 1674 return buildResponseWithId( | 1681 return buildResponseWithId( |
| 1675 response, | 1682 response, |
| 1676 _udpSocketMethodAllowAddressReuseName, | 1683 _udpSocketMethodAllowAddressReuseName, |
| 1677 message.header.requestId, | 1684 message.header.requestId, |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1825 break; | 1832 break; |
| 1826 default: | 1833 default: |
| 1827 throw new bindings.MojoCodecError("Unexpected message name"); | 1834 throw new bindings.MojoCodecError("Unexpected message name"); |
| 1828 break; | 1835 break; |
| 1829 } | 1836 } |
| 1830 return null; | 1837 return null; |
| 1831 } | 1838 } |
| 1832 | 1839 |
| 1833 UdpSocket get impl => _impl; | 1840 UdpSocket get impl => _impl; |
| 1834 set impl(UdpSocket d) { | 1841 set impl(UdpSocket d) { |
| 1835 assert(_impl == null); | 1842 if (d == null) { |
| 1843 throw new core.MojoApiError("$this: Cannot set a null implementation"); |
| 1844 } |
| 1845 if (isBound && (_impl == null)) { |
| 1846 beginHandlingEvents(); |
| 1847 } |
| 1836 _impl = d; | 1848 _impl = d; |
| 1837 } | 1849 } |
| 1838 | 1850 |
| 1851 @override |
| 1852 void bind(core.MojoMessagePipeEndpoint endpoint) { |
| 1853 super.bind(endpoint); |
| 1854 if (!isOpen && (_impl != null)) { |
| 1855 beginHandlingEvents(); |
| 1856 } |
| 1857 } |
| 1858 |
| 1839 String toString() { | 1859 String toString() { |
| 1840 var superString = super.toString(); | 1860 var superString = super.toString(); |
| 1841 return "UdpSocketStub($superString)"; | 1861 return "UdpSocketStub($superString)"; |
| 1842 } | 1862 } |
| 1843 | 1863 |
| 1844 int get version => 0; | 1864 int get version => 0; |
| 1845 | 1865 |
| 1846 static service_describer.ServiceDescription _cachedServiceDescription; | 1866 static service_describer.ServiceDescription _cachedServiceDescription; |
| 1847 static service_describer.ServiceDescription get serviceDescription { | 1867 static service_describer.ServiceDescription get serviceDescription { |
| 1848 if (_cachedServiceDescription == null) { | 1868 if (_cachedServiceDescription == null) { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1976 impl.requireVersion(requiredVersion); | 1996 impl.requireVersion(requiredVersion); |
| 1977 } | 1997 } |
| 1978 | 1998 |
| 1979 String toString() { | 1999 String toString() { |
| 1980 return "UdpSocketReceiverProxy($impl)"; | 2000 return "UdpSocketReceiverProxy($impl)"; |
| 1981 } | 2001 } |
| 1982 } | 2002 } |
| 1983 | 2003 |
| 1984 | 2004 |
| 1985 class UdpSocketReceiverStub extends bindings.Stub { | 2005 class UdpSocketReceiverStub extends bindings.Stub { |
| 1986 UdpSocketReceiver _impl = null; | 2006 UdpSocketReceiver _impl; |
| 1987 | 2007 |
| 1988 UdpSocketReceiverStub.fromEndpoint( | 2008 UdpSocketReceiverStub.fromEndpoint( |
| 1989 core.MojoMessagePipeEndpoint endpoint, [this._impl]) | 2009 core.MojoMessagePipeEndpoint endpoint, [UdpSocketReceiver impl]) |
| 1990 : super.fromEndpoint(endpoint); | 2010 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| 2011 _impl = impl; |
| 2012 } |
| 1991 | 2013 |
| 1992 UdpSocketReceiverStub.fromHandle(core.MojoHandle handle, [this._impl]) | 2014 UdpSocketReceiverStub.fromHandle( |
| 1993 : super.fromHandle(handle); | 2015 core.MojoHandle handle, [UdpSocketReceiver impl]) |
| 2016 : super.fromHandle(handle, autoBegin: impl != null) { |
| 2017 _impl = impl; |
| 2018 } |
| 1994 | 2019 |
| 1995 UdpSocketReceiverStub.unbound() : super.unbound(); | 2020 UdpSocketReceiverStub.unbound() : super.unbound(); |
| 1996 | 2021 |
| 1997 static UdpSocketReceiverStub newFromEndpoint( | 2022 static UdpSocketReceiverStub newFromEndpoint( |
| 1998 core.MojoMessagePipeEndpoint endpoint) { | 2023 core.MojoMessagePipeEndpoint endpoint) { |
| 1999 assert(endpoint.setDescription("For UdpSocketReceiverStub")); | 2024 assert(endpoint.setDescription("For UdpSocketReceiverStub")); |
| 2000 return new UdpSocketReceiverStub.fromEndpoint(endpoint); | 2025 return new UdpSocketReceiverStub.fromEndpoint(endpoint); |
| 2001 } | 2026 } |
| 2002 | 2027 |
| 2003 | 2028 |
| 2004 | 2029 |
| 2005 dynamic handleMessage(bindings.ServiceMessage message) { | 2030 dynamic handleMessage(bindings.ServiceMessage message) { |
| 2006 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 2031 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 2007 return bindings.ControlMessageHandler.handleMessage(this, | 2032 return bindings.ControlMessageHandler.handleMessage(this, |
| 2008 0, | 2033 0, |
| 2009 message); | 2034 message); |
| 2010 } | 2035 } |
| 2011 assert(_impl != null); | 2036 if (_impl == null) { |
| 2037 throw new core.MojoApiError("$this has no implementation set"); |
| 2038 } |
| 2012 switch (message.header.type) { | 2039 switch (message.header.type) { |
| 2013 case _udpSocketReceiverMethodOnReceivedName: | 2040 case _udpSocketReceiverMethodOnReceivedName: |
| 2014 var params = _UdpSocketReceiverOnReceivedParams.deserialize( | 2041 var params = _UdpSocketReceiverOnReceivedParams.deserialize( |
| 2015 message.payload); | 2042 message.payload); |
| 2016 _impl.onReceived(params.result, params.srcAddr, params.data); | 2043 _impl.onReceived(params.result, params.srcAddr, params.data); |
| 2017 break; | 2044 break; |
| 2018 default: | 2045 default: |
| 2019 throw new bindings.MojoCodecError("Unexpected message name"); | 2046 throw new bindings.MojoCodecError("Unexpected message name"); |
| 2020 break; | 2047 break; |
| 2021 } | 2048 } |
| 2022 return null; | 2049 return null; |
| 2023 } | 2050 } |
| 2024 | 2051 |
| 2025 UdpSocketReceiver get impl => _impl; | 2052 UdpSocketReceiver get impl => _impl; |
| 2026 set impl(UdpSocketReceiver d) { | 2053 set impl(UdpSocketReceiver d) { |
| 2027 assert(_impl == null); | 2054 if (d == null) { |
| 2055 throw new core.MojoApiError("$this: Cannot set a null implementation"); |
| 2056 } |
| 2057 if (isBound && (_impl == null)) { |
| 2058 beginHandlingEvents(); |
| 2059 } |
| 2028 _impl = d; | 2060 _impl = d; |
| 2029 } | 2061 } |
| 2030 | 2062 |
| 2063 @override |
| 2064 void bind(core.MojoMessagePipeEndpoint endpoint) { |
| 2065 super.bind(endpoint); |
| 2066 if (!isOpen && (_impl != null)) { |
| 2067 beginHandlingEvents(); |
| 2068 } |
| 2069 } |
| 2070 |
| 2031 String toString() { | 2071 String toString() { |
| 2032 var superString = super.toString(); | 2072 var superString = super.toString(); |
| 2033 return "UdpSocketReceiverStub($superString)"; | 2073 return "UdpSocketReceiverStub($superString)"; |
| 2034 } | 2074 } |
| 2035 | 2075 |
| 2036 int get version => 0; | 2076 int get version => 0; |
| 2037 | 2077 |
| 2038 static service_describer.ServiceDescription _cachedServiceDescription; | 2078 static service_describer.ServiceDescription _cachedServiceDescription; |
| 2039 static service_describer.ServiceDescription get serviceDescription { | 2079 static service_describer.ServiceDescription get serviceDescription { |
| 2040 if (_cachedServiceDescription == null) { | 2080 if (_cachedServiceDescription == null) { |
| 2041 _cachedServiceDescription = new _UdpSocketReceiverServiceDescription(); | 2081 _cachedServiceDescription = new _UdpSocketReceiverServiceDescription(); |
| 2042 } | 2082 } |
| 2043 return _cachedServiceDescription; | 2083 return _cachedServiceDescription; |
| 2044 } | 2084 } |
| 2045 } | 2085 } |
| 2046 | 2086 |
| 2047 | 2087 |
| 2048 | 2088 |
| OLD | NEW |