| 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 """The metaclasses used by the mojo python bindings.""" | 5 """The metaclasses used by the mojo python bindings.""" |
| 6 | 6 |
| 7 import itertools | 7 import itertools |
| 8 import logging | 8 import logging |
| 9 import sys | 9 import sys |
| 10 | 10 |
| 11 # pylint: disable=F0401 | 11 # pylint: disable=F0401 |
| 12 import mojo_bindings.messaging as messaging | 12 import mojo_bindings.messaging as messaging |
| 13 import mojo_bindings.promise as promise | 13 import mojo_bindings.promise as promise |
| 14 import mojo_bindings.serialization as serialization | 14 import mojo_bindings.serialization as serialization |
| 15 import mojo_system |
| 15 | 16 |
| 16 | 17 |
| 17 class MojoEnumType(type): | 18 class MojoEnumType(type): |
| 18 """Meta class for enumerations. | 19 """Meta class for enumerations. |
| 19 | 20 |
| 20 Usage: | 21 Usage: |
| 21 class MyEnum(object): | 22 class MyEnum(object): |
| 22 __metaclass__ = MojoEnumType | 23 __metaclass__ = MojoEnumType |
| 23 VALUES = [ | 24 VALUES = [ |
| 24 ('A', 0), | 25 ('A', 0), |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 def Cleanup(_): | 267 def Cleanup(_): |
| 267 retainer.release() | 268 retainer.release() |
| 268 error_handler.AddCallback(Cleanup) | 269 error_handler.AddCallback(Cleanup) |
| 269 | 270 |
| 270 # Give an instance manager to the implementation to allow it to close | 271 # Give an instance manager to the implementation to allow it to close |
| 271 # the connection. | 272 # the connection. |
| 272 impl.manager = InstanceManager(router, error_handler) | 273 impl.manager = InstanceManager(router, error_handler) |
| 273 | 274 |
| 274 router.Start() | 275 router.Start() |
| 275 | 276 |
| 277 def NewRequest(self): |
| 278 pipe = mojo_system.MessagePipe() |
| 279 return (self.Proxy(pipe.handle0), InterfaceRequest(pipe.handle1)) |
| 280 |
| 276 def _InternalProxy(self, router, error_handler): | 281 def _InternalProxy(self, router, error_handler): |
| 277 if error_handler is None: | 282 if error_handler is None: |
| 278 error_handler = _ProxyErrorHandler() | 283 error_handler = _ProxyErrorHandler() |
| 279 | 284 |
| 280 if not self._proxy_class: | 285 if not self._proxy_class: |
| 281 dictionary = { | 286 dictionary = { |
| 282 '__module__': __name__, | 287 '__module__': __name__, |
| 283 '__init__': _ProxyInit, | 288 '__init__': _ProxyInit, |
| 284 } | 289 } |
| 285 for method in self.methods: | 290 for method in self.methods: |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 logging.warning( | 556 logging.warning( |
| 552 'Error occured in accept method. Connection will be closed.') | 557 'Error occured in accept method. Connection will be closed.') |
| 553 if self.impl.manager: | 558 if self.impl.manager: |
| 554 self.impl.manager.Close() | 559 self.impl.manager.Close() |
| 555 return False | 560 return False |
| 556 return Accept | 561 return Accept |
| 557 | 562 |
| 558 | 563 |
| 559 def _NotImplemented(*_1, **_2): | 564 def _NotImplemented(*_1, **_2): |
| 560 raise NotImplementedError() | 565 raise NotImplementedError() |
| OLD | NEW |