OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.mojo.bindings; | 5 package org.chromium.mojo.bindings; |
6 | 6 |
7 import org.chromium.mojo.system.Handle; | 7 import org.chromium.mojo.system.Handle; |
8 import org.chromium.mojo.system.MessagePipeHandle; | 8 import org.chromium.mojo.system.MessagePipeHandle; |
9 | 9 |
10 import java.nio.ByteBuffer; | 10 import java.nio.ByteBuffer; |
11 import java.util.List; | 11 import java.util.List; |
12 | 12 |
13 /** | 13 /** |
14 * A raw message to be sent/received from a {@link MessagePipeHandle}. | 14 * A raw message to be sent/received from a {@link MessagePipeHandle}. Note that
this can contain |
| 15 * any data, not necessarily a Mojo message with a proper header. See also {@lin
k MessageWithHeader} |
| 16 * and {@link SimpleMessage}. |
15 */ | 17 */ |
16 public final class Message { | 18 public interface Message { |
17 | 19 |
18 /** | 20 /** |
19 * The data of the message. | 21 * The data part of the message. |
20 */ | 22 */ |
21 public final ByteBuffer buffer; | 23 public ByteBuffer getData(); |
22 | 24 |
23 /** | 25 /** |
24 * The handles of the message. | 26 * The handles part of the message. |
25 */ | 27 */ |
26 public final List<? extends Handle> handles; | 28 public List<? extends Handle> getHandles(); |
27 | 29 |
28 /** | 30 /** |
29 * Constructor. | 31 * Returns the message considered as a message with a header. |
30 * | |
31 * @param buffer The buffer containing the bytes to send. This must be a dir
ect buffer. | |
32 * @param handles The list of handles to send. | |
33 */ | 32 */ |
34 public Message(ByteBuffer buffer, List<? extends Handle> handles) { | 33 public MessageWithHeader asMojoMessage(); |
35 assert buffer.isDirect(); | 34 |
36 this.buffer = buffer; | |
37 this.handles = handles; | |
38 } | |
39 } | 35 } |
OLD | NEW |