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

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: fix missing test annotation Created 4 years, 10 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 package org.chromium.net; 5 package org.chromium.net;
6 6
7 import android.os.SystemClock; 7 import android.os.SystemClock;
8 import android.support.annotation.Nullable; 8 import android.support.annotation.Nullable;
9 import android.util.Log; 9 import android.util.Log;
10 10
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 } 446 }
447 } 447 }
448 } 448 }
449 449
450 /** 450 /**
451 * If listener method throws an exception, request gets canceled 451 * If listener method throws an exception, request gets canceled
452 * and exception is reported via onFailed listener callback. 452 * and exception is reported via onFailed listener callback.
453 * Only called on the Executor. 453 * Only called on the Executor.
454 */ 454 */
455 private void onListenerException(Exception e) { 455 private void onListenerException(Exception e) {
456 UrlRequestException requestError = new UrlRequestException( 456 UrlRequestException requestError =
457 "CalledByNative method has thrown an exception", e); 457 new UrlRequestException("UrlRequestListener method has thrown an exception", e);
458 Log.e(CronetUrlRequestContext.LOG_TAG, 458 Log.e(CronetUrlRequestContext.LOG_TAG,
459 "Exception in CalledByNative method", e); 459 "Exception in CalledByNative method", e);
460 // Do not call into listener if request is finished. 460 // Do not call into listener if request is finished.
461 synchronized (mUrlRequestAdapterLock) { 461 synchronized (mUrlRequestAdapterLock) {
462 if (isDone()) { 462 if (isDone()) {
463 return; 463 return;
464 } 464 }
465 destroyRequestAdapter(false); 465 destroyRequestAdapter(false);
466 } 466 }
467 try { 467 try {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 "Exception in onComplete method", e); 651 "Exception in onComplete method", e);
652 } 652 }
653 } 653 }
654 }; 654 };
655 postTaskToExecutor(task); 655 postTaskToExecutor(task);
656 } 656 }
657 657
658 /** 658 /**
659 * Called when error has occured, no callbacks will be called afterwards. 659 * Called when error has occured, no callbacks will be called afterwards.
660 * 660 *
661 * @param errorCode error code from {@link UrlRequestException.ERROR_LISTENE R_EXCEPTION_THROWN
662 * UrlRequestException.ERROR_*}.
661 * @param nativeError native net error code. 663 * @param nativeError native net error code.
662 * @param errorString textual representation of the error code. 664 * @param errorString textual representation of the error code.
663 * @param receivedBytesCount number of bytes received. 665 * @param receivedBytesCount number of bytes received.
664 */ 666 */
665 @SuppressWarnings("unused") 667 @SuppressWarnings("unused")
666 @CalledByNative 668 @CalledByNative
667 private void onError(final int nativeError, final String errorString, long r eceivedBytesCount) { 669 private void onError(
670 int errorCode, int nativeError, String errorString, long receivedByt esCount) {
668 if (mResponseInfo != null) { 671 if (mResponseInfo != null) {
669 mResponseInfo.setReceivedBytesCount( 672 mResponseInfo.setReceivedBytesCount(
670 mReceivedBytesCountFromRedirects + receivedBytesCount); 673 mReceivedBytesCountFromRedirects + receivedBytesCount);
671 } 674 }
672 UrlRequestException requestError = new UrlRequestException( 675 UrlRequestException requestError = new UrlRequestException(
673 "Exception in CronetUrlRequest: " + errorString, 676 "Exception in CronetUrlRequest: " + errorString, errorCode, nati veError);
674 nativeError);
675 failWithException(requestError); 677 failWithException(requestError);
676 } 678 }
677 679
678 /** 680 /**
679 * Called when request is canceled, no callbacks will be called afterwards. 681 * Called when request is canceled, no callbacks will be called afterwards.
680 */ 682 */
681 @SuppressWarnings("unused") 683 @SuppressWarnings("unused")
682 @CalledByNative 684 @CalledByNative
683 private void onCanceled() { 685 private void onCanceled() {
684 Runnable task = new Runnable() { 686 Runnable task = new Runnable() {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 785
784 @NativeClassQualifiedName("CronetURLRequestAdapter") 786 @NativeClassQualifiedName("CronetURLRequestAdapter")
785 private native String nativeGetProxyServer(long nativePtr); 787 private native String nativeGetProxyServer(long nativePtr);
786 788
787 @NativeClassQualifiedName("CronetURLRequestAdapter") 789 @NativeClassQualifiedName("CronetURLRequestAdapter")
788 private native void nativeGetStatus(long nativePtr, UrlRequest.StatusListene r listener); 790 private native void nativeGetStatus(long nativePtr, UrlRequest.StatusListene r listener);
789 791
790 @NativeClassQualifiedName("CronetURLRequestAdapter") 792 @NativeClassQualifiedName("CronetURLRequestAdapter")
791 private native boolean nativeGetWasCached(long nativePtr); 793 private native boolean nativeGetWasCached(long nativePtr);
792 } 794 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698