| 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.util.Log; | 7 import android.util.Log; |
| 8 | 8 |
| 9 import org.apache.http.conn.ConnectTimeoutException; | 9 import org.apache.http.conn.ConnectTimeoutException; |
| 10 import org.chromium.base.CalledByNative; | 10 import org.chromium.base.CalledByNative; |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 /** | 679 /** |
| 680 * Reads a sequence of bytes from upload channel into the given buffer. | 680 * Reads a sequence of bytes from upload channel into the given buffer. |
| 681 * @param dest The buffer into which bytes are to be transferred. | 681 * @param dest The buffer into which bytes are to be transferred. |
| 682 * @return Returns number of bytes read (could be 0) or -1 and closes | 682 * @return Returns number of bytes read (could be 0) or -1 and closes |
| 683 * the channel if error occured. | 683 * the channel if error occured. |
| 684 */ | 684 */ |
| 685 @SuppressWarnings("unused") | 685 @SuppressWarnings("unused") |
| 686 @CalledByNative | 686 @CalledByNative |
| 687 private int readFromUploadChannel(ByteBuffer dest) { | 687 private int readFromUploadChannel(ByteBuffer dest) { |
| 688 try { | 688 try { |
| 689 if (mUploadChannel == null || !mUploadChannel.isOpen()) | 689 if (mUploadChannel == null || !mUploadChannel.isOpen()) return -1; |
| 690 return -1; | |
| 691 int result = mUploadChannel.read(dest); | 690 int result = mUploadChannel.read(dest); |
| 692 if (result < 0) { | 691 if (result < 0) { |
| 693 mUploadChannel.close(); | 692 mUploadChannel.close(); |
| 694 return 0; | 693 return 0; |
| 695 } | 694 } |
| 696 return result; | 695 return result; |
| 697 } catch (Exception e) { | 696 } catch (Exception e) { |
| 698 onCalledByNativeException(e); | 697 onCalledByNativeException(e); |
| 699 } | 698 } |
| 700 return -1; | 699 return -1; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 private native void nativeGetAllHeaders(long urlRequestAdapter, | 746 private native void nativeGetAllHeaders(long urlRequestAdapter, |
| 748 ResponseHeadersMap headers); | 747 ResponseHeadersMap headers); |
| 749 | 748 |
| 750 private native String nativeGetNegotiatedProtocol(long urlRequestAdapter); | 749 private native String nativeGetNegotiatedProtocol(long urlRequestAdapter); |
| 751 | 750 |
| 752 // Explicit class to work around JNI-generator generics confusion. | 751 // Explicit class to work around JNI-generator generics confusion. |
| 753 private static class ResponseHeadersMap extends | 752 private static class ResponseHeadersMap extends |
| 754 HashMap<String, List<String>> { | 753 HashMap<String, List<String>> { |
| 755 } | 754 } |
| 756 } | 755 } |
| OLD | NEW |