| 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 org.chromium.base.CalledByNative; | 7 import org.chromium.base.CalledByNative; |
| 8 import org.chromium.base.JNINamespace; | 8 import org.chromium.base.JNINamespace; |
| 9 import org.chromium.base.NativeClassQualifiedName; | 9 import org.chromium.base.NativeClassQualifiedName; |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 /** | 64 /** |
| 65 * Constructs a CronetUploadDataStream. | 65 * Constructs a CronetUploadDataStream. |
| 66 * @param dataProvider the UploadDataProvider to read data from. | 66 * @param dataProvider the UploadDataProvider to read data from. |
| 67 * @param executor the Executor to execute UploadDataProvider tasks. | 67 * @param executor the Executor to execute UploadDataProvider tasks. |
| 68 */ | 68 */ |
| 69 public CronetUploadDataStream(UploadDataProvider dataProvider, | 69 public CronetUploadDataStream(UploadDataProvider dataProvider, |
| 70 Executor executor) { | 70 Executor executor) { |
| 71 mExecutor = executor; | 71 mExecutor = executor; |
| 72 mDataProvider = dataProvider; | 72 mDataProvider = dataProvider; |
| 73 mLength = mDataProvider.getLength(); | 73 mLength = mDataProvider.getLength(); |
| 74 if (mLength < 0) { | |
| 75 // TODO(mmenke): Add tests and remove this line. | |
| 76 throw new IllegalArgumentException( | |
| 77 "Chunked uploads not supported."); | |
| 78 } | |
| 79 } | 74 } |
| 80 | 75 |
| 81 /** | 76 /** |
| 82 * Called by native code to make the UploadDataProvider read data into | 77 * Called by native code to make the UploadDataProvider read data into |
| 83 * {@code byteBuffer}. | 78 * {@code byteBuffer}. |
| 84 */ | 79 */ |
| 85 @SuppressWarnings("unused") | 80 @SuppressWarnings("unused") |
| 86 @CalledByNative | 81 @CalledByNative |
| 87 void readData(ByteBuffer byteBuffer) { | 82 void readData(ByteBuffer byteBuffer) { |
| 88 mByteBuffer = byteBuffer; | 83 mByteBuffer = byteBuffer; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 @NativeClassQualifiedName("CronetUploadDataStreamDelegate") | 288 @NativeClassQualifiedName("CronetUploadDataStreamDelegate") |
| 294 private native void nativeOnReadSucceeded(long nativePtr, | 289 private native void nativeOnReadSucceeded(long nativePtr, |
| 295 int bytesRead, boolean finalChunk); | 290 int bytesRead, boolean finalChunk); |
| 296 | 291 |
| 297 @NativeClassQualifiedName("CronetUploadDataStreamDelegate") | 292 @NativeClassQualifiedName("CronetUploadDataStreamDelegate") |
| 298 private native void nativeOnRewindSucceeded(long nativePtr); | 293 private native void nativeOnRewindSucceeded(long nativePtr); |
| 299 | 294 |
| 300 private static native void nativeDestroyDelegate( | 295 private static native void nativeDestroyDelegate( |
| 301 long uploadDataStreamDelegate); | 296 long uploadDataStreamDelegate); |
| 302 } | 297 } |
| OLD | NEW |