| OLD | NEW |
| 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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 } | 442 } |
| 443 } | 443 } |
| 444 } | 444 } |
| 445 | 445 |
| 446 /** | 446 /** |
| 447 * If listener method throws an exception, request gets canceled | 447 * If listener method throws an exception, request gets canceled |
| 448 * and exception is reported via onFailed listener callback. | 448 * and exception is reported via onFailed listener callback. |
| 449 * Only called on the Executor. | 449 * Only called on the Executor. |
| 450 */ | 450 */ |
| 451 private void onListenerException(Exception e) { | 451 private void onListenerException(Exception e) { |
| 452 UrlRequestException requestError = new UrlRequestException( | 452 UrlRequestException requestError = |
| 453 "CalledByNative method has thrown an exception", e); | 453 new UrlRequestException("UrlRequestListener method has thrown an
exception", e); |
| 454 Log.e(CronetUrlRequestContext.LOG_TAG, | 454 Log.e(CronetUrlRequestContext.LOG_TAG, |
| 455 "Exception in CalledByNative method", e); | 455 "Exception in CalledByNative method", e); |
| 456 // Do not call into listener if request is finished. | 456 // Do not call into listener if request is finished. |
| 457 synchronized (mUrlRequestAdapterLock) { | 457 synchronized (mUrlRequestAdapterLock) { |
| 458 if (isDone()) { | 458 if (isDone()) { |
| 459 return; | 459 return; |
| 460 } | 460 } |
| 461 destroyRequestAdapter(false); | 461 destroyRequestAdapter(false); |
| 462 } | 462 } |
| 463 try { | 463 try { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 "Exception in onComplete method", e); | 647 "Exception in onComplete method", e); |
| 648 } | 648 } |
| 649 } | 649 } |
| 650 }; | 650 }; |
| 651 postTaskToExecutor(task); | 651 postTaskToExecutor(task); |
| 652 } | 652 } |
| 653 | 653 |
| 654 /** | 654 /** |
| 655 * Called when error has occured, no callbacks will be called afterwards. | 655 * Called when error has occured, no callbacks will be called afterwards. |
| 656 * | 656 * |
| 657 * @param errorCode error code from {@link UrlRequestException.ERROR_LISTENE
R_EXCEPTION_THROWN |
| 658 * UrlRequestException.ERROR_*}. |
| 657 * @param nativeError native net error code. | 659 * @param nativeError native net error code. |
| 658 * @param errorString textual representation of the error code. | 660 * @param errorString textual representation of the error code. |
| 659 * @param receivedBytesCount number of bytes received. | 661 * @param receivedBytesCount number of bytes received. |
| 660 */ | 662 */ |
| 661 @SuppressWarnings("unused") | 663 @SuppressWarnings("unused") |
| 662 @CalledByNative | 664 @CalledByNative |
| 663 private void onError(final int nativeError, final String errorString, long r
eceivedBytesCount) { | 665 private void onError( |
| 666 int errorCode, int nativeError, String errorString, long receivedByt
esCount) { |
| 664 if (mResponseInfo != null) { | 667 if (mResponseInfo != null) { |
| 665 mResponseInfo.setReceivedBytesCount( | 668 mResponseInfo.setReceivedBytesCount( |
| 666 mReceivedBytesCountFromRedirects + receivedBytesCount); | 669 mReceivedBytesCountFromRedirects + receivedBytesCount); |
| 667 } | 670 } |
| 668 UrlRequestException requestError = new UrlRequestException( | 671 UrlRequestException requestError = new UrlRequestException( |
| 669 "Exception in CronetUrlRequest: " + errorString, | 672 "Exception in CronetUrlRequest: " + errorString, errorCode, nati
veError); |
| 670 nativeError); | |
| 671 failWithException(requestError); | 673 failWithException(requestError); |
| 672 } | 674 } |
| 673 | 675 |
| 674 /** | 676 /** |
| 675 * Called when request is canceled, no callbacks will be called afterwards. | 677 * Called when request is canceled, no callbacks will be called afterwards. |
| 676 */ | 678 */ |
| 677 @SuppressWarnings("unused") | 679 @SuppressWarnings("unused") |
| 678 @CalledByNative | 680 @CalledByNative |
| 679 private void onCanceled() { | 681 private void onCanceled() { |
| 680 Runnable task = new Runnable() { | 682 Runnable task = new Runnable() { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 | 781 |
| 780 @NativeClassQualifiedName("CronetURLRequestAdapter") | 782 @NativeClassQualifiedName("CronetURLRequestAdapter") |
| 781 private native String nativeGetProxyServer(long nativePtr); | 783 private native String nativeGetProxyServer(long nativePtr); |
| 782 | 784 |
| 783 @NativeClassQualifiedName("CronetURLRequestAdapter") | 785 @NativeClassQualifiedName("CronetURLRequestAdapter") |
| 784 private native void nativeGetStatus(long nativePtr, UrlRequest.StatusListene
r listener); | 786 private native void nativeGetStatus(long nativePtr, UrlRequest.StatusListene
r listener); |
| 785 | 787 |
| 786 @NativeClassQualifiedName("CronetURLRequestAdapter") | 788 @NativeClassQualifiedName("CronetURLRequestAdapter") |
| 787 private native boolean nativeGetWasCached(long nativePtr); | 789 private native boolean nativeGetWasCached(long nativePtr); |
| 788 } | 790 } |
| OLD | NEW |