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.
5 package org.chromium.mojo.system;
7 import org.chromium.mojo.system.Core.HandleSignals;
8 import org.chromium.mojo.system.DataPipe.ConsumerHandle;
9 import org.chromium.mojo.system.DataPipe.ProducerHandle;
11 import java.nio.ByteBuffer;
12 import java.util.List;
15 * A handle that will always be invalid.
17 public class InvalidHandle implements UntypedHandle, MessagePipeHandle, ConsumerHandle,
18 ProducerHandle, SharedBufferHandle {
23 public static final InvalidHandle INSTANCE = new InvalidHandle();
26 * Private constructor.
28 private InvalidHandle() {
40 * @see Handle#wait(Core.HandleSignals, long)
43 public int wait(HandleSignals signals, long deadline) {
44 throw new MojoException(MojoResult.INVALID_ARGUMENT);
48 * @see Handle#isValid()
51 public boolean isValid() {
56 * @see Handle#getCore()
59 public Core getCore() {
64 * @see org.chromium.mojo.system.Handle#pass()
67 public InvalidHandle pass() {
73 * @see Handle#toUntypedHandle()
76 public UntypedHandle toUntypedHandle() {
81 * @see UntypedHandle#toMessagePipeHandle()
84 public MessagePipeHandle toMessagePipeHandle() {
89 * @see UntypedHandle#toDataPipeConsumerHandle()
92 public ConsumerHandle toDataPipeConsumerHandle() {
97 * @see UntypedHandle#toDataPipeProducerHandle()
100 public ProducerHandle toDataPipeProducerHandle() {
105 * @see UntypedHandle#toSharedBufferHandle()
108 public SharedBufferHandle toSharedBufferHandle() {
113 * @see SharedBufferHandle#duplicate(SharedBufferHandle.DuplicateOptions)
116 public SharedBufferHandle duplicate(DuplicateOptions options) {
117 throw new MojoException(MojoResult.INVALID_ARGUMENT);
121 * @see SharedBufferHandle#map(long, long, SharedBufferHandle.MapFlags)
124 public ByteBuffer map(long offset, long numBytes, MapFlags flags) {
125 throw new MojoException(MojoResult.INVALID_ARGUMENT);
129 * @see SharedBufferHandle#unmap(java.nio.ByteBuffer)
132 public void unmap(ByteBuffer buffer) {
133 throw new MojoException(MojoResult.INVALID_ARGUMENT);
137 * @see DataPipe.ProducerHandle#writeData(java.nio.ByteBuffer, DataPipe.WriteFlags)
140 public int writeData(ByteBuffer elements, DataPipe.WriteFlags flags) {
141 throw new MojoException(MojoResult.INVALID_ARGUMENT);
145 * @see DataPipe.ProducerHandle#beginWriteData(int, DataPipe.WriteFlags)
148 public ByteBuffer beginWriteData(int numBytes,
149 DataPipe.WriteFlags flags) {
150 throw new MojoException(MojoResult.INVALID_ARGUMENT);
154 * @see DataPipe.ProducerHandle#endWriteData(int)
157 public void endWriteData(int numBytesWritten) {
158 throw new MojoException(MojoResult.INVALID_ARGUMENT);
162 * @see DataPipe.ConsumerHandle#discardData(int, DataPipe.ReadFlags)
165 public int discardData(int numBytes, DataPipe.ReadFlags flags) {
166 throw new MojoException(MojoResult.INVALID_ARGUMENT);
170 * @see DataPipe.ConsumerHandle#readData(java.nio.ByteBuffer, DataPipe.ReadFlags)
173 public int readData(ByteBuffer elements, DataPipe.ReadFlags flags) {
174 throw new MojoException(MojoResult.INVALID_ARGUMENT);
178 * @see DataPipe.ConsumerHandle#beginReadData(int, DataPipe.ReadFlags)
181 public ByteBuffer beginReadData(int numBytes,
182 DataPipe.ReadFlags flags) {
183 throw new MojoException(MojoResult.INVALID_ARGUMENT);
187 * @see DataPipe.ConsumerHandle#endReadData(int)
190 public void endReadData(int numBytesRead) {
191 throw new MojoException(MojoResult.INVALID_ARGUMENT);
195 * @see MessagePipeHandle#writeMessage(java.nio.ByteBuffer, java.util.List,
196 * MessagePipeHandle.WriteFlags)
199 public void writeMessage(ByteBuffer bytes, List<? extends Handle> handles, WriteFlags flags) {
200 throw new MojoException(MojoResult.INVALID_ARGUMENT);
204 * @see MessagePipeHandle#readMessage(java.nio.ByteBuffer, int, MessagePipeHandle.ReadFlags)
207 public ReadMessageResult readMessage(ByteBuffer bytes, int maxNumberOfHandles,
209 throw new MojoException(MojoResult.INVALID_ARGUMENT);