Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 """Python implementation of the Application interface.""" | 5 """Python implementation of the Application interface.""" |
| 6 | 6 |
| 7 import logging | |
| 8 | |
| 7 import application_mojom | 9 import application_mojom |
| 8 import service_provider_mojom | 10 import service_provider_mojom |
| 9 import shell_mojom | 11 import shell_mojom |
| 10 from mojo_application.service_provider_impl import ServiceProviderImpl | 12 from mojo_application.service_provider_impl import ServiceProviderImpl |
| 11 | 13 |
| 12 import mojo_system | 14 import mojo_system |
| 13 | 15 |
| 14 class ApplicationImpl(application_mojom.Application): | 16 class ApplicationImpl(application_mojom.Application): |
| 15 def __init__(self, delegate, app_request_handle): | 17 def __init__(self, delegate, app_request_handle): |
| 16 self.shell = None | 18 self.shell = None |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 39 def removeServiceProvider(): | 41 def removeServiceProvider(): |
| 40 self._providers.remove(service_provider) | 42 self._providers.remove(service_provider) |
| 41 service_provider.manager.AddOnErrorCallback(removeServiceProvider) | 43 service_provider.manager.AddOnErrorCallback(removeServiceProvider) |
| 42 | 44 |
| 43 def ConnectToService(self, application_url, service_class): | 45 def ConnectToService(self, application_url, service_class): |
| 44 """ | 46 """ |
| 45 Helper method to connect to a service. |application_url| is the URL of the | 47 Helper method to connect to a service. |application_url| is the URL of the |
| 46 application to be connected to, and |service_class| is the class of the | 48 application to be connected to, and |service_class| is the class of the |
| 47 service to be connected to. Returns a proxy to the service. | 49 service to be connected to. Returns a proxy to the service. |
| 48 """ | 50 """ |
| 51 if not service_class.service_name: | |
|
qsr
2015/12/10 15:13:53
I think service_name should be in the manager clas
| |
| 52 logging.error("No ServiceName specified for %s." % service_class.__name__) | |
| 53 return | |
| 49 application_proxy, request = ( | 54 application_proxy, request = ( |
| 50 service_provider_mojom.ServiceProvider.manager.NewRequest()) | 55 service_provider_mojom.ServiceProvider.manager.NewRequest()) |
| 51 self.shell.ConnectToApplication(application_url, request, None) | 56 self.shell.ConnectToApplication(application_url, request, None) |
| 52 | 57 |
| 53 service_proxy, request = service_class.manager.NewRequest() | 58 service_proxy, request = service_class.manager.NewRequest() |
| 54 application_proxy.ConnectToService(service_class.manager.name, | 59 application_proxy.ConnectToService(service_class.service_name, |
| 55 request.PassMessagePipe()) | 60 request.PassMessagePipe()) |
| 56 | 61 |
| 57 return service_proxy | 62 return service_proxy |
| OLD | NEW |