| 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.impl; | 5 package org.chromium.net.impl; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; |
| 7 import android.util.Log; | 8 import android.util.Log; |
| 8 | 9 |
| 9 import org.chromium.base.VisibleForTesting; | 10 import org.chromium.base.VisibleForTesting; |
| 10 import org.chromium.base.annotations.CalledByNative; | 11 import org.chromium.base.annotations.CalledByNative; |
| 11 import org.chromium.base.annotations.JNINamespace; | 12 import org.chromium.base.annotations.JNINamespace; |
| 12 import org.chromium.base.annotations.NativeClassQualifiedName; | 13 import org.chromium.base.annotations.NativeClassQualifiedName; |
| 13 import org.chromium.net.UploadDataProvider; | 14 import org.chromium.net.UploadDataProvider; |
| 14 import org.chromium.net.UploadDataSink; | 15 import org.chromium.net.UploadDataSink; |
| 15 | 16 |
| 16 import java.io.IOException; | 17 import java.io.IOException; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } | 195 } |
| 195 | 196 |
| 196 // Just fail the request - simpler to fail directly, and | 197 // Just fail the request - simpler to fail directly, and |
| 197 // UploadDataStream only supports failing during initialization, not | 198 // UploadDataStream only supports failing during initialization, not |
| 198 // while reading. The request is smart enough to handle the case where | 199 // while reading. The request is smart enough to handle the case where |
| 199 // it was already canceled by the embedder. | 200 // it was already canceled by the embedder. |
| 200 mRequest.onUploadException(exception); | 201 mRequest.onUploadException(exception); |
| 201 } | 202 } |
| 202 | 203 |
| 203 @Override | 204 @Override |
| 205 @SuppressLint("DefaultLocale") |
| 204 public void onReadSucceeded(boolean lastChunk) { | 206 public void onReadSucceeded(boolean lastChunk) { |
| 205 synchronized (mLock) { | 207 synchronized (mLock) { |
| 206 checkState(UserCallback.READ); | 208 checkState(UserCallback.READ); |
| 207 if (lastChunk && mLength >= 0) { | 209 if (lastChunk && mLength >= 0) { |
| 208 throw new IllegalArgumentException("Non-chunked upload can't hav
e last chunk"); | 210 throw new IllegalArgumentException("Non-chunked upload can't hav
e last chunk"); |
| 209 } | 211 } |
| 210 int bytesRead = mByteBuffer.position(); | 212 int bytesRead = mByteBuffer.position(); |
| 211 mRemainingLength -= bytesRead; | 213 mRemainingLength -= bytesRead; |
| 212 if (mRemainingLength < 0 && mLength >= 0) { | 214 if (mRemainingLength < 0 && mLength >= 0) { |
| 213 throw new IllegalArgumentException( | 215 throw new IllegalArgumentException( |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 386 |
| 385 @NativeClassQualifiedName("CronetUploadDataStreamAdapter") | 387 @NativeClassQualifiedName("CronetUploadDataStreamAdapter") |
| 386 private native void nativeOnReadSucceeded(long nativePtr, int bytesRead, boo
lean finalChunk); | 388 private native void nativeOnReadSucceeded(long nativePtr, int bytesRead, boo
lean finalChunk); |
| 387 | 389 |
| 388 @NativeClassQualifiedName("CronetUploadDataStreamAdapter") | 390 @NativeClassQualifiedName("CronetUploadDataStreamAdapter") |
| 389 private native void nativeOnRewindSucceeded(long nativePtr); | 391 private native void nativeOnRewindSucceeded(long nativePtr); |
| 390 | 392 |
| 391 @NativeClassQualifiedName("CronetUploadDataStreamAdapter") | 393 @NativeClassQualifiedName("CronetUploadDataStreamAdapter") |
| 392 private static native void nativeDestroy(long nativePtr); | 394 private static native void nativeDestroy(long nativePtr); |
| 393 } | 395 } |
| OLD | NEW |