| Index: mojo/public/java/org/chromium/mojo/system/DataPipe.java
|
| diff --git a/mojo/public/java/org/chromium/mojo/system/DataPipe.java b/mojo/public/java/org/chromium/mojo/system/DataPipe.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..00b8c7d1d8d13a31bf8664547e4e7ea861c849bb
|
| --- /dev/null
|
| +++ b/mojo/public/java/org/chromium/mojo/system/DataPipe.java
|
| @@ -0,0 +1,209 @@
|
| +// 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.system;
|
| +
|
| +import java.nio.ByteBuffer;
|
| +
|
| +/**
|
| + * TODO(qsr): Insert description here.
|
| + */
|
| +public interface DataPipe {
|
| +
|
| + /**
|
| + * TODO(qsr): Insert description here.
|
| + */
|
| + public static class CreateFlags extends Flags<CreateFlags> {
|
| + private static final int FLAG_NONE = 0;
|
| + private static final int FLAG_MAY_DISCARD = 1 << 0;
|
| +
|
| + /**
|
| + * Dedicated constructor.
|
| + *
|
| + * @param flags initial value of the flags.
|
| + */
|
| + protected CreateFlags(int flags) {
|
| + super(flags);
|
| + }
|
| +
|
| + /**
|
| + * Change the may-discard bit of this flag.
|
| + *
|
| + * @param mayDiscard the new value of the may-discard bit.
|
| + * @return this.
|
| + */
|
| + public CreateFlags mayDiscard(boolean mayDiscard) {
|
| + return setFlag(FLAG_MAY_DISCARD, mayDiscard);
|
| + }
|
| +
|
| + /**
|
| + * @return flags with no bit set.
|
| + */
|
| + public static CreateFlags none() {
|
| + return new CreateFlags(FLAG_NONE);
|
| + }
|
| +
|
| + }
|
| +
|
| + /**
|
| + * TODO(qsr): Insert description here.
|
| + */
|
| + public static class CreateOptions {
|
| + public CreateFlags flags;
|
| + public int elementNumBytes;
|
| + public int capacityNumBytes;
|
| + }
|
| +
|
| + /**
|
| + * Flag for the write operations on MessagePipeHandle .
|
| + */
|
| + public static class WriteFlags extends Flags<WriteFlags> {
|
| + private static final int FLAG_NONE = 0;
|
| + private static final int FLAG_ALL_OR_NONE = 1 << 0;
|
| +
|
| + /**
|
| + * Dedicated constructor.
|
| + *
|
| + * @param flags initial value of the flags.
|
| + */
|
| + private WriteFlags(int flags) {
|
| + super(flags);
|
| + }
|
| +
|
| + /**
|
| + * Change the all-or-none bit of those flags.
|
| + *
|
| + * @param allOrNone the new value of all-or-none bit.
|
| + * @return this.
|
| + */
|
| + public WriteFlags allOrNone(boolean allOrNone) {
|
| + return setFlag(FLAG_ALL_OR_NONE, allOrNone);
|
| + }
|
| +
|
| + /**
|
| + * @return a flag with no bit set.
|
| + */
|
| + public static WriteFlags none() {
|
| + return new WriteFlags(FLAG_NONE);
|
| + }
|
| + }
|
| +
|
| + /**
|
| + * Flag for the read operations on MessagePipeHandle.
|
| + */
|
| + public static class ReadFlags extends Flags<ReadFlags> {
|
| + private static final int FLAG_NONE = 0;
|
| + private static final int FLAG_ALL_OR_NONE = 1 << 0;
|
| + private static final int FLAG_DISCARD = 1 << 1;
|
| + private static final int FLAG_QUERY = 1 << 2;
|
| +
|
| + /**
|
| + * Dedicated constructor.
|
| + *
|
| + * @param flags initial value of the flag.
|
| + */
|
| + private ReadFlags(int flags) {
|
| + super(flags);
|
| + }
|
| +
|
| + /**
|
| + * Change the all-or-none bit of this flag.
|
| + *
|
| + * @param allOrNone the new value of the all-or-none bit.
|
| + * @return this.
|
| + */
|
| + public ReadFlags allOrNone(boolean allOrNone) {
|
| + return setFlag(FLAG_ALL_OR_NONE, allOrNone);
|
| + }
|
| +
|
| + /**
|
| + * Change the discard bit of this flag.
|
| + *
|
| + * @param discard the new value of the discard bit.
|
| + * @return this.
|
| + */
|
| + public ReadFlags discard(boolean discard) {
|
| + return setFlag(FLAG_DISCARD, discard);
|
| + }
|
| +
|
| + /**
|
| + * Change the query bit of this flag.
|
| + *
|
| + * @param query the new value of the query bit.
|
| + * @return this.
|
| + */
|
| + public ReadFlags query(boolean query) {
|
| + return setFlag(FLAG_QUERY, query);
|
| + }
|
| +
|
| + /**
|
| + * @return a flag with no bit set.
|
| + */
|
| + public static ReadFlags none() {
|
| + return new ReadFlags(FLAG_NONE);
|
| + }
|
| +
|
| + }
|
| +
|
| + /**
|
| + * TODO(qsr): Insert description here.
|
| + */
|
| + public static interface ProducerHandle extends Handle {
|
| + /**
|
| + * TODO(qsr):
|
| + *
|
| + * @param elements
|
| + * @param flags
|
| + * @return number of written bytes.
|
| + */
|
| + public int writeData(ByteBuffer elements, WriteFlags flags);
|
| +
|
| + /**
|
| + * TODO(qsr):
|
| + *
|
| + * @param numBytes
|
| + * @param flags
|
| + * @return TODO(qsr)
|
| + */
|
| + public java.nio.ByteBuffer beingWriteData(int numBytes, WriteFlags flags);
|
| +
|
| + /**
|
| + * TODO(qsr):
|
| + *
|
| + * @param numBytesWritten
|
| + */
|
| + public void endWriteData(int numBytesWritten);
|
| + }
|
| +
|
| + /**
|
| + * TODO(qsr): Insert description here.
|
| + */
|
| + public static interface ConsumerHandle extends Handle {
|
| + /**
|
| + * TODO(qsr):
|
| + *
|
| + * @param elements
|
| + * @param flags
|
| + * @return TODO(qsr):
|
| + */
|
| + public int readData(ByteBuffer elements, ReadFlags flags);
|
| +
|
| + /**
|
| + * TODO(qsr):
|
| + *
|
| + * @param numBytes
|
| + * @param flags
|
| + * @return TODO(qsr):
|
| + */
|
| + public java.nio.ByteBuffer beingReadData(int numBytes, ReadFlags flags);
|
| +
|
| + /**
|
| + * TODO(qsr):
|
| + *
|
| + * @param numBytesRead
|
| + */
|
| + public void endReadData(int numBytesRead);
|
| + }
|
| +
|
| +}
|
|
|