Commit 5a02c9d2 authored by qsr's avatar qsr Committed by Commit bot

mojo: Java bindings: Add name to the manager.

The name is used to retrieve a service from a ServiceProvider.

R=ppi@chromium.org

Review URL: https://codereview.chromium.org/540913003

Cr-Commit-Position: refs/heads/master@{#293499}
parent a1ee8d91
...@@ -276,6 +276,11 @@ public class InterfacesTest extends MojoTestCase { ...@@ -276,6 +276,11 @@ public class InterfacesTest extends MojoTestCase {
assertEquals(NAME, callback.getName()); assertEquals(NAME, callback.getName());
} }
@SmallTest
public void testName() {
assertEquals("sample::NamedObject", NamedObject.MANAGER.getName());
}
@SmallTest @SmallTest
public void testProxyAndStub() { public void testProxyAndStub() {
MockNamedObjectImpl impl = new MockNamedObjectImpl(); MockNamedObjectImpl impl = new MockNamedObjectImpl();
......
...@@ -173,6 +173,12 @@ public interface Interface extends ConnectionErrorHandler, Closeable { ...@@ -173,6 +173,12 @@ public interface Interface extends ConnectionErrorHandler, Closeable {
*/ */
abstract class Manager<I extends Interface, P extends Proxy> { abstract class Manager<I extends Interface, P extends Proxy> {
/**
* Returns the name of the interface. This is an opaque (but human readable) identifier used
* by the service provider to identify services.
*/
public abstract String getName();
/** /**
* Binds the given implementation to the handle. * Binds the given implementation to the handle.
*/ */
......
...@@ -68,6 +68,10 @@ org.chromium.mojo.bindings.MessageHeader.MESSAGE_IS_RESPONSE_FLAG ...@@ -68,6 +68,10 @@ org.chromium.mojo.bindings.MessageHeader.MESSAGE_IS_RESPONSE_FLAG
public static final {{manager_class(interface, client, True)}} MANAGER = public static final {{manager_class(interface, client, True)}} MANAGER =
new {{manager_class(interface, client, True)}}() { new {{manager_class(interface, client, True)}}() {
public String getName() {
return "{{namespace|replace(".","::")}}::{{interface.name}}";
}
public Proxy buildProxy(org.chromium.mojo.system.Core core, public Proxy buildProxy(org.chromium.mojo.system.Core core,
org.chromium.mojo.bindings.MessageReceiverWithResponder messageReceiver) { org.chromium.mojo.bindings.MessageReceiverWithResponder messageReceiver) {
return new Proxy(core, messageReceiver); return new Proxy(core, messageReceiver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment