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

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

Issue 937513003: Add Data Saver support to Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed boolean from api Created 5 years, 8 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.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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 } 102 }
103 103
104 static final class NativeResponseInfo implements ResponseInfo { 104 static final class NativeResponseInfo implements ResponseInfo {
105 private final String[] mResponseInfoUrlChain; 105 private final String[] mResponseInfoUrlChain;
106 private final int mHttpStatusCode; 106 private final int mHttpStatusCode;
107 private final String mHttpStatusText; 107 private final String mHttpStatusText;
108 private final HeadersList mAllHeaders = new HeadersList(); 108 private final HeadersList mAllHeaders = new HeadersList();
109 private final boolean mWasCached; 109 private final boolean mWasCached;
110 private final String mNegotiatedProtocol; 110 private final String mNegotiatedProtocol;
111 private final String mProxyServer;
111 private Map<String, List<String>> mResponseHeaders; 112 private Map<String, List<String>> mResponseHeaders;
112 private List<Pair<String, String>> mUnmodifiableAllHeaders; 113 private List<Pair<String, String>> mUnmodifiableAllHeaders;
113 114
114 NativeResponseInfo(String[] urlChain, int httpStatusCode, 115 NativeResponseInfo(String[] urlChain, int httpStatusCode,
115 String httpStatusText, boolean wasCached, 116 String httpStatusText, boolean wasCached,
116 String negotiatedProtocol) { 117 String negotiatedProtocol, String proxyServer) {
117 mResponseInfoUrlChain = urlChain; 118 mResponseInfoUrlChain = urlChain;
118 mHttpStatusCode = httpStatusCode; 119 mHttpStatusCode = httpStatusCode;
119 mHttpStatusText = httpStatusText; 120 mHttpStatusText = httpStatusText;
120 mWasCached = wasCached; 121 mWasCached = wasCached;
121 mNegotiatedProtocol = negotiatedProtocol; 122 mNegotiatedProtocol = negotiatedProtocol;
123 mProxyServer = proxyServer;
122 } 124 }
123 125
124 @Override 126 @Override
125 public String getUrl() { 127 public String getUrl() {
126 return mResponseInfoUrlChain[mResponseInfoUrlChain.length - 1]; 128 return mResponseInfoUrlChain[mResponseInfoUrlChain.length - 1];
127 } 129 }
128 130
129 @Override 131 @Override
130 public String[] getUrlChain() { 132 public String[] getUrlChain() {
131 return mResponseInfoUrlChain; 133 return mResponseInfoUrlChain;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 173
172 @Override 174 @Override
173 public boolean wasCached() { 175 public boolean wasCached() {
174 return mWasCached; 176 return mWasCached;
175 } 177 }
176 178
177 @Override 179 @Override
178 public String getNegotiatedProtocol() { 180 public String getNegotiatedProtocol() {
179 return mNegotiatedProtocol; 181 return mNegotiatedProtocol;
180 } 182 }
183
184 @Override
185 public String getProxyServer() {
186 return mProxyServer;
187 }
181 }; 188 };
182 189
183 static final class NativeExtendedResponseInfo implements 190 static final class NativeExtendedResponseInfo implements
184 ExtendedResponseInfo { 191 ExtendedResponseInfo {
185 private final ResponseInfo mResponseInfo; 192 private final ResponseInfo mResponseInfo;
186 private final long mTotalReceivedBytes; 193 private final long mTotalReceivedBytes;
187 194
188 NativeExtendedResponseInfo(ResponseInfo responseInfo, 195 NativeExtendedResponseInfo(ResponseInfo responseInfo,
189 long totalReceivedBytes) { 196 long totalReceivedBytes) {
190 mResponseInfo = responseInfo; 197 mResponseInfo = responseInfo;
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // mUrlRequestAdapter is set to 0 from another thread the actual 423 // mUrlRequestAdapter is set to 0 from another thread the actual
417 // deletion of the adapter is posted to network thread, so it is 424 // deletion of the adapter is posted to network thread, so it is
418 // safe to preserve and use urlRequestAdapter outside the lock. 425 // safe to preserve and use urlRequestAdapter outside the lock.
419 urlRequestAdapter = mUrlRequestAdapter; 426 urlRequestAdapter = mUrlRequestAdapter;
420 } 427 }
421 NativeResponseInfo responseInfo = new NativeResponseInfo( 428 NativeResponseInfo responseInfo = new NativeResponseInfo(
422 mUrlChain.toArray(new String[mUrlChain.size()]), 429 mUrlChain.toArray(new String[mUrlChain.size()]),
423 httpStatusCode, 430 httpStatusCode,
424 nativeGetHttpStatusText(urlRequestAdapter), 431 nativeGetHttpStatusText(urlRequestAdapter),
425 nativeGetWasCached(urlRequestAdapter), 432 nativeGetWasCached(urlRequestAdapter),
426 nativeGetNegotiatedProtocol(urlRequestAdapter)); 433 nativeGetNegotiatedProtocol(urlRequestAdapter),
434 nativeGetProxyServer(urlRequestAdapter));
427 nativePopulateResponseHeaders(urlRequestAdapter, 435 nativePopulateResponseHeaders(urlRequestAdapter,
428 responseInfo.mAllHeaders); 436 responseInfo.mAllHeaders);
429 return responseInfo; 437 return responseInfo;
430 } 438 }
431 439
432 private void checkNotStarted() { 440 private void checkNotStarted() {
433 synchronized (mUrlRequestAdapterLock) { 441 synchronized (mUrlRequestAdapterLock) {
434 if (mStarted || isCanceled()) { 442 if (mStarted || isCanceled()) {
435 throw new IllegalStateException("Request is already started."); 443 throw new IllegalStateException("Request is already started.");
436 } 444 }
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 @NativeClassQualifiedName("CronetURLRequestAdapter") 714 @NativeClassQualifiedName("CronetURLRequestAdapter")
707 private native void nativePopulateResponseHeaders(long nativePtr, HeadersLis t headers); 715 private native void nativePopulateResponseHeaders(long nativePtr, HeadersLis t headers);
708 716
709 @NativeClassQualifiedName("CronetURLRequestAdapter") 717 @NativeClassQualifiedName("CronetURLRequestAdapter")
710 private native String nativeGetHttpStatusText(long nativePtr); 718 private native String nativeGetHttpStatusText(long nativePtr);
711 719
712 @NativeClassQualifiedName("CronetURLRequestAdapter") 720 @NativeClassQualifiedName("CronetURLRequestAdapter")
713 private native String nativeGetNegotiatedProtocol(long nativePtr); 721 private native String nativeGetNegotiatedProtocol(long nativePtr);
714 722
715 @NativeClassQualifiedName("CronetURLRequestAdapter") 723 @NativeClassQualifiedName("CronetURLRequestAdapter")
724 private native String nativeGetProxyServer(long nativePtr);
725
726 @NativeClassQualifiedName("CronetURLRequestAdapter")
716 private native boolean nativeGetWasCached(long nativePtr); 727 private native boolean nativeGetWasCached(long nativePtr);
717 728
718 @NativeClassQualifiedName("CronetURLRequestAdapter") 729 @NativeClassQualifiedName("CronetURLRequestAdapter")
719 private native long nativeGetTotalReceivedBytes(long nativePtr); 730 private native long nativeGetTotalReceivedBytes(long nativePtr);
720 } 731 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698