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

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: remove more dead code 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 return ConvertUTF8ToJavaString( 225 return ConvertUTF8ToJavaString(
226 env, url_request_->response_info().npn_negotiated_protocol); 226 env, url_request_->response_info().npn_negotiated_protocol);
227 } 227 }
228 228
229 jboolean CronetURLRequestAdapter::GetWasCached(JNIEnv* env, 229 jboolean CronetURLRequestAdapter::GetWasCached(JNIEnv* env,
230 jobject jcaller) const { 230 jobject jcaller) const {
231 DCHECK(context_->IsOnNetworkThread()); 231 DCHECK(context_->IsOnNetworkThread());
232 return url_request_->response_info().was_cached; 232 return url_request_->response_info().was_cached;
233 } 233 }
234 234
235 int64 CronetURLRequestAdapter::GetTotalReceivedBytes(JNIEnv* env,
236 jobject jcaller) const {
237 DCHECK(context_->IsOnNetworkThread());
238 return url_request_->GetTotalReceivedBytes();
239 }
240
241 // net::URLRequest::Delegate overrides (called on network thread). 235 // net::URLRequest::Delegate overrides (called on network thread).
242 236
243 void CronetURLRequestAdapter::OnReceivedRedirect( 237 void CronetURLRequestAdapter::OnReceivedRedirect(
244 net::URLRequest* request, 238 net::URLRequest* request,
245 const net::RedirectInfo& redirect_info, 239 const net::RedirectInfo& redirect_info,
246 bool* defer_redirect) { 240 bool* defer_redirect) {
247 DCHECK(context_->IsOnNetworkThread()); 241 DCHECK(context_->IsOnNetworkThread());
248 DCHECK(request->status().is_success()); 242 DCHECK(request->status().is_success());
249 JNIEnv* env = base::android::AttachCurrentThread(); 243 JNIEnv* env = base::android::AttachCurrentThread();
250 cronet::Java_CronetUrlRequest_onReceivedRedirect( 244 cronet::Java_CronetUrlRequest_onReceivedRedirect(
(...skipping 20 matching lines...) Expand all
271 if (bytes_read != 0) { 265 if (bytes_read != 0) {
272 JNIEnv* env = base::android::AttachCurrentThread(); 266 JNIEnv* env = base::android::AttachCurrentThread();
273 cronet::Java_CronetUrlRequest_onReadCompleted( 267 cronet::Java_CronetUrlRequest_onReadCompleted(
274 env, owner_.obj(), read_buffer_->byte_buffer(), bytes_read, 268 env, owner_.obj(), read_buffer_->byte_buffer(), bytes_read,
275 read_buffer_->initial_position()); 269 read_buffer_->initial_position());
276 // Free the read buffer. This lets the Java ByteBuffer be freed, if the 270 // Free the read buffer. This lets the Java ByteBuffer be freed, if the
277 // embedder releases it, too. 271 // embedder releases it, too.
278 read_buffer_ = nullptr; 272 read_buffer_ = nullptr;
279 } else { 273 } else {
280 JNIEnv* env = base::android::AttachCurrentThread(); 274 JNIEnv* env = base::android::AttachCurrentThread();
281 cronet::Java_CronetUrlRequest_onSucceeded(env, owner_.obj()); 275 cronet::Java_CronetUrlRequest_onSucceeded(
276 env, owner_.obj(), url_request_->GetTotalReceivedBytes());
282 } 277 }
283 } 278 }
284 279
285 void CronetURLRequestAdapter::StartOnNetworkThread() { 280 void CronetURLRequestAdapter::StartOnNetworkThread() {
286 DCHECK(context_->IsOnNetworkThread()); 281 DCHECK(context_->IsOnNetworkThread());
287 VLOG(1) << "Starting chromium request: " 282 VLOG(1) << "Starting chromium request: "
288 << initial_url_.possibly_invalid_spec().c_str() 283 << initial_url_.possibly_invalid_spec().c_str()
289 << " priority: " << RequestPriorityToString(initial_priority_); 284 << " priority: " << RequestPriorityToString(initial_priority_);
290 url_request_ = context_->GetURLRequestContext()->CreateRequest( 285 url_request_ = context_->GetURLRequestContext()->CreateRequest(
291 initial_url_, net::DEFAULT_PRIORITY, this); 286 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) 330 VLOG(1) << "Error " << net::ErrorToString(net_error)
336 << " on chromium request: " << initial_url_.possibly_invalid_spec(); 331 << " on chromium request: " << initial_url_.possibly_invalid_spec();
337 JNIEnv* env = base::android::AttachCurrentThread(); 332 JNIEnv* env = base::android::AttachCurrentThread();
338 cronet::Java_CronetUrlRequest_onError( 333 cronet::Java_CronetUrlRequest_onError(
339 env, owner_.obj(), net_error, 334 env, owner_.obj(), net_error,
340 ConvertUTF8ToJavaString(env, net::ErrorToString(net_error)).obj()); 335 ConvertUTF8ToJavaString(env, net::ErrorToString(net_error)).obj());
341 return true; 336 return true;
342 } 337 }
343 338
344 } // namespace cronet 339 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698