Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / mojo / public / java / src / org / chromium / mojo / system / InvalidHandle.java
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
8 import org.chromium.mojo.system.Core.WaitFlags;
9 import org.chromium.mojo.system.DataPipe.ConsumerHandle;
10 import org.chromium.mojo.system.DataPipe.ProducerHandle;
11
12 import java.nio.ByteBuffer;
13 import java.util.List;
14
15 /**
16  * A handle that will always be invalid.
17  */
18 public class InvalidHandle implements UntypedHandle, MessagePipeHandle, ConsumerHandle,
19         ProducerHandle, SharedBufferHandle {
20
21     /**
22      * @see Handle#close()
23      */
24     @Override
25     public void close() {
26         // Do nothing.
27     }
28
29     /**
30      * @see Handle#wait(Core.WaitFlags, long)
31      */
32     @Override
33     public int wait(WaitFlags flags, long deadline) {
34         throw new MojoException(MojoResult.INVALID_ARGUMENT);
35     }
36
37     /**
38      * @see Handle#isValid()
39      */
40     @Override
41     public boolean isValid() {
42         return false;
43     }
44
45     /**
46      * @see UntypedHandle#toMessagePipeHandle()
47      */
48     @Override
49     public MessagePipeHandle toMessagePipeHandle() {
50         return this;
51     }
52
53     /**
54      * @see UntypedHandle#toDataPipeConsumerHandle()
55      */
56     @Override
57     public ConsumerHandle toDataPipeConsumerHandle() {
58         return this;
59     }
60
61     /**
62      * @see UntypedHandle#toDataPipeProducerHandle()
63      */
64     @Override
65     public ProducerHandle toDataPipeProducerHandle() {
66         return this;
67     }
68
69     /**
70      * @see UntypedHandle#toSharedBufferHandle()
71      */
72     @Override
73     public SharedBufferHandle toSharedBufferHandle() {
74         return this;
75     }
76
77     /**
78      * @see SharedBufferHandle#duplicate(SharedBufferHandle.DuplicateOptions)
79      */
80     @Override
81     public SharedBufferHandle duplicate(DuplicateOptions options) {
82         throw new MojoException(MojoResult.INVALID_ARGUMENT);
83     }
84
85     /**
86      * @see SharedBufferHandle#map(long, long, SharedBufferHandle.MapFlags)
87      */
88     @Override
89     public ByteBuffer map(long offset, long numBytes, MapFlags flags) {
90         throw new MojoException(MojoResult.INVALID_ARGUMENT);
91     }
92
93     /**
94      * @see SharedBufferHandle#unmap(java.nio.ByteBuffer)
95      */
96     @Override
97     public void unmap(ByteBuffer buffer) {
98         throw new MojoException(MojoResult.INVALID_ARGUMENT);
99     }
100
101     /**
102      * @see DataPipe.ProducerHandle#writeData(java.nio.ByteBuffer, DataPipe.WriteFlags)
103      */
104     @Override
105     public int writeData(ByteBuffer elements, DataPipe.WriteFlags flags) {
106         throw new MojoException(MojoResult.INVALID_ARGUMENT);
107     }
108
109     /**
110      * @see DataPipe.ProducerHandle#beginWriteData(int, DataPipe.WriteFlags)
111      */
112     @Override
113     public ByteBuffer beginWriteData(int numBytes,
114             DataPipe.WriteFlags flags) {
115         throw new MojoException(MojoResult.INVALID_ARGUMENT);
116     }
117
118     /**
119      * @see DataPipe.ProducerHandle#endWriteData(int)
120      */
121     @Override
122     public void endWriteData(int numBytesWritten) {
123         throw new MojoException(MojoResult.INVALID_ARGUMENT);
124     }
125
126     /**
127      * @see DataPipe.ConsumerHandle#discardData(int, DataPipe.ReadFlags)
128      */
129     @Override
130     public int discardData(int numBytes, DataPipe.ReadFlags flags) {
131         throw new MojoException(MojoResult.INVALID_ARGUMENT);
132     }
133
134     /**
135      * @see DataPipe.ConsumerHandle#readData(java.nio.ByteBuffer, DataPipe.ReadFlags)
136      */
137     @Override
138     public int readData(ByteBuffer elements, DataPipe.ReadFlags flags) {
139         throw new MojoException(MojoResult.INVALID_ARGUMENT);
140     }
141
142     /**
143      * @see DataPipe.ConsumerHandle#beginReadData(int, DataPipe.ReadFlags)
144      */
145     @Override
146     public ByteBuffer beginReadData(int numBytes,
147             DataPipe.ReadFlags flags) {
148         throw new MojoException(MojoResult.INVALID_ARGUMENT);
149     }
150
151     /**
152      * @see DataPipe.ConsumerHandle#endReadData(int)
153      */
154     @Override
155     public void endReadData(int numBytesRead) {
156         throw new MojoException(MojoResult.INVALID_ARGUMENT);
157     }
158
159     /**
160      * @see MessagePipeHandle#writeMessage(java.nio.ByteBuffer, java.util.List,
161      *      MessagePipeHandle.WriteFlags)
162      */
163     @Override
164     public void writeMessage(ByteBuffer bytes, List<Handle> handles, WriteFlags flags) {
165         throw new MojoException(MojoResult.INVALID_ARGUMENT);
166     }
167
168     /**
169      * @see MessagePipeHandle#readMessage(java.nio.ByteBuffer, int, MessagePipeHandle.ReadFlags)
170      */
171     @Override
172     public ReadMessageResult readMessage(ByteBuffer bytes, int maxNumberOfHandles,
173             ReadFlags flags) {
174         throw new MojoException(MojoResult.INVALID_ARGUMENT);
175     }
176
177 }