Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: mojo/public/python/mojo_application/application_impl.py

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 """Python implementation of the Application interface."""
6
7 import logging
8
9 import application_mojom
10 import service_provider_mojom
11 import shell_mojom
12 from mojo_application.service_provider_impl import ServiceProviderImpl
13
14 import mojo_system
15
16 class ApplicationImpl(application_mojom.Application):
17 def __init__(self, delegate, app_request_handle):
18 self.shell = None
19 self.url = None
20 self.args = None
21 self._delegate = delegate
22 self._providers = []
23 application_mojom.Application.manager.Bind(self, app_request_handle)
24
25 def Initialize(self, shell, url, args):
26 self.shell = shell
27 self.url = url
28 self.args = args
29 self._delegate.Initialize(shell, self)
30
31 def AcceptConnection(self, requestor_url, resolved_url, services):
32 service_provider = ServiceProviderImpl(services)
33 if self._delegate.OnAcceptConnection(requestor_url, resolved_url,
34 service_provider):
35 # We keep a reference to ServiceProviderImpl to ensure neither it nor
36 # |services| gets garbage collected.
37 services.Bind(service_provider)
38 self._providers.append(service_provider)
39
40 def removeServiceProvider():
41 self._providers.remove(service_provider)
42 service_provider.manager.AddOnErrorCallback(removeServiceProvider)
43
44 def ConnectToService(self, application_url, service_class):
45 """
46 Helper method to connect to a service. |application_url| is the URL of the
47 application to be connected to, and |service_class| is the class of the
48 service to be connected to. Returns a proxy to the service.
49 """
50 if not service_class.manager.service_name:
51 logging.error("No ServiceName specified for %s." % service_class.__name__)
52 return
53 application_proxy, request = (
54 service_provider_mojom.ServiceProvider.manager.NewRequest())
55 self.shell.ConnectToApplication(application_url, request, None)
56
57 service_proxy, request = service_class.manager.NewRequest()
58 application_proxy.ConnectToService(service_class.manager.service_name,
59 request.PassMessagePipe())
60
61 return service_proxy
OLDNEW
« no previous file with comments | « mojo/public/python/mojo_application/application_delegate.py ('k') | mojo/public/python/mojo_application/application_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698