Chromium Code Reviews| Index: mojo/public/java/bindings/src/org/chromium/mojo/bindings/Message.java |
| diff --git a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Message.java b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Message.java |
| index 4c302d9a0c82ff0b8fe7d9b22317d946d7358c85..1b3097a1e7fd13a69d80aa5e55e00198c2d80b23 100644 |
| --- a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Message.java |
| +++ b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Message.java |
| @@ -12,24 +12,58 @@ import java.util.List; |
| /** |
| * A raw message to be sent/received from a {@link MessagePipeHandle}. Note that this can contain |
| - * any data, not necessarily a Mojo message with a proper header. See also {@link MessageWithHeader} |
| - * and {@link SimpleMessage}. |
| + * any data, not necessarily a Mojo message with a proper header. See also {@link ServiceMessage}. |
| */ |
| -public interface Message { |
| +public class Message { |
| /** |
| - * The data part of the message. |
| + * The data of the message. |
| */ |
| - public ByteBuffer getData(); |
| + private final ByteBuffer mBuffer; |
| /** |
| - * The handles part of the message. |
| + * The handles of the message. |
| */ |
| - public List<? extends Handle> getHandles(); |
| + private final List<? extends Handle> mHandle; |
| /** |
| - * Returns the message considered as a message with a header. |
| + * This message interpreted with headers. |
|
ppi
2014/09/03 11:44:08
-> This message interpreted as a message for a moj
qsr
2014/09/03 14:11:29
Done.
|
| */ |
| - public MessageWithHeader asMojoMessage(); |
| + private ServiceMessage mWithHeader = null; |
| + /** |
| + * Constructor. |
| + * |
| + * @param buffer The buffer containing the bytes to send. This must be a direct buffer. |
| + * @param handles The list of handles to send. |
| + */ |
| + public Message(ByteBuffer buffer, List<? extends Handle> handles) { |
| + assert buffer.isDirect(); |
| + mBuffer = buffer; |
| + mHandle = handles; |
| + } |
| + |
| + /** |
| + * The data of the message. |
| + */ |
| + public ByteBuffer getData() { |
| + return mBuffer; |
| + } |
| + |
| + /** |
| + * The handles of the message. |
| + */ |
| + public List<? extends Handle> getHandles() { |
| + return mHandle; |
| + } |
| + |
| + /** |
| + * Returns the message considered as a message for a mojo service. |
|
ppi
2014/09/03 11:44:08
s/considered/interpreted/
qsr
2014/09/03 14:11:29
Done.
|
| + */ |
| + public ServiceMessage asServiceMessage() { |
| + if (mWithHeader == null) { |
| + mWithHeader = new ServiceMessage(this); |
| + } |
| + return mWithHeader; |
| + } |
| } |