OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.net; | 5 package org.chromium.net; |
6 | 6 |
7 import java.io.IOException; | 7 import java.io.IOException; |
8 import java.nio.ByteBuffer; | 8 import java.nio.ByteBuffer; |
9 import java.util.ArrayList; | 9 import java.util.ArrayList; |
10 import java.util.concurrent.Executor; | 10 import java.util.concurrent.Executor; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 "Unexpected operation during rewind"); | 188 "Unexpected operation during rewind"); |
189 } | 189 } |
190 if (mFailed) { | 190 if (mFailed) { |
191 throw new IllegalStateException( | 191 throw new IllegalStateException( |
192 "Unexpected operation after failure"); | 192 "Unexpected operation after failure"); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 private boolean maybeFailRead(int readIndex, | 196 private boolean maybeFailRead(int readIndex, |
197 final UploadDataSink uploadDataSink) { | 197 final UploadDataSink uploadDataSink) { |
198 if (readIndex != mReadFailIndex) | 198 if (readIndex != mReadFailIndex) return false; |
199 return false; | |
200 | 199 |
201 switch (mReadFailMode) { | 200 switch (mReadFailMode) { |
202 case THROWN: | 201 case THROWN: |
203 throw new IllegalStateException("Thrown read failure"); | 202 throw new IllegalStateException("Thrown read failure"); |
204 case CALLBACK_SYNC: | 203 case CALLBACK_SYNC: |
205 uploadDataSink.onReadError( | 204 uploadDataSink.onReadError( |
206 new IllegalStateException("Sync read failure")); | 205 new IllegalStateException("Sync read failure")); |
207 return true; | 206 return true; |
208 case CALLBACK_ASYNC: | 207 case CALLBACK_ASYNC: |
209 Runnable errorRunnable = new Runnable() { | 208 Runnable errorRunnable = new Runnable() { |
(...skipping 26 matching lines...) Expand all Loading... |
236 "Async rewind failure")); | 235 "Async rewind failure")); |
237 } | 236 } |
238 }; | 237 }; |
239 mExecutor.execute(errorRunnable); | 238 mExecutor.execute(errorRunnable); |
240 return true; | 239 return true; |
241 default: | 240 default: |
242 return false; | 241 return false; |
243 } | 242 } |
244 } | 243 } |
245 } | 244 } |
OLD | NEW |