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

Unified Diff: mojo/public/python/mojo/bindings/reflection.py

Issue 703273002: Update mojo sdk to rev 04a510fb37db10642e156957f9b2c11c2f6442ac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix content/child -> mojo/common linking Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/python/mojo/bindings/messaging.py ('k') | mojo/public/sky/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/python/mojo/bindings/reflection.py
diff --git a/mojo/public/python/mojo/bindings/reflection.py b/mojo/public/python/mojo/bindings/reflection.py
index 49c911caa4bd5502822417608a50eb727fb741c1..3193f6e37d89a745b0da96027291916d78d29a21 100644
--- a/mojo/public/python/mojo/bindings/reflection.py
+++ b/mojo/public/python/mojo/bindings/reflection.py
@@ -181,9 +181,9 @@ class MojoInterfaceType(type):
methods = [_MethodDescriptor(x) for x in descriptor.get('methods', [])]
for method in methods:
dictionary[method.name] = _NotImplemented
- client_class = descriptor.get('client', None)
+ client_class_getter = descriptor.get('client', None)
- interface_manager = InterfaceManager(name, methods, client_class)
+ interface_manager = InterfaceManager(name, methods, client_class_getter)
dictionary.update({
'client': None,
'manager': None,
@@ -207,6 +207,31 @@ class MojoInterfaceType(type):
raise AttributeError, 'can\'t delete attribute'
+class InterfaceProxy(object):
+ """
+ A proxy allows to access a remote interface through a message pipe.
+ """
+ pass
+
+
+class InterfaceRequest(object):
+ """
+ An interface request allows to send a request for an interface to a remote
+ object and start using it immediately.
+ """
+
+ def __init__(self, handle):
+ self._handle = handle
+
+ def IsPending(self):
+ return self._handle.IsValid()
+
+ def PassMessagePipe(self):
+ result = self._handle
+ self._handle = None
+ return result
+
+
class InterfaceManager(object):
"""
Manager for an interface class. The manager contains the operation that allows
@@ -214,17 +239,24 @@ class InterfaceManager(object):
over a pipe.
"""
- def __init__(self, name, methods, client_class):
+ def __init__(self, name, methods, client_class_getter):
self.name = name
self.methods = methods
- if client_class:
- self.client_manager = client_class.manager
- else:
- self.client_manager = None
self.interface_class = None
+ self._client_class_getter = client_class_getter
+ self._client_manager = None
+ self._client_manager_computed = False
self._proxy_class = None
self._stub_class = None
+ @property
+ def client_manager(self):
+ if not self._client_manager_computed:
+ self._client_manager_computed = True
+ if self._client_class_getter:
+ self._client_manager = self._client_class_getter().manager
+ return self._client_manager
+
def Proxy(self, handle):
router = messaging.Router(handle)
error_handler = _ProxyErrorHandler()
@@ -267,7 +299,7 @@ class InterfaceManager(object):
for method in self.methods:
dictionary[method.name] = _ProxyMethodCall(method)
self._proxy_class = type('%sProxy' % self.name,
- (self.interface_class,),
+ (self.interface_class, InterfaceProxy),
dictionary)
proxy = self._proxy_class(router, error_handler)
@@ -301,6 +333,9 @@ class InstanceManager(object):
def Close(self):
self.router.Close()
+ def PassMessagePipe(self):
+ return self.router.PassMessagePipe()
+
class _MethodDescriptor(object):
def __init__(self, descriptor):
« no previous file with comments | « mojo/public/python/mojo/bindings/messaging.py ('k') | mojo/public/sky/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698