Commit 255fd2c4 authored by pauljensen's avatar pauljensen Committed by Commit bot

[cronet] Pass total bytes received to CronetUrlRequest.onSucceeded()

Previously onSucceeded() had to synchronize and turn around and
request total bytes received.  By passing it we avoid the
synchronization.

Review URL: https://codereview.chromium.org/1100923002

Cr-Commit-Position: refs/heads/master@{#327334}
parent b8fb0b71
......@@ -232,12 +232,6 @@ jboolean CronetURLRequestAdapter::GetWasCached(JNIEnv* env,
return url_request_->response_info().was_cached;
}
int64 CronetURLRequestAdapter::GetTotalReceivedBytes(JNIEnv* env,
jobject jcaller) const {
DCHECK(context_->IsOnNetworkThread());
return url_request_->GetTotalReceivedBytes();
}
// net::URLRequest::Delegate overrides (called on network thread).
void CronetURLRequestAdapter::OnReceivedRedirect(
......@@ -278,7 +272,8 @@ void CronetURLRequestAdapter::OnReadCompleted(net::URLRequest* request,
read_buffer_ = nullptr;
} else {
JNIEnv* env = base::android::AttachCurrentThread();
cronet::Java_CronetUrlRequest_onSucceeded(env, owner_.obj());
cronet::Java_CronetUrlRequest_onSucceeded(
env, owner_.obj(), url_request_->GetTotalReceivedBytes());
}
}
......
......@@ -107,11 +107,6 @@ class CronetURLRequestAdapter : public net::URLRequest::Delegate {
// Returns true if response is coming from the cache.
jboolean GetWasCached(JNIEnv* env, jobject jcaller) const;
// Gets the total amount of body data received from network after
// SSL/SPDY/QUIC decoding and proxy handling. Basically the size of the body
// prior to decompression.
int64 GetTotalReceivedBytes(JNIEnv* env, jobject jcaller) const;
// net::URLRequest::Delegate implementations:
void OnReceivedRedirect(net::URLRequest* request,
......
......@@ -616,16 +616,7 @@ final class CronetUrlRequest implements UrlRequest {
*/
@SuppressWarnings("unused")
@CalledByNative
private void onSucceeded() {
long totalReceivedBytes;
synchronized (mUrlRequestAdapterLock) {
if (mUrlRequestAdapter == 0) {
return;
}
totalReceivedBytes =
nativeGetTotalReceivedBytes(mUrlRequestAdapter);
}
private void onSucceeded(long totalReceivedBytes) {
final NativeExtendedResponseInfo extendedResponseInfo =
new NativeExtendedResponseInfo(mResponseInfo,
totalReceivedBytes);
......@@ -714,7 +705,4 @@ final class CronetUrlRequest implements UrlRequest {
@NativeClassQualifiedName("CronetURLRequestAdapter")
private native boolean nativeGetWasCached(long nativePtr);
@NativeClassQualifiedName("CronetURLRequestAdapter")
private native long nativeGetTotalReceivedBytes(long nativePtr);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment