| 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 """Example python application implementing the Echo service.""" | 5 """Example python application implementing the Echo service.""" |
| 6 | 6 |
| 7 import logging | 7 import logging |
| 8 | 8 |
| 9 import application_mojom | 9 import application_mojom |
| 10 import example_service_mojom | 10 import example_service_mojom |
| 11 import service_provider_mojom | 11 import service_provider_mojom |
| 12 import shell_mojom | 12 import shell_mojom |
| 13 | 13 |
| 14 import mojo_system | 14 import mojo_system |
| 15 | 15 |
| 16 class ApplicationImpl(application_mojom.Application): | 16 class ApplicationImpl(application_mojom.Application): |
| 17 def __init__(self, app_request_handle): | 17 def __init__(self, app_request_handle): |
| 18 self._providers = [] | 18 self._providers = [] |
| 19 application_mojom.Application.manager.Bind(self, app_request_handle) | 19 application_mojom.Application.manager.Bind(self, app_request_handle) |
| 20 | 20 |
| 21 def Initialize(self, shell, args): | 21 def Initialize(self, shell, url, args): |
| 22 self.shell = shell | 22 self.shell = shell |
| 23 | 23 |
| 24 def AcceptConnection(self, requestor_url, services, exposed_services): | 24 def AcceptConnection(self, requestor_url, services, exposed_services): |
| 25 # We keep a reference to ServiceProviderImpl to ensure neither it nor | 25 # We keep a reference to ServiceProviderImpl to ensure neither it nor |
| 26 # provider gets garbage collected. | 26 # provider gets garbage collected. |
| 27 service_provider = ServiceProviderImpl(services) | 27 service_provider = ServiceProviderImpl(services) |
| 28 service_provider.AddService(ExampleServiceImpl) | 28 service_provider.AddService(ExampleServiceImpl) |
| 29 services.Bind(service_provider) | 29 services.Bind(service_provider) |
| 30 self._providers.append(service_provider) | 30 self._providers.append(service_provider) |
| 31 | 31 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 52 | 52 |
| 53 | 53 |
| 54 def MojoMain(app_request_handle): | 54 def MojoMain(app_request_handle): |
| 55 """MojoMain is the entry point for a python Mojo module.""" | 55 """MojoMain is the entry point for a python Mojo module.""" |
| 56 loop = mojo_system.RunLoop() | 56 loop = mojo_system.RunLoop() |
| 57 | 57 |
| 58 application = ApplicationImpl(mojo_system.Handle(app_request_handle)) | 58 application = ApplicationImpl(mojo_system.Handle(app_request_handle)) |
| 59 application.manager.AddOnErrorCallback(loop.Quit) | 59 application.manager.AddOnErrorCallback(loop.Quit) |
| 60 | 60 |
| 61 loop.Run() | 61 loop.Run() |
| OLD | NEW |