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 sample_service_mojom; | 5 library sample_service_mojom; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'dart:typed_data'; | 10 import 'dart:typed_data'; |
(...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 responseFactory(null); | 1754 responseFactory(null); |
1755 } | 1755 } |
1756 | 1756 |
1757 abstract class Service { | 1757 abstract class Service { |
1758 static const String serviceName = null; | 1758 static const String serviceName = null; |
1759 dynamic frobinate(Foo foo,ServiceBazOptions baz,Object port,[Function response
Factory = null]); | 1759 dynamic frobinate(Foo foo,ServiceBazOptions baz,Object port,[Function response
Factory = null]); |
1760 void getPort(Object port); | 1760 void getPort(Object port); |
1761 static const int kFavoriteBaz = 1; | 1761 static const int kFavoriteBaz = 1; |
1762 } | 1762 } |
1763 | 1763 |
1764 | 1764 class _ServiceProxyControl |
1765 class _ServiceProxyControl extends bindings.ProxyMessageHandler | 1765 extends bindings.ProxyMessageHandler |
1766 implements bindings.ProxyControl { | 1766 implements bindings.ProxyControl { |
1767 _ServiceProxyControl.fromEndpoint( | 1767 _ServiceProxyControl.fromEndpoint( |
1768 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 1768 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
1769 | 1769 |
1770 _ServiceProxyControl.fromHandle( | 1770 _ServiceProxyControl.fromHandle( |
1771 core.MojoHandle handle) : super.fromHandle(handle); | 1771 core.MojoHandle handle) : super.fromHandle(handle); |
1772 | 1772 |
1773 _ServiceProxyControl.unbound() : super.unbound(); | 1773 _ServiceProxyControl.unbound() : super.unbound(); |
1774 | 1774 |
1775 service_describer.ServiceDescription get serviceDescription => | 1775 service_describer.ServiceDescription get serviceDescription => |
1776 new _ServiceServiceDescription(); | 1776 new _ServiceServiceDescription(); |
1777 | 1777 |
1778 String get serviceName => Service.serviceName; | 1778 String get serviceName => Service.serviceName; |
1779 | 1779 |
1780 @override | |
1781 void handleResponse(bindings.ServiceMessage message) { | 1780 void handleResponse(bindings.ServiceMessage message) { |
1782 switch (message.header.type) { | 1781 switch (message.header.type) { |
1783 case _serviceMethodFrobinateName: | 1782 case _serviceMethodFrobinateName: |
1784 var r = ServiceFrobinateResponseParams.deserialize( | 1783 var r = ServiceFrobinateResponseParams.deserialize( |
1785 message.payload); | 1784 message.payload); |
1786 if (!message.header.hasRequestId) { | 1785 if (!message.header.hasRequestId) { |
1787 proxyError("Expected a message with a valid request Id."); | 1786 proxyError("Expected a message with a valid request Id."); |
1788 return; | 1787 return; |
1789 } | 1788 } |
1790 Completer c = completerMap[message.header.requestId]; | 1789 Completer c = completerMap[message.header.requestId]; |
(...skipping 16 matching lines...) Expand all Loading... |
1807 } | 1806 } |
1808 } | 1807 } |
1809 | 1808 |
1810 @override | 1809 @override |
1811 String toString() { | 1810 String toString() { |
1812 var superString = super.toString(); | 1811 var superString = super.toString(); |
1813 return "_ServiceProxyControl($superString)"; | 1812 return "_ServiceProxyControl($superString)"; |
1814 } | 1813 } |
1815 } | 1814 } |
1816 | 1815 |
1817 | 1816 class ServiceProxy |
1818 class ServiceProxy extends bindings.Proxy | 1817 extends bindings.Proxy |
1819 implements Service { | 1818 implements Service { |
1820 ServiceProxy.fromEndpoint( | 1819 ServiceProxy.fromEndpoint( |
1821 core.MojoMessagePipeEndpoint endpoint) | 1820 core.MojoMessagePipeEndpoint endpoint) |
1822 : super(new _ServiceProxyControl.fromEndpoint(endpoint)); | 1821 : super(new _ServiceProxyControl.fromEndpoint(endpoint)); |
1823 | 1822 |
1824 ServiceProxy.fromHandle(core.MojoHandle handle) | 1823 ServiceProxy.fromHandle(core.MojoHandle handle) |
1825 : super(new _ServiceProxyControl.fromHandle(handle)); | 1824 : super(new _ServiceProxyControl.fromHandle(handle)); |
1826 | 1825 |
1827 ServiceProxy.unbound() | 1826 ServiceProxy.unbound() |
1828 : super(new _ServiceProxyControl.unbound()); | 1827 : super(new _ServiceProxyControl.unbound()); |
1829 | 1828 |
(...skipping 27 matching lines...) Expand all Loading... |
1857 ctrl.proxyError("The Proxy is closed."); | 1856 ctrl.proxyError("The Proxy is closed."); |
1858 return; | 1857 return; |
1859 } | 1858 } |
1860 var params = new _ServiceGetPortParams(); | 1859 var params = new _ServiceGetPortParams(); |
1861 params.port = port; | 1860 params.port = port; |
1862 ctrl.sendMessage(params, | 1861 ctrl.sendMessage(params, |
1863 _serviceMethodGetPortName); | 1862 _serviceMethodGetPortName); |
1864 } | 1863 } |
1865 } | 1864 } |
1866 | 1865 |
1867 | 1866 class _ServiceStubControl |
1868 class ServiceStub extends bindings.Stub { | 1867 extends bindings.StubMessageHandler |
| 1868 implements bindings.StubControl<Service> { |
1869 Service _impl; | 1869 Service _impl; |
1870 | 1870 |
1871 ServiceStub.fromEndpoint( | 1871 _ServiceStubControl.fromEndpoint( |
1872 core.MojoMessagePipeEndpoint endpoint, [Service impl]) | 1872 core.MojoMessagePipeEndpoint endpoint, [Service impl]) |
1873 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 1873 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
1874 _impl = impl; | 1874 _impl = impl; |
1875 } | 1875 } |
1876 | 1876 |
1877 ServiceStub.fromHandle( | 1877 _ServiceStubControl.fromHandle( |
1878 core.MojoHandle handle, [Service impl]) | 1878 core.MojoHandle handle, [Service impl]) |
1879 : super.fromHandle(handle, autoBegin: impl != null) { | 1879 : super.fromHandle(handle, autoBegin: impl != null) { |
1880 _impl = impl; | 1880 _impl = impl; |
1881 } | 1881 } |
1882 | 1882 |
1883 ServiceStub.unbound([this._impl]) : super.unbound(); | 1883 _ServiceStubControl.unbound([this._impl]) : super.unbound(); |
1884 | |
1885 static ServiceStub newFromEndpoint( | |
1886 core.MojoMessagePipeEndpoint endpoint) { | |
1887 assert(endpoint.setDescription("For ServiceStub")); | |
1888 return new ServiceStub.fromEndpoint(endpoint); | |
1889 } | |
1890 | 1884 |
1891 | 1885 |
1892 ServiceFrobinateResponseParams _serviceFrobinateResponseParamsFactory(int resu
lt) { | 1886 ServiceFrobinateResponseParams _serviceFrobinateResponseParamsFactory(int resu
lt) { |
1893 var result = new ServiceFrobinateResponseParams(); | 1887 var result = new ServiceFrobinateResponseParams(); |
1894 result.result = result; | 1888 result.result = result; |
1895 return result; | 1889 return result; |
1896 } | 1890 } |
1897 | 1891 |
1898 dynamic handleMessage(bindings.ServiceMessage message) { | 1892 dynamic handleMessage(bindings.ServiceMessage message) { |
1899 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 1893 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1951 } | 1945 } |
1952 | 1946 |
1953 @override | 1947 @override |
1954 void bind(core.MojoMessagePipeEndpoint endpoint) { | 1948 void bind(core.MojoMessagePipeEndpoint endpoint) { |
1955 super.bind(endpoint); | 1949 super.bind(endpoint); |
1956 if (!isOpen && (_impl != null)) { | 1950 if (!isOpen && (_impl != null)) { |
1957 beginHandlingEvents(); | 1951 beginHandlingEvents(); |
1958 } | 1952 } |
1959 } | 1953 } |
1960 | 1954 |
| 1955 @override |
1961 String toString() { | 1956 String toString() { |
1962 var superString = super.toString(); | 1957 var superString = super.toString(); |
1963 return "ServiceStub($superString)"; | 1958 return "_ServiceStubControl($superString)"; |
1964 } | 1959 } |
1965 | 1960 |
1966 int get version => 0; | 1961 int get version => 0; |
1967 | 1962 |
1968 static service_describer.ServiceDescription _cachedServiceDescription; | 1963 static service_describer.ServiceDescription _cachedServiceDescription; |
1969 static service_describer.ServiceDescription get serviceDescription { | 1964 static service_describer.ServiceDescription get serviceDescription { |
1970 if (_cachedServiceDescription == null) { | 1965 if (_cachedServiceDescription == null) { |
1971 _cachedServiceDescription = new _ServiceServiceDescription(); | 1966 _cachedServiceDescription = new _ServiceServiceDescription(); |
1972 } | 1967 } |
1973 return _cachedServiceDescription; | 1968 return _cachedServiceDescription; |
1974 } | 1969 } |
1975 } | 1970 } |
1976 | 1971 |
| 1972 class ServiceStub |
| 1973 extends bindings.Stub<Service> |
| 1974 implements Service { |
| 1975 ServiceStub.fromEndpoint( |
| 1976 core.MojoMessagePipeEndpoint endpoint, [Service impl]) |
| 1977 : super(new _ServiceStubControl.fromEndpoint(endpoint, impl)); |
| 1978 |
| 1979 ServiceStub.fromHandle( |
| 1980 core.MojoHandle handle, [Service impl]) |
| 1981 : super(new _ServiceStubControl.fromHandle(handle, impl)); |
| 1982 |
| 1983 ServiceStub.unbound([Service impl]) |
| 1984 : super(new _ServiceStubControl.unbound(impl)); |
| 1985 |
| 1986 static ServiceStub newFromEndpoint( |
| 1987 core.MojoMessagePipeEndpoint endpoint) { |
| 1988 assert(endpoint.setDescription("For ServiceStub")); |
| 1989 return new ServiceStub.fromEndpoint(endpoint); |
| 1990 } |
| 1991 |
| 1992 static service_describer.ServiceDescription get serviceDescription => |
| 1993 _ServiceStubControl.serviceDescription; |
| 1994 |
| 1995 |
| 1996 dynamic frobinate(Foo foo,ServiceBazOptions baz,Object port,[Function response
Factory = null]) { |
| 1997 return impl.frobinate(foo,baz,port,responseFactory); |
| 1998 } |
| 1999 void getPort(Object port) { |
| 2000 return impl.getPort(port); |
| 2001 } |
| 2002 } |
| 2003 |
1977 const int _portMethodPostMessageName = 0; | 2004 const int _portMethodPostMessageName = 0; |
1978 | 2005 |
1979 class _PortServiceDescription implements service_describer.ServiceDescription { | 2006 class _PortServiceDescription implements service_describer.ServiceDescription { |
1980 dynamic getTopLevelInterface([Function responseFactory]) => | 2007 dynamic getTopLevelInterface([Function responseFactory]) => |
1981 responseFactory(null); | 2008 responseFactory(null); |
1982 | 2009 |
1983 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => | 2010 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => |
1984 responseFactory(null); | 2011 responseFactory(null); |
1985 | 2012 |
1986 dynamic getAllTypeDefinitions([Function responseFactory]) => | 2013 dynamic getAllTypeDefinitions([Function responseFactory]) => |
1987 responseFactory(null); | 2014 responseFactory(null); |
1988 } | 2015 } |
1989 | 2016 |
1990 abstract class Port { | 2017 abstract class Port { |
1991 static const String serviceName = null; | 2018 static const String serviceName = null; |
1992 void postMessage(String messageText, Object port); | 2019 void postMessage(String messageText, Object port); |
1993 } | 2020 } |
1994 | 2021 |
1995 | 2022 class _PortProxyControl |
1996 class _PortProxyControl extends bindings.ProxyMessageHandler | 2023 extends bindings.ProxyMessageHandler |
1997 implements bindings.ProxyControl { | 2024 implements bindings.ProxyControl { |
1998 _PortProxyControl.fromEndpoint( | 2025 _PortProxyControl.fromEndpoint( |
1999 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 2026 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
2000 | 2027 |
2001 _PortProxyControl.fromHandle( | 2028 _PortProxyControl.fromHandle( |
2002 core.MojoHandle handle) : super.fromHandle(handle); | 2029 core.MojoHandle handle) : super.fromHandle(handle); |
2003 | 2030 |
2004 _PortProxyControl.unbound() : super.unbound(); | 2031 _PortProxyControl.unbound() : super.unbound(); |
2005 | 2032 |
2006 service_describer.ServiceDescription get serviceDescription => | 2033 service_describer.ServiceDescription get serviceDescription => |
2007 new _PortServiceDescription(); | 2034 new _PortServiceDescription(); |
2008 | 2035 |
2009 String get serviceName => Port.serviceName; | 2036 String get serviceName => Port.serviceName; |
2010 | 2037 |
2011 @override | |
2012 void handleResponse(bindings.ServiceMessage message) { | 2038 void handleResponse(bindings.ServiceMessage message) { |
2013 switch (message.header.type) { | 2039 switch (message.header.type) { |
2014 default: | 2040 default: |
2015 proxyError("Unexpected message type: ${message.header.type}"); | 2041 proxyError("Unexpected message type: ${message.header.type}"); |
2016 close(immediate: true); | 2042 close(immediate: true); |
2017 break; | 2043 break; |
2018 } | 2044 } |
2019 } | 2045 } |
2020 | 2046 |
2021 @override | 2047 @override |
2022 String toString() { | 2048 String toString() { |
2023 var superString = super.toString(); | 2049 var superString = super.toString(); |
2024 return "_PortProxyControl($superString)"; | 2050 return "_PortProxyControl($superString)"; |
2025 } | 2051 } |
2026 } | 2052 } |
2027 | 2053 |
2028 | 2054 class PortProxy |
2029 class PortProxy extends bindings.Proxy | 2055 extends bindings.Proxy |
2030 implements Port { | 2056 implements Port { |
2031 PortProxy.fromEndpoint( | 2057 PortProxy.fromEndpoint( |
2032 core.MojoMessagePipeEndpoint endpoint) | 2058 core.MojoMessagePipeEndpoint endpoint) |
2033 : super(new _PortProxyControl.fromEndpoint(endpoint)); | 2059 : super(new _PortProxyControl.fromEndpoint(endpoint)); |
2034 | 2060 |
2035 PortProxy.fromHandle(core.MojoHandle handle) | 2061 PortProxy.fromHandle(core.MojoHandle handle) |
2036 : super(new _PortProxyControl.fromHandle(handle)); | 2062 : super(new _PortProxyControl.fromHandle(handle)); |
2037 | 2063 |
2038 PortProxy.unbound() | 2064 PortProxy.unbound() |
2039 : super(new _PortProxyControl.unbound()); | 2065 : super(new _PortProxyControl.unbound()); |
2040 | 2066 |
(...skipping 17 matching lines...) Expand all Loading... |
2058 return; | 2084 return; |
2059 } | 2085 } |
2060 var params = new _PortPostMessageParams(); | 2086 var params = new _PortPostMessageParams(); |
2061 params.messageText = messageText; | 2087 params.messageText = messageText; |
2062 params.port = port; | 2088 params.port = port; |
2063 ctrl.sendMessage(params, | 2089 ctrl.sendMessage(params, |
2064 _portMethodPostMessageName); | 2090 _portMethodPostMessageName); |
2065 } | 2091 } |
2066 } | 2092 } |
2067 | 2093 |
2068 | 2094 class _PortStubControl |
2069 class PortStub extends bindings.Stub { | 2095 extends bindings.StubMessageHandler |
| 2096 implements bindings.StubControl<Port> { |
2070 Port _impl; | 2097 Port _impl; |
2071 | 2098 |
2072 PortStub.fromEndpoint( | 2099 _PortStubControl.fromEndpoint( |
2073 core.MojoMessagePipeEndpoint endpoint, [Port impl]) | 2100 core.MojoMessagePipeEndpoint endpoint, [Port impl]) |
2074 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 2101 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
2075 _impl = impl; | 2102 _impl = impl; |
2076 } | 2103 } |
2077 | 2104 |
2078 PortStub.fromHandle( | 2105 _PortStubControl.fromHandle( |
2079 core.MojoHandle handle, [Port impl]) | 2106 core.MojoHandle handle, [Port impl]) |
2080 : super.fromHandle(handle, autoBegin: impl != null) { | 2107 : super.fromHandle(handle, autoBegin: impl != null) { |
2081 _impl = impl; | 2108 _impl = impl; |
2082 } | 2109 } |
2083 | 2110 |
2084 PortStub.unbound([this._impl]) : super.unbound(); | 2111 _PortStubControl.unbound([this._impl]) : super.unbound(); |
2085 | |
2086 static PortStub newFromEndpoint( | |
2087 core.MojoMessagePipeEndpoint endpoint) { | |
2088 assert(endpoint.setDescription("For PortStub")); | |
2089 return new PortStub.fromEndpoint(endpoint); | |
2090 } | |
2091 | 2112 |
2092 | 2113 |
2093 | 2114 |
2094 dynamic handleMessage(bindings.ServiceMessage message) { | 2115 dynamic handleMessage(bindings.ServiceMessage message) { |
2095 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 2116 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
2096 return bindings.ControlMessageHandler.handleMessage(this, | 2117 return bindings.ControlMessageHandler.handleMessage(this, |
2097 0, | 2118 0, |
2098 message); | 2119 message); |
2099 } | 2120 } |
2100 if (_impl == null) { | 2121 if (_impl == null) { |
(...skipping 24 matching lines...) Expand all Loading... |
2125 } | 2146 } |
2126 | 2147 |
2127 @override | 2148 @override |
2128 void bind(core.MojoMessagePipeEndpoint endpoint) { | 2149 void bind(core.MojoMessagePipeEndpoint endpoint) { |
2129 super.bind(endpoint); | 2150 super.bind(endpoint); |
2130 if (!isOpen && (_impl != null)) { | 2151 if (!isOpen && (_impl != null)) { |
2131 beginHandlingEvents(); | 2152 beginHandlingEvents(); |
2132 } | 2153 } |
2133 } | 2154 } |
2134 | 2155 |
| 2156 @override |
2135 String toString() { | 2157 String toString() { |
2136 var superString = super.toString(); | 2158 var superString = super.toString(); |
2137 return "PortStub($superString)"; | 2159 return "_PortStubControl($superString)"; |
2138 } | 2160 } |
2139 | 2161 |
2140 int get version => 0; | 2162 int get version => 0; |
2141 | 2163 |
2142 static service_describer.ServiceDescription _cachedServiceDescription; | 2164 static service_describer.ServiceDescription _cachedServiceDescription; |
2143 static service_describer.ServiceDescription get serviceDescription { | 2165 static service_describer.ServiceDescription get serviceDescription { |
2144 if (_cachedServiceDescription == null) { | 2166 if (_cachedServiceDescription == null) { |
2145 _cachedServiceDescription = new _PortServiceDescription(); | 2167 _cachedServiceDescription = new _PortServiceDescription(); |
2146 } | 2168 } |
2147 return _cachedServiceDescription; | 2169 return _cachedServiceDescription; |
2148 } | 2170 } |
2149 } | 2171 } |
2150 | 2172 |
| 2173 class PortStub |
| 2174 extends bindings.Stub<Port> |
| 2175 implements Port { |
| 2176 PortStub.fromEndpoint( |
| 2177 core.MojoMessagePipeEndpoint endpoint, [Port impl]) |
| 2178 : super(new _PortStubControl.fromEndpoint(endpoint, impl)); |
| 2179 |
| 2180 PortStub.fromHandle( |
| 2181 core.MojoHandle handle, [Port impl]) |
| 2182 : super(new _PortStubControl.fromHandle(handle, impl)); |
| 2183 |
| 2184 PortStub.unbound([Port impl]) |
| 2185 : super(new _PortStubControl.unbound(impl)); |
| 2186 |
| 2187 static PortStub newFromEndpoint( |
| 2188 core.MojoMessagePipeEndpoint endpoint) { |
| 2189 assert(endpoint.setDescription("For PortStub")); |
| 2190 return new PortStub.fromEndpoint(endpoint); |
| 2191 } |
| 2192 |
| 2193 static service_describer.ServiceDescription get serviceDescription => |
| 2194 _PortStubControl.serviceDescription; |
| 2195 |
| 2196 |
| 2197 void postMessage(String messageText, Object port) { |
| 2198 return impl.postMessage(messageText, port); |
| 2199 } |
| 2200 } |
| 2201 |
2151 | 2202 |
2152 mojom_types.RuntimeTypeInfo getRuntimeTypeInfo() => _runtimeTypeInfo ?? | 2203 mojom_types.RuntimeTypeInfo getRuntimeTypeInfo() => _runtimeTypeInfo ?? |
2153 _initRuntimeTypeInfo(); | 2204 _initRuntimeTypeInfo(); |
2154 | 2205 |
2155 Map<String, mojom_types.UserDefinedType> getAllMojomTypeDefinitions() { | 2206 Map<String, mojom_types.UserDefinedType> getAllMojomTypeDefinitions() { |
2156 return getRuntimeTypeInfo().typeMap; | 2207 return getRuntimeTypeInfo().typeMap; |
2157 } | 2208 } |
2158 | 2209 |
2159 var _runtimeTypeInfo; | 2210 var _runtimeTypeInfo; |
2160 mojom_types.RuntimeTypeInfo _initRuntimeTypeInfo() { | 2211 mojom_types.RuntimeTypeInfo _initRuntimeTypeInfo() { |
(...skipping 13 matching lines...) Expand all Loading... |
2174 _runtimeTypeInfo.typeMap[s] = udt; | 2225 _runtimeTypeInfo.typeMap[s] = udt; |
2175 }); | 2226 }); |
2176 | 2227 |
2177 sample_import2_mojom.getAllMojomTypeDefinitions() | 2228 sample_import2_mojom.getAllMojomTypeDefinitions() |
2178 .forEach((String s, mojom_types.UserDefinedType udt) { | 2229 .forEach((String s, mojom_types.UserDefinedType udt) { |
2179 _runtimeTypeInfo.typeMap[s] = udt; | 2230 _runtimeTypeInfo.typeMap[s] = udt; |
2180 }); | 2231 }); |
2181 | 2232 |
2182 return _runtimeTypeInfo; | 2233 return _runtimeTypeInfo; |
2183 } | 2234 } |
OLD | NEW |