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 application_mojom; | 5 library application_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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 } | 309 } |
310 | 310 |
311 abstract class Application { | 311 abstract class Application { |
312 static const String serviceName = null; | 312 static const String serviceName = null; |
313 void initialize(Object shell, List<String> args, String url); | 313 void initialize(Object shell, List<String> args, String url); |
314 void acceptConnection(String requestorUrl, Object services, Object exposedServ
ices, String resolvedUrl); | 314 void acceptConnection(String requestorUrl, Object services, Object exposedServ
ices, String resolvedUrl); |
315 void requestQuit(); | 315 void requestQuit(); |
316 } | 316 } |
317 | 317 |
318 | 318 |
319 class _ApplicationProxyImpl extends bindings.Proxy { | 319 class _ApplicationProxyControl extends bindings.ProxyMessageHandler |
320 _ApplicationProxyImpl.fromEndpoint( | 320 implements bindings.ProxyControl { |
| 321 _ApplicationProxyControl.fromEndpoint( |
321 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 322 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
322 | 323 |
323 _ApplicationProxyImpl.fromHandle(core.MojoHandle handle) : | 324 _ApplicationProxyControl.fromHandle( |
324 super.fromHandle(handle); | 325 core.MojoHandle handle) : super.fromHandle(handle); |
325 | 326 |
326 _ApplicationProxyImpl.unbound() : super.unbound(); | 327 _ApplicationProxyControl.unbound() : super.unbound(); |
327 | |
328 static _ApplicationProxyImpl newFromEndpoint( | |
329 core.MojoMessagePipeEndpoint endpoint) { | |
330 assert(endpoint.setDescription("For _ApplicationProxyImpl")); | |
331 return new _ApplicationProxyImpl.fromEndpoint(endpoint); | |
332 } | |
333 | 328 |
334 service_describer.ServiceDescription get serviceDescription => | 329 service_describer.ServiceDescription get serviceDescription => |
335 new _ApplicationServiceDescription(); | 330 new _ApplicationServiceDescription(); |
336 | 331 |
| 332 String get serviceName => Application.serviceName; |
| 333 |
| 334 @override |
337 void handleResponse(bindings.ServiceMessage message) { | 335 void handleResponse(bindings.ServiceMessage message) { |
338 switch (message.header.type) { | 336 switch (message.header.type) { |
339 default: | 337 default: |
340 proxyError("Unexpected message type: ${message.header.type}"); | 338 proxyError("Unexpected message type: ${message.header.type}"); |
341 close(immediate: true); | 339 close(immediate: true); |
342 break; | 340 break; |
343 } | 341 } |
344 } | 342 } |
345 | 343 |
| 344 @override |
346 String toString() { | 345 String toString() { |
347 var superString = super.toString(); | 346 var superString = super.toString(); |
348 return "_ApplicationProxyImpl($superString)"; | 347 return "_ApplicationProxyControl($superString)"; |
349 } | 348 } |
350 } | 349 } |
351 | 350 |
352 | 351 |
353 class _ApplicationProxyCalls implements Application { | 352 class ApplicationProxy extends bindings.Proxy |
354 _ApplicationProxyImpl _proxyImpl; | 353 implements Application { |
| 354 ApplicationProxy.fromEndpoint( |
| 355 core.MojoMessagePipeEndpoint endpoint) |
| 356 : super(new _ApplicationProxyControl.fromEndpoint(endpoint)); |
355 | 357 |
356 _ApplicationProxyCalls(this._proxyImpl); | 358 ApplicationProxy.fromHandle(core.MojoHandle handle) |
357 void initialize(Object shell, List<String> args, String url) { | 359 : super(new _ApplicationProxyControl.fromHandle(handle)); |
358 if (!_proxyImpl.isBound) { | |
359 _proxyImpl.proxyError("The Proxy is closed."); | |
360 return; | |
361 } | |
362 var params = new _ApplicationInitializeParams(); | |
363 params.shell = shell; | |
364 params.args = args; | |
365 params.url = url; | |
366 _proxyImpl.sendMessage(params, _applicationMethodInitializeName); | |
367 } | |
368 void acceptConnection(String requestorUrl, Object services, Object exposedSe
rvices, String resolvedUrl) { | |
369 if (!_proxyImpl.isBound) { | |
370 _proxyImpl.proxyError("The Proxy is closed."); | |
371 return; | |
372 } | |
373 var params = new _ApplicationAcceptConnectionParams(); | |
374 params.requestorUrl = requestorUrl; | |
375 params.services = services; | |
376 params.exposedServices = exposedServices; | |
377 params.resolvedUrl = resolvedUrl; | |
378 _proxyImpl.sendMessage(params, _applicationMethodAcceptConnectionName); | |
379 } | |
380 void requestQuit() { | |
381 if (!_proxyImpl.isBound) { | |
382 _proxyImpl.proxyError("The Proxy is closed."); | |
383 return; | |
384 } | |
385 var params = new _ApplicationRequestQuitParams(); | |
386 _proxyImpl.sendMessage(params, _applicationMethodRequestQuitName); | |
387 } | |
388 } | |
389 | 360 |
| 361 ApplicationProxy.unbound() |
| 362 : super(new _ApplicationProxyControl.unbound()); |
390 | 363 |
391 class ApplicationProxy implements bindings.ProxyBase { | 364 static ApplicationProxy newFromEndpoint( |
392 final bindings.Proxy impl; | 365 core.MojoMessagePipeEndpoint endpoint) { |
393 Application ptr; | 366 assert(endpoint.setDescription("For ApplicationProxy")); |
394 | 367 return new ApplicationProxy.fromEndpoint(endpoint); |
395 ApplicationProxy(_ApplicationProxyImpl proxyImpl) : | |
396 impl = proxyImpl, | |
397 ptr = new _ApplicationProxyCalls(proxyImpl); | |
398 | |
399 ApplicationProxy.fromEndpoint( | |
400 core.MojoMessagePipeEndpoint endpoint) : | |
401 impl = new _ApplicationProxyImpl.fromEndpoint(endpoint) { | |
402 ptr = new _ApplicationProxyCalls(impl); | |
403 } | |
404 | |
405 ApplicationProxy.fromHandle(core.MojoHandle handle) : | |
406 impl = new _ApplicationProxyImpl.fromHandle(handle) { | |
407 ptr = new _ApplicationProxyCalls(impl); | |
408 } | |
409 | |
410 ApplicationProxy.unbound() : | |
411 impl = new _ApplicationProxyImpl.unbound() { | |
412 ptr = new _ApplicationProxyCalls(impl); | |
413 } | 368 } |
414 | 369 |
415 factory ApplicationProxy.connectToService( | 370 factory ApplicationProxy.connectToService( |
416 bindings.ServiceConnector s, String url, [String serviceName]) { | 371 bindings.ServiceConnector s, String url, [String serviceName]) { |
417 ApplicationProxy p = new ApplicationProxy.unbound(); | 372 ApplicationProxy p = new ApplicationProxy.unbound(); |
418 s.connectToService(url, p, serviceName); | 373 s.connectToService(url, p, serviceName); |
419 return p; | 374 return p; |
420 } | 375 } |
421 | 376 |
422 static ApplicationProxy newFromEndpoint( | 377 |
423 core.MojoMessagePipeEndpoint endpoint) { | 378 void initialize(Object shell, List<String> args, String url) { |
424 assert(endpoint.setDescription("For ApplicationProxy")); | 379 if (!ctrl.isBound) { |
425 return new ApplicationProxy.fromEndpoint(endpoint); | 380 ctrl.proxyError("The Proxy is closed."); |
| 381 return; |
| 382 } |
| 383 var params = new _ApplicationInitializeParams(); |
| 384 params.shell = shell; |
| 385 params.args = args; |
| 386 params.url = url; |
| 387 ctrl.sendMessage(params, |
| 388 _applicationMethodInitializeName); |
426 } | 389 } |
427 | 390 void acceptConnection(String requestorUrl, Object services, Object exposedServ
ices, String resolvedUrl) { |
428 String get serviceName => Application.serviceName; | 391 if (!ctrl.isBound) { |
429 | 392 ctrl.proxyError("The Proxy is closed."); |
430 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 393 return; |
431 | 394 } |
432 Future responseOrError(Future f) => impl.responseOrError(f); | 395 var params = new _ApplicationAcceptConnectionParams(); |
433 | 396 params.requestorUrl = requestorUrl; |
434 Future get errorFuture => impl.errorFuture; | 397 params.services = services; |
435 | 398 params.exposedServices = exposedServices; |
436 int get version => impl.version; | 399 params.resolvedUrl = resolvedUrl; |
437 | 400 ctrl.sendMessage(params, |
438 Future<int> queryVersion() => impl.queryVersion(); | 401 _applicationMethodAcceptConnectionName); |
439 | |
440 void requireVersion(int requiredVersion) { | |
441 impl.requireVersion(requiredVersion); | |
442 } | 402 } |
443 | 403 void requestQuit() { |
444 String toString() { | 404 if (!ctrl.isBound) { |
445 return "ApplicationProxy($impl)"; | 405 ctrl.proxyError("The Proxy is closed."); |
| 406 return; |
| 407 } |
| 408 var params = new _ApplicationRequestQuitParams(); |
| 409 ctrl.sendMessage(params, |
| 410 _applicationMethodRequestQuitName); |
446 } | 411 } |
447 } | 412 } |
448 | 413 |
449 | 414 |
450 class ApplicationStub extends bindings.Stub { | 415 class ApplicationStub extends bindings.Stub { |
451 Application _impl; | 416 Application _impl; |
452 | 417 |
453 ApplicationStub.fromEndpoint( | 418 ApplicationStub.fromEndpoint( |
454 core.MojoMessagePipeEndpoint endpoint, [Application impl]) | 419 core.MojoMessagePipeEndpoint endpoint, [Application impl]) |
455 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 420 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 static service_describer.ServiceDescription get serviceDescription { | 497 static service_describer.ServiceDescription get serviceDescription { |
533 if (_cachedServiceDescription == null) { | 498 if (_cachedServiceDescription == null) { |
534 _cachedServiceDescription = new _ApplicationServiceDescription(); | 499 _cachedServiceDescription = new _ApplicationServiceDescription(); |
535 } | 500 } |
536 return _cachedServiceDescription; | 501 return _cachedServiceDescription; |
537 } | 502 } |
538 } | 503 } |
539 | 504 |
540 | 505 |
541 | 506 |
OLD | NEW |