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

Unified Diff: mojo/bindings/java/src/org/chromium/mojo/bindings/Message.java

Issue 371603003: Adding a router class to handle messages that expect responses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix findbugs issue Created 6 years, 5 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: mojo/bindings/java/src/org/chromium/mojo/bindings/Message.java
diff --git a/mojo/bindings/java/src/org/chromium/mojo/bindings/Message.java b/mojo/bindings/java/src/org/chromium/mojo/bindings/Message.java
index ee687070127fff4b5f6b896de6c61c493a6584d4..07bd2bd2e4697516242c73ef017cb10fbe4a198b 100644
--- a/mojo/bindings/java/src/org/chromium/mojo/bindings/Message.java
+++ b/mojo/bindings/java/src/org/chromium/mojo/bindings/Message.java
@@ -6,8 +6,6 @@ package org.chromium.mojo.bindings;
import org.chromium.mojo.system.Handle;
import org.chromium.mojo.system.MessagePipeHandle;
-import org.chromium.mojo.system.MessagePipeHandle.ReadMessageResult;
-import org.chromium.mojo.system.MojoResult;
import java.nio.ByteBuffer;
import java.util.List;
@@ -38,26 +36,4 @@ public final class Message {
this.buffer = buffer;
this.handles = handles;
}
-
- /**
- * Read a message, and pass it to the given |MessageReceiver| if not null. If the
- * |MessageReceiver| is null, the message is lost.
- *
- * @param receiver The {@link MessageReceiver} that will receive the read {@link Message}. Can
- * be <code>null</code>, in which case the message is discarded.
- */
- public static int readAndDispatchMessage(MessagePipeHandle handle, MessageReceiver receiver) {
- // TODO(qsr) Allow usage of a pool of pre-allocated buffer for performance.
- ReadMessageResult result = handle.readMessage(null, 0, MessagePipeHandle.ReadFlags.NONE);
- if (result.getMojoResult() != MojoResult.RESOURCE_EXHAUSTED) {
- return result.getMojoResult();
- }
- ByteBuffer buffer = ByteBuffer.allocateDirect(result.getMessageSize());
- result = handle.readMessage(buffer, result.getHandlesCount(),
- MessagePipeHandle.ReadFlags.NONE);
- if (receiver != null && result.getMojoResult() == MojoResult.OK) {
- receiver.accept(new Message(buffer, result.getHandles()));
- }
- return result.getMojoResult();
- }
}

Powered by Google App Engine
This is Rietveld 408576698