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

Side by Side Diff: mojo/public/java/bindings/src/org/chromium/mojo/bindings/Message.java

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.mojo.bindings;
6
7 import org.chromium.mojo.system.Handle;
8 import org.chromium.mojo.system.MessagePipeHandle;
9
10 import java.nio.ByteBuffer;
11 import java.util.List;
12
13 /**
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 ServiceMessage}.
16 */
17 public class Message {
18
19 /**
20 * The data of the message.
21 */
22 private final ByteBuffer mBuffer;
23
24 /**
25 * The handles of the message.
26 */
27 private final List<? extends Handle> mHandle;
28
29 /**
30 * This message interpreted as a message for a mojo service with an appropri ate header.
31 */
32 private ServiceMessage mWithHeader = null;
33
34 /**
35 * Constructor.
36 *
37 * @param buffer The buffer containing the bytes to send. This must be a dir ect buffer.
38 * @param handles The list of handles to send.
39 */
40 public Message(ByteBuffer buffer, List<? extends Handle> handles) {
41 assert buffer.isDirect();
42 mBuffer = buffer;
43 mHandle = handles;
44 }
45
46 /**
47 * The data of the message.
48 */
49 public ByteBuffer getData() {
50 return mBuffer;
51 }
52
53 /**
54 * The handles of the message.
55 */
56 public List<? extends Handle> getHandles() {
57 return mHandle;
58 }
59
60 /**
61 * Returns the message interpreted as a message for a mojo service.
62 */
63 public ServiceMessage asServiceMessage() {
64 if (mWithHeader == null) {
65 mWithHeader = new ServiceMessage(this);
66 }
67 return mWithHeader;
68 }
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698