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 service_registry_mojom; | 5 library service_registry_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/service_provider.mojom.dart' as service_provider_mojom
; | 10 import 'package:mojo/mojo/service_provider.mojom.dart' as service_provider_mojom
; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 dynamic getAllTypeDefinitions([Function responseFactory]) => | 121 dynamic getAllTypeDefinitions([Function responseFactory]) => |
122 responseFactory(null); | 122 responseFactory(null); |
123 } | 123 } |
124 | 124 |
125 abstract class ServiceRegistry { | 125 abstract class ServiceRegistry { |
126 static const String serviceName = "mojo::ServiceRegistry"; | 126 static const String serviceName = "mojo::ServiceRegistry"; |
127 void addServices(List<String> interfaceNames, Object serviceProvider); | 127 void addServices(List<String> interfaceNames, Object serviceProvider); |
128 } | 128 } |
129 | 129 |
130 | 130 class _ServiceRegistryProxyControl |
131 class _ServiceRegistryProxyControl extends bindings.ProxyMessageHandler | 131 extends bindings.ProxyMessageHandler |
132 implements bindings.ProxyControl { | 132 implements bindings.ProxyControl { |
133 _ServiceRegistryProxyControl.fromEndpoint( | 133 _ServiceRegistryProxyControl.fromEndpoint( |
134 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 134 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
135 | 135 |
136 _ServiceRegistryProxyControl.fromHandle( | 136 _ServiceRegistryProxyControl.fromHandle( |
137 core.MojoHandle handle) : super.fromHandle(handle); | 137 core.MojoHandle handle) : super.fromHandle(handle); |
138 | 138 |
139 _ServiceRegistryProxyControl.unbound() : super.unbound(); | 139 _ServiceRegistryProxyControl.unbound() : super.unbound(); |
140 | 140 |
141 service_describer.ServiceDescription get serviceDescription => | 141 service_describer.ServiceDescription get serviceDescription => |
142 new _ServiceRegistryServiceDescription(); | 142 new _ServiceRegistryServiceDescription(); |
143 | 143 |
144 String get serviceName => ServiceRegistry.serviceName; | 144 String get serviceName => ServiceRegistry.serviceName; |
145 | 145 |
146 @override | |
147 void handleResponse(bindings.ServiceMessage message) { | 146 void handleResponse(bindings.ServiceMessage message) { |
148 switch (message.header.type) { | 147 switch (message.header.type) { |
149 default: | 148 default: |
150 proxyError("Unexpected message type: ${message.header.type}"); | 149 proxyError("Unexpected message type: ${message.header.type}"); |
151 close(immediate: true); | 150 close(immediate: true); |
152 break; | 151 break; |
153 } | 152 } |
154 } | 153 } |
155 | 154 |
156 @override | 155 @override |
157 String toString() { | 156 String toString() { |
158 var superString = super.toString(); | 157 var superString = super.toString(); |
159 return "_ServiceRegistryProxyControl($superString)"; | 158 return "_ServiceRegistryProxyControl($superString)"; |
160 } | 159 } |
161 } | 160 } |
162 | 161 |
163 | 162 class ServiceRegistryProxy |
164 class ServiceRegistryProxy extends bindings.Proxy | 163 extends bindings.Proxy |
165 implements ServiceRegistry { | 164 implements ServiceRegistry { |
166 ServiceRegistryProxy.fromEndpoint( | 165 ServiceRegistryProxy.fromEndpoint( |
167 core.MojoMessagePipeEndpoint endpoint) | 166 core.MojoMessagePipeEndpoint endpoint) |
168 : super(new _ServiceRegistryProxyControl.fromEndpoint(endpoint)); | 167 : super(new _ServiceRegistryProxyControl.fromEndpoint(endpoint)); |
169 | 168 |
170 ServiceRegistryProxy.fromHandle(core.MojoHandle handle) | 169 ServiceRegistryProxy.fromHandle(core.MojoHandle handle) |
171 : super(new _ServiceRegistryProxyControl.fromHandle(handle)); | 170 : super(new _ServiceRegistryProxyControl.fromHandle(handle)); |
172 | 171 |
173 ServiceRegistryProxy.unbound() | 172 ServiceRegistryProxy.unbound() |
174 : super(new _ServiceRegistryProxyControl.unbound()); | 173 : super(new _ServiceRegistryProxyControl.unbound()); |
175 | 174 |
(...skipping 17 matching lines...) Expand all Loading... |
193 return; | 192 return; |
194 } | 193 } |
195 var params = new _ServiceRegistryAddServicesParams(); | 194 var params = new _ServiceRegistryAddServicesParams(); |
196 params.interfaceNames = interfaceNames; | 195 params.interfaceNames = interfaceNames; |
197 params.serviceProvider = serviceProvider; | 196 params.serviceProvider = serviceProvider; |
198 ctrl.sendMessage(params, | 197 ctrl.sendMessage(params, |
199 _serviceRegistryMethodAddServicesName); | 198 _serviceRegistryMethodAddServicesName); |
200 } | 199 } |
201 } | 200 } |
202 | 201 |
203 | 202 class _ServiceRegistryStubControl |
204 class ServiceRegistryStub extends bindings.Stub { | 203 extends bindings.StubMessageHandler |
| 204 implements bindings.StubControl<ServiceRegistry> { |
205 ServiceRegistry _impl; | 205 ServiceRegistry _impl; |
206 | 206 |
207 ServiceRegistryStub.fromEndpoint( | 207 _ServiceRegistryStubControl.fromEndpoint( |
208 core.MojoMessagePipeEndpoint endpoint, [ServiceRegistry impl]) | 208 core.MojoMessagePipeEndpoint endpoint, [ServiceRegistry impl]) |
209 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 209 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
210 _impl = impl; | 210 _impl = impl; |
211 } | 211 } |
212 | 212 |
213 ServiceRegistryStub.fromHandle( | 213 _ServiceRegistryStubControl.fromHandle( |
214 core.MojoHandle handle, [ServiceRegistry impl]) | 214 core.MojoHandle handle, [ServiceRegistry impl]) |
215 : super.fromHandle(handle, autoBegin: impl != null) { | 215 : super.fromHandle(handle, autoBegin: impl != null) { |
216 _impl = impl; | 216 _impl = impl; |
217 } | 217 } |
218 | 218 |
219 ServiceRegistryStub.unbound([this._impl]) : super.unbound(); | 219 _ServiceRegistryStubControl.unbound([this._impl]) : super.unbound(); |
220 | |
221 static ServiceRegistryStub newFromEndpoint( | |
222 core.MojoMessagePipeEndpoint endpoint) { | |
223 assert(endpoint.setDescription("For ServiceRegistryStub")); | |
224 return new ServiceRegistryStub.fromEndpoint(endpoint); | |
225 } | |
226 | 220 |
227 | 221 |
228 | 222 |
229 dynamic handleMessage(bindings.ServiceMessage message) { | 223 dynamic handleMessage(bindings.ServiceMessage message) { |
230 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 224 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
231 return bindings.ControlMessageHandler.handleMessage(this, | 225 return bindings.ControlMessageHandler.handleMessage(this, |
232 0, | 226 0, |
233 message); | 227 message); |
234 } | 228 } |
235 if (_impl == null) { | 229 if (_impl == null) { |
(...skipping 24 matching lines...) Expand all Loading... |
260 } | 254 } |
261 | 255 |
262 @override | 256 @override |
263 void bind(core.MojoMessagePipeEndpoint endpoint) { | 257 void bind(core.MojoMessagePipeEndpoint endpoint) { |
264 super.bind(endpoint); | 258 super.bind(endpoint); |
265 if (!isOpen && (_impl != null)) { | 259 if (!isOpen && (_impl != null)) { |
266 beginHandlingEvents(); | 260 beginHandlingEvents(); |
267 } | 261 } |
268 } | 262 } |
269 | 263 |
| 264 @override |
270 String toString() { | 265 String toString() { |
271 var superString = super.toString(); | 266 var superString = super.toString(); |
272 return "ServiceRegistryStub($superString)"; | 267 return "_ServiceRegistryStubControl($superString)"; |
273 } | 268 } |
274 | 269 |
275 int get version => 0; | 270 int get version => 0; |
276 | 271 |
277 static service_describer.ServiceDescription _cachedServiceDescription; | 272 static service_describer.ServiceDescription _cachedServiceDescription; |
278 static service_describer.ServiceDescription get serviceDescription { | 273 static service_describer.ServiceDescription get serviceDescription { |
279 if (_cachedServiceDescription == null) { | 274 if (_cachedServiceDescription == null) { |
280 _cachedServiceDescription = new _ServiceRegistryServiceDescription(); | 275 _cachedServiceDescription = new _ServiceRegistryServiceDescription(); |
281 } | 276 } |
282 return _cachedServiceDescription; | 277 return _cachedServiceDescription; |
283 } | 278 } |
284 } | 279 } |
285 | 280 |
| 281 class ServiceRegistryStub |
| 282 extends bindings.Stub<ServiceRegistry> |
| 283 implements ServiceRegistry { |
| 284 ServiceRegistryStub.fromEndpoint( |
| 285 core.MojoMessagePipeEndpoint endpoint, [ServiceRegistry impl]) |
| 286 : super(new _ServiceRegistryStubControl.fromEndpoint(endpoint, impl)); |
| 287 |
| 288 ServiceRegistryStub.fromHandle( |
| 289 core.MojoHandle handle, [ServiceRegistry impl]) |
| 290 : super(new _ServiceRegistryStubControl.fromHandle(handle, impl)); |
| 291 |
| 292 ServiceRegistryStub.unbound([ServiceRegistry impl]) |
| 293 : super(new _ServiceRegistryStubControl.unbound(impl)); |
| 294 |
| 295 static ServiceRegistryStub newFromEndpoint( |
| 296 core.MojoMessagePipeEndpoint endpoint) { |
| 297 assert(endpoint.setDescription("For ServiceRegistryStub")); |
| 298 return new ServiceRegistryStub.fromEndpoint(endpoint); |
| 299 } |
| 300 |
| 301 static service_describer.ServiceDescription get serviceDescription => |
| 302 _ServiceRegistryStubControl.serviceDescription; |
| 303 |
| 304 |
| 305 void addServices(List<String> interfaceNames, Object serviceProvider) { |
| 306 return impl.addServices(interfaceNames, serviceProvider); |
| 307 } |
| 308 } |
| 309 |
286 | 310 |
287 | 311 |
OLD | NEW |