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

Side by Side Diff: components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java

Issue 1393713005: [Cronet] Add error code and immediatelyRetryable() to UrlRequestException (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Helen's comments Created 5 years, 1 month 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 package org.chromium.net; 5 package org.chromium.net;
6 6
7 import android.util.Log; 7 import android.util.Log;
8 8
9 import org.chromium.base.VisibleForTesting; 9 import org.chromium.base.VisibleForTesting;
10 import org.chromium.base.annotations.CalledByNative; 10 import org.chromium.base.annotations.CalledByNative;
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 } 420 }
421 } 421 }
422 } 422 }
423 423
424 /** 424 /**
425 * If listener method throws an exception, request gets canceled 425 * If listener method throws an exception, request gets canceled
426 * and exception is reported via onFailed listener callback. 426 * and exception is reported via onFailed listener callback.
427 * Only called on the Executor. 427 * Only called on the Executor.
428 */ 428 */
429 private void onListenerException(Exception e) { 429 private void onListenerException(Exception e) {
430 UrlRequestException requestError = new UrlRequestException( 430 UrlRequestException requestError =
431 "CalledByNative method has thrown an exception", e); 431 new UrlRequestException("UrlRequestListener method has thrown an exception", e);
432 Log.e(CronetUrlRequestContext.LOG_TAG, 432 Log.e(CronetUrlRequestContext.LOG_TAG,
433 "Exception in CalledByNative method", e); 433 "Exception in CalledByNative method", e);
434 // Do not call into listener if request is complete. 434 // Do not call into listener if request is complete.
435 synchronized (mUrlRequestAdapterLock) { 435 synchronized (mUrlRequestAdapterLock) {
436 if (isDone()) { 436 if (isDone()) {
437 return; 437 return;
438 } 438 }
439 destroyRequestAdapter(false); 439 destroyRequestAdapter(false);
440 } 440 }
441 try { 441 try {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 "Exception in onComplete method", e); 618 "Exception in onComplete method", e);
619 } 619 }
620 } 620 }
621 }; 621 };
622 postTaskToExecutor(task); 622 postTaskToExecutor(task);
623 } 623 }
624 624
625 /** 625 /**
626 * Called when error has occured, no callbacks will be called afterwards. 626 * Called when error has occured, no callbacks will be called afterwards.
627 * 627 *
628 * @param errorCode error code from {@link UrlRequestException.ERROR_LISTENE R_THREW
629 * UrlRequestException.ERROR_*}.
628 * @param nativeError native net error code. 630 * @param nativeError native net error code.
629 * @param errorString textual representation of the error code. 631 * @param errorString textual representation of the error code.
630 * @param receivedBytesCount number of bytes received. 632 * @param receivedBytesCount number of bytes received.
631 */ 633 */
632 @SuppressWarnings("unused") 634 @SuppressWarnings("unused")
633 @CalledByNative 635 @CalledByNative
634 private void onError(final int nativeError, final String errorString, long r eceivedBytesCount) { 636 private void onError(
637 int errorCode, int nativeError, String errorString, long receivedByt esCount) {
635 if (mResponseInfo != null) { 638 if (mResponseInfo != null) {
636 mResponseInfo.setReceivedBytesCount( 639 mResponseInfo.setReceivedBytesCount(
637 mReceivedBytesCountFromRedirects + receivedBytesCount); 640 mReceivedBytesCountFromRedirects + receivedBytesCount);
638 } 641 }
639 UrlRequestException requestError = new UrlRequestException( 642 UrlRequestException requestError = new UrlRequestException(
640 "Exception in CronetUrlRequest: " + errorString, 643 "Exception in CronetUrlRequest: " + errorString, errorCode, nati veError);
641 nativeError);
642 failWithException(requestError); 644 failWithException(requestError);
643 } 645 }
644 646
645 /** 647 /**
646 * Called when request is canceled, no callbacks will be called afterwards. 648 * Called when request is canceled, no callbacks will be called afterwards.
647 */ 649 */
648 @SuppressWarnings("unused") 650 @SuppressWarnings("unused")
649 @CalledByNative 651 @CalledByNative
650 private void onCanceled() { 652 private void onCanceled() {
651 Runnable task = new Runnable() { 653 Runnable task = new Runnable() {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 713
712 @NativeClassQualifiedName("CronetURLRequestAdapter") 714 @NativeClassQualifiedName("CronetURLRequestAdapter")
713 private native String nativeGetProxyServer(long nativePtr); 715 private native String nativeGetProxyServer(long nativePtr);
714 716
715 @NativeClassQualifiedName("CronetURLRequestAdapter") 717 @NativeClassQualifiedName("CronetURLRequestAdapter")
716 private native void nativeGetStatus(long nativePtr, UrlRequest.StatusListene r listener); 718 private native void nativeGetStatus(long nativePtr, UrlRequest.StatusListene r listener);
717 719
718 @NativeClassQualifiedName("CronetURLRequestAdapter") 720 @NativeClassQualifiedName("CronetURLRequestAdapter")
719 private native boolean nativeGetWasCached(long nativePtr); 721 private native boolean nativeGetWasCached(long nativePtr);
720 } 722 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698