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

Unified Diff: third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java

Issue 1101303002: Update mojo sdk to rev e7270700d671fa8e458b4d8c9e47f7bcfb65da0b (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Actualy provide a default TaskTracker impl Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java
diff --git a/third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java b/third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java
index c3b26a205dd6e13580ec1824ea782b8aee4c0583..4c828db04c22ed67fc34d513bc494616cb198b2d 100644
--- a/third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java
+++ b/third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java
@@ -30,84 +30,129 @@ public interface Interface extends ConnectionErrorHandler, Closeable {
* {@link MessageReceiverWithResponder}, along with the response callback if needed.
*/
public interface Proxy extends Interface {
-
/**
- * Set the {@link ConnectionErrorHandler} that will be notified of errors.
+ * Class allowing to interact with the proxy itself.
*/
- public void setErrorHandler(ConnectionErrorHandler errorHandler);
+ public interface Handler extends Closeable {
+ /**
+ * Sets the {@link ConnectionErrorHandler} that will be notified of errors.
+ */
+ public void setErrorHandler(ConnectionErrorHandler errorHandler);
+ }
+ /**
+ * Returns the {@link Handler} object allowing to interact with the proxy itself.
+ */
+ public Handler getProxyHandler();
}
/**
* Base implementation of {@link Proxy}.
*/
abstract class AbstractProxy implements Proxy {
-
/**
- * The {@link Core} implementation to use.
+ * Implementation of {@link Handler}.
*/
- private final Core mCore;
+ protected static class HandlerImpl implements Proxy.Handler, ConnectionErrorHandler {
+ /**
+ * The {@link Core} implementation to use.
+ */
+ private final Core mCore;
+
+ /**
+ * The {@link MessageReceiverWithResponder} that will receive a serialized message for
+ * each method call.
+ */
+ private final MessageReceiverWithResponder mMessageReceiver;
+
+ /**
+ * The {@link ConnectionErrorHandler} that will be notified of errors.
+ */
+ private ConnectionErrorHandler mErrorHandler = null;
+
+ /**
+ * Constructor.
+ *
+ * @param core the Core implementation used to create pipes and access the async waiter.
+ * @param messageReceiver the message receiver to send message to.
+ */
+ protected HandlerImpl(Core core, MessageReceiverWithResponder messageReceiver) {
+ this.mCore = core;
+ this.mMessageReceiver = messageReceiver;
+ }
- /**
- * The {@link MessageReceiverWithResponder} that will receive a serialized message for each
- * method call.
- */
- private final MessageReceiverWithResponder mMessageReceiver;
+ /**
+ * Returns the message receiver to send message to.
+ */
+ public MessageReceiverWithResponder getMessageReceiver() {
+ return mMessageReceiver;
+ }
- /**
- * The {@link ConnectionErrorHandler} that will be notified of errors.
- */
- private ConnectionErrorHandler mErrorHandler = null;
+ /**
+ * Returns the Core implementation.
+ */
+ public Core getCore() {
+ return mCore;
+ }
- /**
- * Constructor.
- *
- * @param core the Core implementation used to create pipes and access the async waiter.
- * @param messageReceiver the message receiver to send message to.
- */
- protected AbstractProxy(Core core, MessageReceiverWithResponder messageReceiver) {
- this.mCore = core;
- this.mMessageReceiver = messageReceiver;
- }
+ /**
+ * Sets the {@link ConnectionErrorHandler} that will be notified of errors.
+ */
+ @Override
+ public void setErrorHandler(ConnectionErrorHandler errorHandler) {
+ this.mErrorHandler = errorHandler;
+ }
- /**
- * Returns the message receiver to send message to.
- */
- protected MessageReceiverWithResponder getMessageReceiver() {
- return mMessageReceiver;
+ /**
+ * @see ConnectionErrorHandler#onConnectionError(MojoException)
+ */
+ @Override
+ public void onConnectionError(MojoException e) {
+ if (mErrorHandler != null) {
+ mErrorHandler.onConnectionError(e);
+ }
+ }
+
+ /**
+ * @see Closeable#close()
+ */
+ @Override
+ public void close() {
+ mMessageReceiver.close();
+ }
}
/**
- * Returns the Core implementation.
+ * The handler associated with this proxy.
*/
- protected Core getCore() {
- return mCore;
+ private final HandlerImpl mHandler;
+
+ protected AbstractProxy(Core core, MessageReceiverWithResponder messageReceiver) {
+ mHandler = new HandlerImpl(core, messageReceiver);
}
/**
- * @see Proxy#setErrorHandler(ConnectionErrorHandler)
+ * @see Interface#close()
*/
@Override
- public void setErrorHandler(ConnectionErrorHandler errorHandler) {
- this.mErrorHandler = errorHandler;
+ public void close() {
+ mHandler.close();
}
/**
- * @see ConnectionErrorHandler#onConnectionError(MojoException)
+ * @see Proxy#getProxyHandler()
*/
@Override
- public void onConnectionError(MojoException e) {
- if (mErrorHandler != null) {
- mErrorHandler.onConnectionError(e);
- }
+ public HandlerImpl getProxyHandler() {
+ return mHandler;
}
/**
- * @see Closeable#close()
+ * @see ConnectionErrorHandler#onConnectionError(org.chromium.mojo.system.MojoException)
*/
@Override
- public void close() {
- mMessageReceiver.close();
+ public void onConnectionError(MojoException e) {
+ mHandler.onConnectionError(e);
}
}

Powered by Google App Engine
This is Rietveld 408576698