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

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

Issue 522353003: mojo: Run validation tests on java (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding conformance tests. Created 6 years, 3 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/public/java/bindings/src/org/chromium/mojo/bindings/SimpleMessage.java
diff --git a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/SimpleMessage.java b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/SimpleMessage.java
new file mode 100644
index 0000000000000000000000000000000000000000..93ae69605f8e9232a853cdcd4ad87ccb48bda3b3
--- /dev/null
+++ b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/SimpleMessage.java
@@ -0,0 +1,71 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.mojo.bindings;
+
+import org.chromium.mojo.system.Handle;
+import org.chromium.mojo.system.MessagePipeHandle;
+
+import java.nio.ByteBuffer;
+import java.util.List;
+
+/**
+ * A raw message to be sent/received from a {@link MessagePipeHandle}.
+ */
+public final class SimpleMessage implements Message {
+
+ /**
+ * The data of the message.
+ */
+ private final ByteBuffer mBuffer;
+
+ /**
+ * The handles of the message.
+ */
+ private final List<? extends Handle> mHandle;
+
+ /**
+ * This message interpreted with headers.
+ */
+ private MessageWithHeader 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 SimpleMessage(ByteBuffer buffer, List<? extends Handle> handles) {
+ assert buffer.isDirect();
+ mBuffer = buffer;
+ mHandle = handles;
+ }
+
+ /**
+ * @see Message#getData()
+ */
+ @Override
+ public ByteBuffer getData() {
+ return mBuffer;
+ }
+
+ /**
+ * @see Message#getHandles()
+ */
+ @Override
+ public List<? extends Handle> getHandles() {
+ return mHandle;
+ }
+
+ /**
+ * @see Message#asMojoMessage()
+ */
+ @Override
+ public MessageWithHeader asMojoMessage() {
+ if (mWithHeader == null) {
+ mWithHeader = new MessageWithHeader(this);
+ }
+ return mWithHeader;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698