Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Unified Diff: components/cronet/android/java/src/org/chromium/net/CronetUploadDataStream.java

Issue 1124333003: Rename CronetUploadDataStreamAdapter to CronetUploadDataStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/cronet/android/java/src/org/chromium/net/CronetUploadDataStream.java
diff --git a/components/cronet/android/java/src/org/chromium/net/CronetUploadDataStream.java b/components/cronet/android/java/src/org/chromium/net/CronetUploadDataStream.java
index 0427c40d9b683e7da4e448a601ac1901ef3ca809..37864f5e073b36ca8250f21674a4d9905f58819a 100644
--- a/components/cronet/android/java/src/org/chromium/net/CronetUploadDataStream.java
+++ b/components/cronet/android/java/src/org/chromium/net/CronetUploadDataStream.java
@@ -52,9 +52,9 @@ final class CronetUploadDataStream implements UploadDataSink {
// to robustly detect getting read/rewind results more often than expected.
private final Object mLock = new Object();
- // Native adapter delegate object, owned by the CronetUploadDataStream.
- // It's only deleted after the native UploadDataStream object is destroyed.
- // All access to the delegate is synchronized, for safe usage and cleanup.
+ // Native delegate object, owned by the CronetUploadDataStream. It's only
+ // deleted after the native UploadDataStream object is destroyed. All access
+ // to the delegate is synchronized, for safe usage and cleanup.
private long mUploadDataStreamDelegate = 0;
private boolean mReading = false;
@@ -115,12 +115,13 @@ final class CronetUploadDataStream implements UploadDataSink {
}
/**
- * Called by native code to destroy the native adapter delegate, when the
- * adapter is destroyed.
+ * Called when the native UploadDataStream is destroyed. At this point,
+ * the native delegate needs to be destroyed, but only after any pending
+ * read operation completes, as the delegate owns the read buffer.
*/
@SuppressWarnings("unused")
@CalledByNative
- void onAdapterDestroyed() {
+ void onUploadDataStreamDestroyed() {
Runnable task = new Runnable() {
@Override
public void run() {
@@ -149,8 +150,8 @@ final class CronetUploadDataStream implements UploadDataSink {
// Just fail the request - simpler to fail directly, and
// UploadDataStream only supports failing during initialization, not
- // while reading. This should be safe, even if we deleted the adapter,
- // because in that case, the request has already been cancelled.
+ // while reading. The request is smart enough to handle the case where
+ // it was already cancelled by the embedder.
mRequest.onUploadException(exception);
}
@@ -266,23 +267,24 @@ final class CronetUploadDataStream implements UploadDataSink {
}
/**
- * Creates a native UploadDataStreamDelegate and UploadDataStreamAdapter
- * for testing.
- * @return the address of the native CronetUploadDataStreamAdapter object.
+ * Creates a native CronetUploadDataStreamDelegate and
+ * CronetUploadDataStream for testing.
+ * @return the address of the native CronetUploadDataStream object.
*/
- public long createAdapterForTesting() {
+ public long createUploadDataStreamForTesting() {
mUploadDataStreamDelegate = nativeCreateDelegateForTesting();
- return nativeCreateAdapterForTesting(mLength, mUploadDataStreamDelegate);
+ return nativeCreateUploadDataStreamForTesting(mLength,
+ mUploadDataStreamDelegate);
}
- // Native methods are implemented in upload_data_stream_adapter.cc.
+ // Native methods are implemented in upload_data_stream.cc.
private native long nativeAttachUploadDataToRequest(long urlRequestAdapter,
long length);
private native long nativeCreateDelegateForTesting();
- private native long nativeCreateAdapterForTesting(long length,
+ private native long nativeCreateUploadDataStreamForTesting(long length,
long delegate);
@NativeClassQualifiedName("CronetUploadDataStreamDelegate")

Powered by Google App Engine
This is Rietveld 408576698