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

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

Issue 1359343005: Update ResponseInfo to UrlResponseInfo with API review comments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update README.md Created 5 years, 2 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 void CronetURLRequestAdapter::OnReceivedRedirect( 262 void CronetURLRequestAdapter::OnReceivedRedirect(
263 net::URLRequest* request, 263 net::URLRequest* request,
264 const net::RedirectInfo& redirect_info, 264 const net::RedirectInfo& redirect_info,
265 bool* defer_redirect) { 265 bool* defer_redirect) {
266 DCHECK(context_->IsOnNetworkThread()); 266 DCHECK(context_->IsOnNetworkThread());
267 DCHECK(request->status().is_success()); 267 DCHECK(request->status().is_success());
268 JNIEnv* env = base::android::AttachCurrentThread(); 268 JNIEnv* env = base::android::AttachCurrentThread();
269 cronet::Java_CronetUrlRequest_onReceivedRedirect( 269 cronet::Java_CronetUrlRequest_onReceivedRedirect(
270 env, owner_.obj(), 270 env, owner_.obj(),
271 ConvertUTF8ToJavaString(env, redirect_info.new_url.spec()).obj(), 271 ConvertUTF8ToJavaString(env, redirect_info.new_url.spec()).obj(),
272 redirect_info.status_code); 272 redirect_info.status_code, request->GetTotalReceivedBytes());
273 *defer_redirect = true; 273 *defer_redirect = true;
274 } 274 }
275 275
276 void CronetURLRequestAdapter::OnSSLCertificateError( 276 void CronetURLRequestAdapter::OnSSLCertificateError(
277 net::URLRequest* request, 277 net::URLRequest* request,
278 const net::SSLInfo& ssl_info, 278 const net::SSLInfo& ssl_info,
279 bool fatal) { 279 bool fatal) {
280 DCHECK(context_->IsOnNetworkThread()); 280 DCHECK(context_->IsOnNetworkThread());
281 request->Cancel(); 281 request->Cancel();
282 int net_error = net::MapCertStatusToNetError(ssl_info.cert_status); 282 int net_error = net::MapCertStatusToNetError(ssl_info.cert_status);
283 JNIEnv* env = base::android::AttachCurrentThread(); 283 JNIEnv* env = base::android::AttachCurrentThread();
284 cronet::Java_CronetUrlRequest_onError( 284 cronet::Java_CronetUrlRequest_onError(
285 env, owner_.obj(), net_error, 285 env, owner_.obj(), net_error,
286 ConvertUTF8ToJavaString(env, net::ErrorToString(net_error)).obj()); 286 ConvertUTF8ToJavaString(env, net::ErrorToString(net_error)).obj(),
287 request->GetTotalReceivedBytes());
287 } 288 }
288 289
289 void CronetURLRequestAdapter::OnResponseStarted(net::URLRequest* request) { 290 void CronetURLRequestAdapter::OnResponseStarted(net::URLRequest* request) {
290 DCHECK(context_->IsOnNetworkThread()); 291 DCHECK(context_->IsOnNetworkThread());
291 if (MaybeReportError(request)) 292 if (MaybeReportError(request))
292 return; 293 return;
293 JNIEnv* env = base::android::AttachCurrentThread(); 294 JNIEnv* env = base::android::AttachCurrentThread();
294 cronet::Java_CronetUrlRequest_onResponseStarted(env, owner_.obj(), 295 cronet::Java_CronetUrlRequest_onResponseStarted(env, owner_.obj(),
295 request->GetResponseCode()); 296 request->GetResponseCode());
296 } 297 }
297 298
298 void CronetURLRequestAdapter::OnReadCompleted(net::URLRequest* request, 299 void CronetURLRequestAdapter::OnReadCompleted(net::URLRequest* request,
299 int bytes_read) { 300 int bytes_read) {
300 DCHECK(context_->IsOnNetworkThread()); 301 DCHECK(context_->IsOnNetworkThread());
301 if (MaybeReportError(request)) 302 if (MaybeReportError(request))
302 return; 303 return;
303 if (bytes_read != 0) { 304 if (bytes_read != 0) {
304 JNIEnv* env = base::android::AttachCurrentThread(); 305 JNIEnv* env = base::android::AttachCurrentThread();
305 cronet::Java_CronetUrlRequest_onReadCompleted( 306 cronet::Java_CronetUrlRequest_onReadCompleted(
306 env, owner_.obj(), read_buffer_->byte_buffer(), bytes_read, 307 env, owner_.obj(), read_buffer_->byte_buffer(), bytes_read,
307 read_buffer_->initial_position()); 308 read_buffer_->initial_position(), request->GetTotalReceivedBytes());
308 // Free the read buffer. This lets the Java ByteBuffer be freed, if the 309 // Free the read buffer. This lets the Java ByteBuffer be freed, if the
309 // embedder releases it, too. 310 // embedder releases it, too.
310 read_buffer_ = nullptr; 311 read_buffer_ = nullptr;
311 } else { 312 } else {
312 JNIEnv* env = base::android::AttachCurrentThread(); 313 JNIEnv* env = base::android::AttachCurrentThread();
313 cronet::Java_CronetUrlRequest_onSucceeded( 314 cronet::Java_CronetUrlRequest_onSucceeded(
314 env, owner_.obj(), url_request_->GetTotalReceivedBytes()); 315 env, owner_.obj(), url_request_->GetTotalReceivedBytes());
315 } 316 }
316 } 317 }
317 318
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 DCHECK_NE(net::URLRequestStatus::IO_PENDING, url_request_->status().status()); 374 DCHECK_NE(net::URLRequestStatus::IO_PENDING, url_request_->status().status());
374 DCHECK_EQ(request, url_request_); 375 DCHECK_EQ(request, url_request_);
375 if (url_request_->status().is_success()) 376 if (url_request_->status().is_success())
376 return false; 377 return false;
377 int net_error = url_request_->status().error(); 378 int net_error = url_request_->status().error();
378 VLOG(1) << "Error " << net::ErrorToString(net_error) 379 VLOG(1) << "Error " << net::ErrorToString(net_error)
379 << " on chromium request: " << initial_url_.possibly_invalid_spec(); 380 << " on chromium request: " << initial_url_.possibly_invalid_spec();
380 JNIEnv* env = base::android::AttachCurrentThread(); 381 JNIEnv* env = base::android::AttachCurrentThread();
381 cronet::Java_CronetUrlRequest_onError( 382 cronet::Java_CronetUrlRequest_onError(
382 env, owner_.obj(), net_error, 383 env, owner_.obj(), net_error,
383 ConvertUTF8ToJavaString(env, net::ErrorToString(net_error)).obj()); 384 ConvertUTF8ToJavaString(env, net::ErrorToString(net_error)).obj(),
385 request->GetTotalReceivedBytes());
384 return true; 386 return true;
385 } 387 }
386 388
387 } // namespace cronet 389 } // namespace cronet
OLDNEW
« no previous file with comments | « components/cronet/README.md ('k') | components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698