OLD | NEW |
| (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 ServiceProvider interface.""" | |
6 | |
7 import logging | |
8 | |
9 import service_provider_mojom | |
10 | |
11 class ServiceProviderImpl(service_provider_mojom.ServiceProvider): | |
12 def __init__(self, provider): | |
13 self._provider = provider | |
14 self._name_to_service_connector = {} | |
15 | |
16 def AddService(self, service_class, service_name=None): | |
17 if service_name is None: | |
18 service_name = service_class.manager.service_name | |
19 if service_name is None: | |
20 logging.error("No ServiceName specified for %s." % service_class.__name__) | |
21 return | |
22 self._name_to_service_connector[service_name] = service_class | |
23 | |
24 def ConnectToService(self, interface_name, pipe): | |
25 if interface_name in self._name_to_service_connector: | |
26 service = self._name_to_service_connector[interface_name] | |
27 service.manager.Bind(service(), pipe) | |
28 else: | |
29 logging.error("Unable to find service " + interface_name) | |
OLD | NEW |