Chromium Code Reviews| 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.annotation.SuppressLint; |
| 8 import android.util.Log; | 8 import android.util.Log; |
| 9 | 9 |
| 10 import org.chromium.base.VisibleForTesting; | 10 import org.chromium.base.VisibleForTesting; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 * It is called by the UploadDataStreamAdapter on the network thread, but calls | 29 * It is called by the UploadDataStreamAdapter on the network thread, but calls |
| 30 * into the UploadDataSink and the UploadDataStreamAdapter on the Executor | 30 * into the UploadDataSink and the UploadDataStreamAdapter on the Executor |
| 31 * passed into its constructor. | 31 * passed into its constructor. |
| 32 */ | 32 */ |
| 33 @JNINamespace("cronet") | 33 @JNINamespace("cronet") |
| 34 @VisibleForTesting | 34 @VisibleForTesting |
| 35 public final class CronetUploadDataStream extends UploadDataSink { | 35 public final class CronetUploadDataStream extends UploadDataSink { |
| 36 private static final String TAG = "CronetUploadDataStream"; | 36 private static final String TAG = "CronetUploadDataStream"; |
| 37 // These are never changed, once a request starts. | 37 // These are never changed, once a request starts. |
| 38 private final Executor mExecutor; | 38 private final Executor mExecutor; |
| 39 private final UploadDataProvider mDataProvider; | 39 private final VersionSafeCallbacks.UploadDataProviderWrapper mDataProvider; |
|
kapishnikov
2016/11/18 16:32:57
Same here. We should keep UploadDataProvider. Appl
pauljensen
2016/11/18 19:18:07
I think that defeats the purpose of this CL. User
kapishnikov
2016/11/18 19:39:15
Acknowledged.
| |
| 40 private long mLength; | 40 private long mLength; |
| 41 private long mRemainingLength; | 41 private long mRemainingLength; |
| 42 private CronetUrlRequest mRequest; | 42 private CronetUrlRequest mRequest; |
| 43 | 43 |
| 44 // Reusable read task, to reduce redundant memory allocation. | 44 // Reusable read task, to reduce redundant memory allocation. |
| 45 private final Runnable mReadTask = new Runnable() { | 45 private final Runnable mReadTask = new Runnable() { |
| 46 @Override | 46 @Override |
| 47 public void run() { | 47 public void run() { |
| 48 synchronized (mLock) { | 48 synchronized (mLock) { |
| 49 if (mUploadDataStreamAdapter == 0) { | 49 if (mUploadDataStreamAdapter == 0) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 private boolean mDestroyAdapterPostponed = false; | 91 private boolean mDestroyAdapterPostponed = false; |
| 92 private Runnable mOnDestroyedCallbackForTesting; | 92 private Runnable mOnDestroyedCallbackForTesting; |
| 93 | 93 |
| 94 /** | 94 /** |
| 95 * Constructs a CronetUploadDataStream. | 95 * Constructs a CronetUploadDataStream. |
| 96 * @param dataProvider the UploadDataProvider to read data from. | 96 * @param dataProvider the UploadDataProvider to read data from. |
| 97 * @param executor the Executor to execute UploadDataProvider tasks. | 97 * @param executor the Executor to execute UploadDataProvider tasks. |
| 98 */ | 98 */ |
| 99 public CronetUploadDataStream(UploadDataProvider dataProvider, Executor exec utor) { | 99 public CronetUploadDataStream(UploadDataProvider dataProvider, Executor exec utor) { |
| 100 mExecutor = executor; | 100 mExecutor = executor; |
| 101 mDataProvider = dataProvider; | 101 mDataProvider = new VersionSafeCallbacks.UploadDataProviderWrapper(dataP rovider); |
| 102 } | 102 } |
| 103 | 103 |
| 104 /** | 104 /** |
| 105 * Called by native code to make the UploadDataProvider read data into | 105 * Called by native code to make the UploadDataProvider read data into |
| 106 * {@code byteBuffer}. | 106 * {@code byteBuffer}. |
| 107 */ | 107 */ |
| 108 @SuppressWarnings("unused") | 108 @SuppressWarnings("unused") |
| 109 @CalledByNative | 109 @CalledByNative |
| 110 void readData(ByteBuffer byteBuffer) { | 110 void readData(ByteBuffer byteBuffer) { |
| 111 mByteBuffer = byteBuffer; | 111 mByteBuffer = byteBuffer; |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 | 386 |
| 387 @NativeClassQualifiedName("CronetUploadDataStreamAdapter") | 387 @NativeClassQualifiedName("CronetUploadDataStreamAdapter") |
| 388 private native void nativeOnReadSucceeded(long nativePtr, int bytesRead, boo lean finalChunk); | 388 private native void nativeOnReadSucceeded(long nativePtr, int bytesRead, boo lean finalChunk); |
| 389 | 389 |
| 390 @NativeClassQualifiedName("CronetUploadDataStreamAdapter") | 390 @NativeClassQualifiedName("CronetUploadDataStreamAdapter") |
| 391 private native void nativeOnRewindSucceeded(long nativePtr); | 391 private native void nativeOnRewindSucceeded(long nativePtr); |
| 392 | 392 |
| 393 @NativeClassQualifiedName("CronetUploadDataStreamAdapter") | 393 @NativeClassQualifiedName("CronetUploadDataStreamAdapter") |
| 394 private static native void nativeDestroy(long nativePtr); | 394 private static native void nativeDestroy(long nativePtr); |
| 395 } | 395 } |
| OLD | NEW |