| 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 import android.util.Pair; | 8 import android.util.Pair; |
| 9 | 9 |
| 10 import org.chromium.base.CalledByNative; | 10 import org.chromium.base.CalledByNative; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 static final class NativeResponseInfo implements ResponseInfo { | 103 static final class NativeResponseInfo implements ResponseInfo { |
| 104 private final String[] mResponseInfoUrlChain; | 104 private final String[] mResponseInfoUrlChain; |
| 105 private final int mHttpStatusCode; | 105 private final int mHttpStatusCode; |
| 106 private final String mHttpStatusText; | 106 private final String mHttpStatusText; |
| 107 private final HeadersList mAllHeaders = new HeadersList(); | 107 private final HeadersList mAllHeaders = new HeadersList(); |
| 108 private final boolean mWasCached; | 108 private final boolean mWasCached; |
| 109 private final String mNegotiatedProtocol; | 109 private final String mNegotiatedProtocol; |
| 110 private final String mProxyServer; |
| 110 private Map<String, List<String>> mResponseHeaders; | 111 private Map<String, List<String>> mResponseHeaders; |
| 111 private List<Pair<String, String>> mUnmodifiableAllHeaders; | 112 private List<Pair<String, String>> mUnmodifiableAllHeaders; |
| 112 | 113 |
| 113 NativeResponseInfo(String[] urlChain, int httpStatusCode, | 114 NativeResponseInfo(String[] urlChain, int httpStatusCode, |
| 114 String httpStatusText, boolean wasCached, | 115 String httpStatusText, boolean wasCached, |
| 115 String negotiatedProtocol) { | 116 String negotiatedProtocol, String proxyServer) { |
| 116 mResponseInfoUrlChain = urlChain; | 117 mResponseInfoUrlChain = urlChain; |
| 117 mHttpStatusCode = httpStatusCode; | 118 mHttpStatusCode = httpStatusCode; |
| 118 mHttpStatusText = httpStatusText; | 119 mHttpStatusText = httpStatusText; |
| 119 mWasCached = wasCached; | 120 mWasCached = wasCached; |
| 120 mNegotiatedProtocol = negotiatedProtocol; | 121 mNegotiatedProtocol = negotiatedProtocol; |
| 122 mProxyServer = proxyServer; |
| 121 } | 123 } |
| 122 | 124 |
| 123 @Override | 125 @Override |
| 124 public String getUrl() { | 126 public String getUrl() { |
| 125 return mResponseInfoUrlChain[mResponseInfoUrlChain.length - 1]; | 127 return mResponseInfoUrlChain[mResponseInfoUrlChain.length - 1]; |
| 126 } | 128 } |
| 127 | 129 |
| 128 @Override | 130 @Override |
| 129 public String[] getUrlChain() { | 131 public String[] getUrlChain() { |
| 130 return mResponseInfoUrlChain; | 132 return mResponseInfoUrlChain; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 172 |
| 171 @Override | 173 @Override |
| 172 public boolean wasCached() { | 174 public boolean wasCached() { |
| 173 return mWasCached; | 175 return mWasCached; |
| 174 } | 176 } |
| 175 | 177 |
| 176 @Override | 178 @Override |
| 177 public String getNegotiatedProtocol() { | 179 public String getNegotiatedProtocol() { |
| 178 return mNegotiatedProtocol; | 180 return mNegotiatedProtocol; |
| 179 } | 181 } |
| 182 |
| 183 @Override |
| 184 public String getProxyServer() { |
| 185 return mProxyServer; |
| 186 } |
| 180 }; | 187 }; |
| 181 | 188 |
| 182 static final class NativeExtendedResponseInfo implements | 189 static final class NativeExtendedResponseInfo implements |
| 183 ExtendedResponseInfo { | 190 ExtendedResponseInfo { |
| 184 private final ResponseInfo mResponseInfo; | 191 private final ResponseInfo mResponseInfo; |
| 185 private final long mTotalReceivedBytes; | 192 private final long mTotalReceivedBytes; |
| 186 | 193 |
| 187 NativeExtendedResponseInfo(ResponseInfo responseInfo, | 194 NativeExtendedResponseInfo(ResponseInfo responseInfo, |
| 188 long totalReceivedBytes) { | 195 long totalReceivedBytes) { |
| 189 mResponseInfo = responseInfo; | 196 mResponseInfo = responseInfo; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 // mUrlRequestAdapter is set to 0 from another thread the actual | 421 // mUrlRequestAdapter is set to 0 from another thread the actual |
| 415 // deletion of the adapter is posted to network thread, so it is | 422 // deletion of the adapter is posted to network thread, so it is |
| 416 // safe to preserve and use urlRequestAdapter outside the lock. | 423 // safe to preserve and use urlRequestAdapter outside the lock. |
| 417 urlRequestAdapter = mUrlRequestAdapter; | 424 urlRequestAdapter = mUrlRequestAdapter; |
| 418 } | 425 } |
| 419 NativeResponseInfo responseInfo = new NativeResponseInfo( | 426 NativeResponseInfo responseInfo = new NativeResponseInfo( |
| 420 mUrlChain.toArray(new String[mUrlChain.size()]), | 427 mUrlChain.toArray(new String[mUrlChain.size()]), |
| 421 httpStatusCode, | 428 httpStatusCode, |
| 422 nativeGetHttpStatusText(urlRequestAdapter), | 429 nativeGetHttpStatusText(urlRequestAdapter), |
| 423 nativeGetWasCached(urlRequestAdapter), | 430 nativeGetWasCached(urlRequestAdapter), |
| 424 nativeGetNegotiatedProtocol(urlRequestAdapter)); | 431 nativeGetNegotiatedProtocol(urlRequestAdapter), |
| 432 nativeGetProxyServer(urlRequestAdapter)); |
| 425 nativePopulateResponseHeaders(urlRequestAdapter, | 433 nativePopulateResponseHeaders(urlRequestAdapter, |
| 426 responseInfo.mAllHeaders); | 434 responseInfo.mAllHeaders); |
| 427 return responseInfo; | 435 return responseInfo; |
| 428 } | 436 } |
| 429 | 437 |
| 430 private void checkNotStarted() { | 438 private void checkNotStarted() { |
| 431 synchronized (mUrlRequestAdapterLock) { | 439 synchronized (mUrlRequestAdapterLock) { |
| 432 if (mStarted || isDone()) { | 440 if (mStarted || isDone()) { |
| 433 throw new IllegalStateException("Request is already started."); | 441 throw new IllegalStateException("Request is already started."); |
| 434 } | 442 } |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 @NativeClassQualifiedName("CronetURLRequestAdapter") | 703 @NativeClassQualifiedName("CronetURLRequestAdapter") |
| 696 private native void nativePopulateResponseHeaders(long nativePtr, HeadersLis
t headers); | 704 private native void nativePopulateResponseHeaders(long nativePtr, HeadersLis
t headers); |
| 697 | 705 |
| 698 @NativeClassQualifiedName("CronetURLRequestAdapter") | 706 @NativeClassQualifiedName("CronetURLRequestAdapter") |
| 699 private native String nativeGetHttpStatusText(long nativePtr); | 707 private native String nativeGetHttpStatusText(long nativePtr); |
| 700 | 708 |
| 701 @NativeClassQualifiedName("CronetURLRequestAdapter") | 709 @NativeClassQualifiedName("CronetURLRequestAdapter") |
| 702 private native String nativeGetNegotiatedProtocol(long nativePtr); | 710 private native String nativeGetNegotiatedProtocol(long nativePtr); |
| 703 | 711 |
| 704 @NativeClassQualifiedName("CronetURLRequestAdapter") | 712 @NativeClassQualifiedName("CronetURLRequestAdapter") |
| 713 private native String nativeGetProxyServer(long nativePtr); |
| 714 |
| 715 @NativeClassQualifiedName("CronetURLRequestAdapter") |
| 705 private native boolean nativeGetWasCached(long nativePtr); | 716 private native boolean nativeGetWasCached(long nativePtr); |
| 706 } | 717 } |
| OLD | NEW |