OLD | NEW |
(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.system; |
| 6 |
| 7 import java.nio.ByteBuffer; |
| 8 |
| 9 /** |
| 10 * TODO(qsr): Insert description here. |
| 11 */ |
| 12 public interface DataPipe { |
| 13 |
| 14 /** |
| 15 * TODO(qsr): Insert description here. |
| 16 */ |
| 17 public static class CreateFlags extends Flags<CreateFlags> { |
| 18 private static final int FLAG_NONE = 0; |
| 19 private static final int FLAG_MAY_DISCARD = 1 << 0; |
| 20 |
| 21 /** |
| 22 * Dedicated constructor. |
| 23 * |
| 24 * @param flags initial value of the flags. |
| 25 */ |
| 26 protected CreateFlags(int flags) { |
| 27 super(flags); |
| 28 } |
| 29 |
| 30 /** |
| 31 * Change the may-discard bit of this flag. |
| 32 * |
| 33 * @param mayDiscard the new value of the may-discard bit. |
| 34 * @return this. |
| 35 */ |
| 36 public CreateFlags mayDiscard(boolean mayDiscard) { |
| 37 return setFlag(FLAG_MAY_DISCARD, mayDiscard); |
| 38 } |
| 39 |
| 40 /** |
| 41 * @return flags with no bit set. |
| 42 */ |
| 43 public static CreateFlags none() { |
| 44 return new CreateFlags(FLAG_NONE); |
| 45 } |
| 46 |
| 47 } |
| 48 |
| 49 /** |
| 50 * TODO(qsr): Insert description here. |
| 51 */ |
| 52 public static class CreateOptions { |
| 53 public CreateFlags flags; |
| 54 public int elementNumBytes; |
| 55 public int capacityNumBytes; |
| 56 } |
| 57 |
| 58 /** |
| 59 * Flag for the write operations on MessagePipeHandle . |
| 60 */ |
| 61 public static class WriteFlags extends Flags<WriteFlags> { |
| 62 private static final int FLAG_NONE = 0; |
| 63 private static final int FLAG_ALL_OR_NONE = 1 << 0; |
| 64 |
| 65 /** |
| 66 * Dedicated constructor. |
| 67 * |
| 68 * @param flags initial value of the flags. |
| 69 */ |
| 70 private WriteFlags(int flags) { |
| 71 super(flags); |
| 72 } |
| 73 |
| 74 /** |
| 75 * Change the all-or-none bit of those flags. |
| 76 * |
| 77 * @param allOrNone the new value of all-or-none bit. |
| 78 * @return this. |
| 79 */ |
| 80 public WriteFlags allOrNone(boolean allOrNone) { |
| 81 return setFlag(FLAG_ALL_OR_NONE, allOrNone); |
| 82 } |
| 83 |
| 84 /** |
| 85 * @return a flag with no bit set. |
| 86 */ |
| 87 public static WriteFlags none() { |
| 88 return new WriteFlags(FLAG_NONE); |
| 89 } |
| 90 } |
| 91 |
| 92 /** |
| 93 * Flag for the read operations on MessagePipeHandle. |
| 94 */ |
| 95 public static class ReadFlags extends Flags<ReadFlags> { |
| 96 private static final int FLAG_NONE = 0; |
| 97 private static final int FLAG_ALL_OR_NONE = 1 << 0; |
| 98 private static final int FLAG_DISCARD = 1 << 1; |
| 99 private static final int FLAG_QUERY = 1 << 2; |
| 100 |
| 101 /** |
| 102 * Dedicated constructor. |
| 103 * |
| 104 * @param flags initial value of the flag. |
| 105 */ |
| 106 private ReadFlags(int flags) { |
| 107 super(flags); |
| 108 } |
| 109 |
| 110 /** |
| 111 * Change the all-or-none bit of this flag. |
| 112 * |
| 113 * @param allOrNone the new value of the all-or-none bit. |
| 114 * @return this. |
| 115 */ |
| 116 public ReadFlags allOrNone(boolean allOrNone) { |
| 117 return setFlag(FLAG_ALL_OR_NONE, allOrNone); |
| 118 } |
| 119 |
| 120 /** |
| 121 * Change the discard bit of this flag. |
| 122 * |
| 123 * @param discard the new value of the discard bit. |
| 124 * @return this. |
| 125 */ |
| 126 public ReadFlags discard(boolean discard) { |
| 127 return setFlag(FLAG_DISCARD, discard); |
| 128 } |
| 129 |
| 130 /** |
| 131 * Change the query bit of this flag. |
| 132 * |
| 133 * @param query the new value of the query bit. |
| 134 * @return this. |
| 135 */ |
| 136 public ReadFlags query(boolean query) { |
| 137 return setFlag(FLAG_QUERY, query); |
| 138 } |
| 139 |
| 140 /** |
| 141 * @return a flag with no bit set. |
| 142 */ |
| 143 public static ReadFlags none() { |
| 144 return new ReadFlags(FLAG_NONE); |
| 145 } |
| 146 |
| 147 } |
| 148 |
| 149 /** |
| 150 * TODO(qsr): Insert description here. |
| 151 */ |
| 152 public static interface ProducerHandle extends Handle { |
| 153 /** |
| 154 * TODO(qsr): |
| 155 * |
| 156 * @param elements |
| 157 * @param flags |
| 158 * @return number of written bytes. |
| 159 */ |
| 160 public int writeData(ByteBuffer elements, WriteFlags flags); |
| 161 |
| 162 /** |
| 163 * TODO(qsr): |
| 164 * |
| 165 * @param numBytes |
| 166 * @param flags |
| 167 * @return TODO(qsr) |
| 168 */ |
| 169 public java.nio.ByteBuffer beingWriteData(int numBytes, WriteFlags flags
); |
| 170 |
| 171 /** |
| 172 * TODO(qsr): |
| 173 * |
| 174 * @param numBytesWritten |
| 175 */ |
| 176 public void endWriteData(int numBytesWritten); |
| 177 } |
| 178 |
| 179 /** |
| 180 * TODO(qsr): Insert description here. |
| 181 */ |
| 182 public static interface ConsumerHandle extends Handle { |
| 183 /** |
| 184 * TODO(qsr): |
| 185 * |
| 186 * @param elements |
| 187 * @param flags |
| 188 * @return TODO(qsr): |
| 189 */ |
| 190 public int readData(ByteBuffer elements, ReadFlags flags); |
| 191 |
| 192 /** |
| 193 * TODO(qsr): |
| 194 * |
| 195 * @param numBytes |
| 196 * @param flags |
| 197 * @return TODO(qsr): |
| 198 */ |
| 199 public java.nio.ByteBuffer beingReadData(int numBytes, ReadFlags flags); |
| 200 |
| 201 /** |
| 202 * TODO(qsr): |
| 203 * |
| 204 * @param numBytesRead |
| 205 */ |
| 206 public void endReadData(int numBytesRead); |
| 207 } |
| 208 |
| 209 } |
OLD | NEW |