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

Side by Side Diff: components/cronet/android/cronet_url_request_adapter.cc

Issue 1100923002: [cronet] Pass total bytes received to CronetUrlRequest.onSucceeded() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "cronet_url_request_adapter.h" 5 #include "cronet_url_request_adapter.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 if (bytes_read != 0) { 271 if (bytes_read != 0) {
272 JNIEnv* env = base::android::AttachCurrentThread(); 272 JNIEnv* env = base::android::AttachCurrentThread();
273 cronet::Java_CronetUrlRequest_onReadCompleted( 273 cronet::Java_CronetUrlRequest_onReadCompleted(
274 env, owner_.obj(), read_buffer_->byte_buffer(), bytes_read, 274 env, owner_.obj(), read_buffer_->byte_buffer(), bytes_read,
275 read_buffer_->initial_position()); 275 read_buffer_->initial_position());
276 // Free the read buffer. This lets the Java ByteBuffer be freed, if the 276 // Free the read buffer. This lets the Java ByteBuffer be freed, if the
277 // embedder releases it, too. 277 // embedder releases it, too.
278 read_buffer_ = nullptr; 278 read_buffer_ = nullptr;
279 } else { 279 } else {
280 JNIEnv* env = base::android::AttachCurrentThread(); 280 JNIEnv* env = base::android::AttachCurrentThread();
281 cronet::Java_CronetUrlRequest_onSucceeded(env, owner_.obj()); 281 cronet::Java_CronetUrlRequest_onSucceeded(
282 env, owner_.obj(), url_request_->GetTotalReceivedBytes());
282 } 283 }
283 } 284 }
284 285
285 void CronetURLRequestAdapter::StartOnNetworkThread() { 286 void CronetURLRequestAdapter::StartOnNetworkThread() {
286 DCHECK(context_->IsOnNetworkThread()); 287 DCHECK(context_->IsOnNetworkThread());
287 VLOG(1) << "Starting chromium request: " 288 VLOG(1) << "Starting chromium request: "
288 << initial_url_.possibly_invalid_spec().c_str() 289 << initial_url_.possibly_invalid_spec().c_str()
289 << " priority: " << RequestPriorityToString(initial_priority_); 290 << " priority: " << RequestPriorityToString(initial_priority_);
290 url_request_ = context_->GetURLRequestContext()->CreateRequest( 291 url_request_ = context_->GetURLRequestContext()->CreateRequest(
291 initial_url_, net::DEFAULT_PRIORITY, this); 292 initial_url_, net::DEFAULT_PRIORITY, this);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 VLOG(1) << "Error " << net::ErrorToString(net_error) 336 VLOG(1) << "Error " << net::ErrorToString(net_error)
336 << " on chromium request: " << initial_url_.possibly_invalid_spec(); 337 << " on chromium request: " << initial_url_.possibly_invalid_spec();
337 JNIEnv* env = base::android::AttachCurrentThread(); 338 JNIEnv* env = base::android::AttachCurrentThread();
338 cronet::Java_CronetUrlRequest_onError( 339 cronet::Java_CronetUrlRequest_onError(
339 env, owner_.obj(), net_error, 340 env, owner_.obj(), net_error,
340 ConvertUTF8ToJavaString(env, net::ErrorToString(net_error)).obj()); 341 ConvertUTF8ToJavaString(env, net::ErrorToString(net_error)).obj());
341 return true; 342 return true;
342 } 343 }
343 344
344 } // namespace cronet 345 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698