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 shell_mojom; | 5 library shell_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/application_connector.mojom.dart' as application_conne
ctor_mojom; | 10 import 'package:mojo/mojo/application_connector.mojom.dart' as application_conne
ctor_mojom; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 dynamic getAllTypeDefinitions([Function responseFactory]) => | 192 dynamic getAllTypeDefinitions([Function responseFactory]) => |
193 responseFactory(null); | 193 responseFactory(null); |
194 } | 194 } |
195 | 195 |
196 abstract class Shell { | 196 abstract class Shell { |
197 static const String serviceName = null; | 197 static const String serviceName = null; |
198 void connectToApplication(String applicationUrl, Object services, Object expos
edServices); | 198 void connectToApplication(String applicationUrl, Object services, Object expos
edServices); |
199 void createApplicationConnector(Object applicationConnectorRequest); | 199 void createApplicationConnector(Object applicationConnectorRequest); |
200 } | 200 } |
201 | 201 |
202 | 202 class _ShellProxyControl |
203 class _ShellProxyControl extends bindings.ProxyMessageHandler | 203 extends bindings.ProxyMessageHandler |
204 implements bindings.ProxyControl { | 204 implements bindings.ProxyControl { |
205 _ShellProxyControl.fromEndpoint( | 205 _ShellProxyControl.fromEndpoint( |
206 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 206 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
207 | 207 |
208 _ShellProxyControl.fromHandle( | 208 _ShellProxyControl.fromHandle( |
209 core.MojoHandle handle) : super.fromHandle(handle); | 209 core.MojoHandle handle) : super.fromHandle(handle); |
210 | 210 |
211 _ShellProxyControl.unbound() : super.unbound(); | 211 _ShellProxyControl.unbound() : super.unbound(); |
212 | 212 |
213 service_describer.ServiceDescription get serviceDescription => | 213 service_describer.ServiceDescription get serviceDescription => |
214 new _ShellServiceDescription(); | 214 new _ShellServiceDescription(); |
215 | 215 |
216 String get serviceName => Shell.serviceName; | 216 String get serviceName => Shell.serviceName; |
217 | 217 |
218 @override | |
219 void handleResponse(bindings.ServiceMessage message) { | 218 void handleResponse(bindings.ServiceMessage message) { |
220 switch (message.header.type) { | 219 switch (message.header.type) { |
221 default: | 220 default: |
222 proxyError("Unexpected message type: ${message.header.type}"); | 221 proxyError("Unexpected message type: ${message.header.type}"); |
223 close(immediate: true); | 222 close(immediate: true); |
224 break; | 223 break; |
225 } | 224 } |
226 } | 225 } |
227 | 226 |
228 @override | 227 @override |
229 String toString() { | 228 String toString() { |
230 var superString = super.toString(); | 229 var superString = super.toString(); |
231 return "_ShellProxyControl($superString)"; | 230 return "_ShellProxyControl($superString)"; |
232 } | 231 } |
233 } | 232 } |
234 | 233 |
235 | 234 class ShellProxy |
236 class ShellProxy extends bindings.Proxy | 235 extends bindings.Proxy |
237 implements Shell { | 236 implements Shell { |
238 ShellProxy.fromEndpoint( | 237 ShellProxy.fromEndpoint( |
239 core.MojoMessagePipeEndpoint endpoint) | 238 core.MojoMessagePipeEndpoint endpoint) |
240 : super(new _ShellProxyControl.fromEndpoint(endpoint)); | 239 : super(new _ShellProxyControl.fromEndpoint(endpoint)); |
241 | 240 |
242 ShellProxy.fromHandle(core.MojoHandle handle) | 241 ShellProxy.fromHandle(core.MojoHandle handle) |
243 : super(new _ShellProxyControl.fromHandle(handle)); | 242 : super(new _ShellProxyControl.fromHandle(handle)); |
244 | 243 |
245 ShellProxy.unbound() | 244 ShellProxy.unbound() |
246 : super(new _ShellProxyControl.unbound()); | 245 : super(new _ShellProxyControl.unbound()); |
247 | 246 |
(...skipping 28 matching lines...) Expand all Loading... |
276 ctrl.proxyError("The Proxy is closed."); | 275 ctrl.proxyError("The Proxy is closed."); |
277 return; | 276 return; |
278 } | 277 } |
279 var params = new _ShellCreateApplicationConnectorParams(); | 278 var params = new _ShellCreateApplicationConnectorParams(); |
280 params.applicationConnectorRequest = applicationConnectorRequest; | 279 params.applicationConnectorRequest = applicationConnectorRequest; |
281 ctrl.sendMessage(params, | 280 ctrl.sendMessage(params, |
282 _shellMethodCreateApplicationConnectorName); | 281 _shellMethodCreateApplicationConnectorName); |
283 } | 282 } |
284 } | 283 } |
285 | 284 |
286 | 285 class _ShellStubControl |
287 class ShellStub extends bindings.Stub { | 286 extends bindings.StubMessageHandler |
| 287 implements bindings.StubControl<Shell> { |
288 Shell _impl; | 288 Shell _impl; |
289 | 289 |
290 ShellStub.fromEndpoint( | 290 _ShellStubControl.fromEndpoint( |
291 core.MojoMessagePipeEndpoint endpoint, [Shell impl]) | 291 core.MojoMessagePipeEndpoint endpoint, [Shell impl]) |
292 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 292 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
293 _impl = impl; | 293 _impl = impl; |
294 } | 294 } |
295 | 295 |
296 ShellStub.fromHandle( | 296 _ShellStubControl.fromHandle( |
297 core.MojoHandle handle, [Shell impl]) | 297 core.MojoHandle handle, [Shell impl]) |
298 : super.fromHandle(handle, autoBegin: impl != null) { | 298 : super.fromHandle(handle, autoBegin: impl != null) { |
299 _impl = impl; | 299 _impl = impl; |
300 } | 300 } |
301 | 301 |
302 ShellStub.unbound([this._impl]) : super.unbound(); | 302 _ShellStubControl.unbound([this._impl]) : super.unbound(); |
303 | |
304 static ShellStub newFromEndpoint( | |
305 core.MojoMessagePipeEndpoint endpoint) { | |
306 assert(endpoint.setDescription("For ShellStub")); | |
307 return new ShellStub.fromEndpoint(endpoint); | |
308 } | |
309 | 303 |
310 | 304 |
311 | 305 |
312 dynamic handleMessage(bindings.ServiceMessage message) { | 306 dynamic handleMessage(bindings.ServiceMessage message) { |
313 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 307 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
314 return bindings.ControlMessageHandler.handleMessage(this, | 308 return bindings.ControlMessageHandler.handleMessage(this, |
315 0, | 309 0, |
316 message); | 310 message); |
317 } | 311 } |
318 if (_impl == null) { | 312 if (_impl == null) { |
(...skipping 29 matching lines...) Expand all Loading... |
348 } | 342 } |
349 | 343 |
350 @override | 344 @override |
351 void bind(core.MojoMessagePipeEndpoint endpoint) { | 345 void bind(core.MojoMessagePipeEndpoint endpoint) { |
352 super.bind(endpoint); | 346 super.bind(endpoint); |
353 if (!isOpen && (_impl != null)) { | 347 if (!isOpen && (_impl != null)) { |
354 beginHandlingEvents(); | 348 beginHandlingEvents(); |
355 } | 349 } |
356 } | 350 } |
357 | 351 |
| 352 @override |
358 String toString() { | 353 String toString() { |
359 var superString = super.toString(); | 354 var superString = super.toString(); |
360 return "ShellStub($superString)"; | 355 return "_ShellStubControl($superString)"; |
361 } | 356 } |
362 | 357 |
363 int get version => 0; | 358 int get version => 0; |
364 | 359 |
365 static service_describer.ServiceDescription _cachedServiceDescription; | 360 static service_describer.ServiceDescription _cachedServiceDescription; |
366 static service_describer.ServiceDescription get serviceDescription { | 361 static service_describer.ServiceDescription get serviceDescription { |
367 if (_cachedServiceDescription == null) { | 362 if (_cachedServiceDescription == null) { |
368 _cachedServiceDescription = new _ShellServiceDescription(); | 363 _cachedServiceDescription = new _ShellServiceDescription(); |
369 } | 364 } |
370 return _cachedServiceDescription; | 365 return _cachedServiceDescription; |
371 } | 366 } |
372 } | 367 } |
373 | 368 |
| 369 class ShellStub |
| 370 extends bindings.Stub<Shell> |
| 371 implements Shell { |
| 372 ShellStub.fromEndpoint( |
| 373 core.MojoMessagePipeEndpoint endpoint, [Shell impl]) |
| 374 : super(new _ShellStubControl.fromEndpoint(endpoint, impl)); |
| 375 |
| 376 ShellStub.fromHandle( |
| 377 core.MojoHandle handle, [Shell impl]) |
| 378 : super(new _ShellStubControl.fromHandle(handle, impl)); |
| 379 |
| 380 ShellStub.unbound([Shell impl]) |
| 381 : super(new _ShellStubControl.unbound(impl)); |
| 382 |
| 383 static ShellStub newFromEndpoint( |
| 384 core.MojoMessagePipeEndpoint endpoint) { |
| 385 assert(endpoint.setDescription("For ShellStub")); |
| 386 return new ShellStub.fromEndpoint(endpoint); |
| 387 } |
| 388 |
| 389 static service_describer.ServiceDescription get serviceDescription => |
| 390 _ShellStubControl.serviceDescription; |
| 391 |
| 392 |
| 393 void connectToApplication(String applicationUrl, Object services, Object expos
edServices) { |
| 394 return impl.connectToApplication(applicationUrl, services, exposedServices); |
| 395 } |
| 396 void createApplicationConnector(Object applicationConnectorRequest) { |
| 397 return impl.createApplicationConnector(applicationConnectorRequest); |
| 398 } |
| 399 } |
| 400 |
374 | 401 |
375 | 402 |
OLD | NEW |