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 org.chromium.mojo.system.Core.HandleSignals; | |
8 import org.chromium.mojo.system.DataPipe.ConsumerHandle; | |
9 import org.chromium.mojo.system.DataPipe.ProducerHandle; | |
10 | |
11 import java.nio.ByteBuffer; | |
12 import java.util.List; | |
13 | |
14 /** | |
15 * A handle that will always be invalid. | |
16 */ | |
17 public class InvalidHandle implements UntypedHandle, MessagePipeHandle, Consumer
Handle, | |
18 ProducerHandle, SharedBufferHandle { | |
19 | |
20 /** | |
21 * Instance singleton. | |
22 */ | |
23 public static final InvalidHandle INSTANCE = new InvalidHandle(); | |
24 | |
25 /** | |
26 * Private constructor. | |
27 */ | |
28 private InvalidHandle() { | |
29 } | |
30 | |
31 /** | |
32 * @see Handle#close() | |
33 */ | |
34 @Override | |
35 public void close() { | |
36 // Do nothing. | |
37 } | |
38 | |
39 /** | |
40 * @see Handle#wait(Core.HandleSignals, long) | |
41 */ | |
42 @Override | |
43 public int wait(HandleSignals signals, long deadline) { | |
44 throw new MojoException(MojoResult.INVALID_ARGUMENT); | |
45 } | |
46 | |
47 /** | |
48 * @see Handle#isValid() | |
49 */ | |
50 @Override | |
51 public boolean isValid() { | |
52 return false; | |
53 } | |
54 | |
55 /** | |
56 * @see Handle#getCore() | |
57 */ | |
58 @Override | |
59 public Core getCore() { | |
60 return null; | |
61 } | |
62 | |
63 /** | |
64 * @see org.chromium.mojo.system.Handle#pass() | |
65 */ | |
66 @Override | |
67 public InvalidHandle pass() { | |
68 return this; | |
69 } | |
70 | |
71 | |
72 /** | |
73 * @see Handle#toUntypedHandle() | |
74 */ | |
75 @Override | |
76 public UntypedHandle toUntypedHandle() { | |
77 return this; | |
78 } | |
79 | |
80 /** | |
81 * @see UntypedHandle#toMessagePipeHandle() | |
82 */ | |
83 @Override | |
84 public MessagePipeHandle toMessagePipeHandle() { | |
85 return this; | |
86 } | |
87 | |
88 /** | |
89 * @see UntypedHandle#toDataPipeConsumerHandle() | |
90 */ | |
91 @Override | |
92 public ConsumerHandle toDataPipeConsumerHandle() { | |
93 return this; | |
94 } | |
95 | |
96 /** | |
97 * @see UntypedHandle#toDataPipeProducerHandle() | |
98 */ | |
99 @Override | |
100 public ProducerHandle toDataPipeProducerHandle() { | |
101 return this; | |
102 } | |
103 | |
104 /** | |
105 * @see UntypedHandle#toSharedBufferHandle() | |
106 */ | |
107 @Override | |
108 public SharedBufferHandle toSharedBufferHandle() { | |
109 return this; | |
110 } | |
111 | |
112 /** | |
113 * @see SharedBufferHandle#duplicate(SharedBufferHandle.DuplicateOptions) | |
114 */ | |
115 @Override | |
116 public SharedBufferHandle duplicate(DuplicateOptions options) { | |
117 throw new MojoException(MojoResult.INVALID_ARGUMENT); | |
118 } | |
119 | |
120 /** | |
121 * @see SharedBufferHandle#map(long, long, SharedBufferHandle.MapFlags) | |
122 */ | |
123 @Override | |
124 public ByteBuffer map(long offset, long numBytes, MapFlags flags) { | |
125 throw new MojoException(MojoResult.INVALID_ARGUMENT); | |
126 } | |
127 | |
128 /** | |
129 * @see SharedBufferHandle#unmap(java.nio.ByteBuffer) | |
130 */ | |
131 @Override | |
132 public void unmap(ByteBuffer buffer) { | |
133 throw new MojoException(MojoResult.INVALID_ARGUMENT); | |
134 } | |
135 | |
136 /** | |
137 * @see DataPipe.ProducerHandle#writeData(java.nio.ByteBuffer, DataPipe.Writ
eFlags) | |
138 */ | |
139 @Override | |
140 public int writeData(ByteBuffer elements, DataPipe.WriteFlags flags) { | |
141 throw new MojoException(MojoResult.INVALID_ARGUMENT); | |
142 } | |
143 | |
144 /** | |
145 * @see DataPipe.ProducerHandle#beginWriteData(int, DataPipe.WriteFlags) | |
146 */ | |
147 @Override | |
148 public ByteBuffer beginWriteData(int numBytes, | |
149 DataPipe.WriteFlags flags) { | |
150 throw new MojoException(MojoResult.INVALID_ARGUMENT); | |
151 } | |
152 | |
153 /** | |
154 * @see DataPipe.ProducerHandle#endWriteData(int) | |
155 */ | |
156 @Override | |
157 public void endWriteData(int numBytesWritten) { | |
158 throw new MojoException(MojoResult.INVALID_ARGUMENT); | |
159 } | |
160 | |
161 /** | |
162 * @see DataPipe.ConsumerHandle#discardData(int, DataPipe.ReadFlags) | |
163 */ | |
164 @Override | |
165 public int discardData(int numBytes, DataPipe.ReadFlags flags) { | |
166 throw new MojoException(MojoResult.INVALID_ARGUMENT); | |
167 } | |
168 | |
169 /** | |
170 * @see DataPipe.ConsumerHandle#readData(java.nio.ByteBuffer, DataPipe.ReadF
lags) | |
171 */ | |
172 @Override | |
173 public int readData(ByteBuffer elements, DataPipe.ReadFlags flags) { | |
174 throw new MojoException(MojoResult.INVALID_ARGUMENT); | |
175 } | |
176 | |
177 /** | |
178 * @see DataPipe.ConsumerHandle#beginReadData(int, DataPipe.ReadFlags) | |
179 */ | |
180 @Override | |
181 public ByteBuffer beginReadData(int numBytes, | |
182 DataPipe.ReadFlags flags) { | |
183 throw new MojoException(MojoResult.INVALID_ARGUMENT); | |
184 } | |
185 | |
186 /** | |
187 * @see DataPipe.ConsumerHandle#endReadData(int) | |
188 */ | |
189 @Override | |
190 public void endReadData(int numBytesRead) { | |
191 throw new MojoException(MojoResult.INVALID_ARGUMENT); | |
192 } | |
193 | |
194 /** | |
195 * @see MessagePipeHandle#writeMessage(java.nio.ByteBuffer, java.util.List, | |
196 * MessagePipeHandle.WriteFlags) | |
197 */ | |
198 @Override | |
199 public void writeMessage(ByteBuffer bytes, List<? extends Handle> handles, W
riteFlags flags) { | |
200 throw new MojoException(MojoResult.INVALID_ARGUMENT); | |
201 } | |
202 | |
203 /** | |
204 * @see MessagePipeHandle#readMessage(java.nio.ByteBuffer, int, MessagePipeH
andle.ReadFlags) | |
205 */ | |
206 @Override | |
207 public ReadMessageResult readMessage(ByteBuffer bytes, int maxNumberOfHandle
s, | |
208 ReadFlags flags) { | |
209 throw new MojoException(MojoResult.INVALID_ARGUMENT); | |
210 } | |
211 | |
212 } | |
OLD | NEW |