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

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: Added test Created 5 years, 9 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 } 114 }
115 115
116 static final class NativeResponseInfo implements ResponseInfo { 116 static final class NativeResponseInfo implements ResponseInfo {
117 private final String[] mResponseInfoUrlChain; 117 private final String[] mResponseInfoUrlChain;
118 private final int mHttpStatusCode; 118 private final int mHttpStatusCode;
119 private final String mHttpStatusText; 119 private final String mHttpStatusText;
120 private final HeadersList mAllHeaders = new HeadersList(); 120 private final HeadersList mAllHeaders = new HeadersList();
121 private final boolean mWasCached; 121 private final boolean mWasCached;
122 private final String mNegotiatedProtocol; 122 private final String mNegotiatedProtocol;
123 private final String mProxyServer;
123 private Map<String, List<String>> mResponseHeaders; 124 private Map<String, List<String>> mResponseHeaders;
124 private List<Pair<String, String>> mUnmodifiableAllHeaders; 125 private List<Pair<String, String>> mUnmodifiableAllHeaders;
125 126
126 NativeResponseInfo(String[] urlChain, int httpStatusCode, 127 NativeResponseInfo(String[] urlChain, int httpStatusCode,
127 String httpStatusText, boolean wasCached, 128 String httpStatusText, boolean wasCached,
128 String negotiatedProtocol) { 129 String negotiatedProtocol, String proxyServer) {
129 mResponseInfoUrlChain = urlChain; 130 mResponseInfoUrlChain = urlChain;
130 mHttpStatusCode = httpStatusCode; 131 mHttpStatusCode = httpStatusCode;
131 mHttpStatusText = httpStatusText; 132 mHttpStatusText = httpStatusText;
132 mWasCached = wasCached; 133 mWasCached = wasCached;
133 mNegotiatedProtocol = negotiatedProtocol; 134 mNegotiatedProtocol = negotiatedProtocol;
135 mProxyServer = proxyServer;
134 } 136 }
135 137
136 @Override 138 @Override
137 public String getUrl() { 139 public String getUrl() {
138 return mResponseInfoUrlChain[mResponseInfoUrlChain.length - 1]; 140 return mResponseInfoUrlChain[mResponseInfoUrlChain.length - 1];
139 } 141 }
140 142
141 @Override 143 @Override
142 public String[] getUrlChain() { 144 public String[] getUrlChain() {
143 return mResponseInfoUrlChain; 145 return mResponseInfoUrlChain;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 185
184 @Override 186 @Override
185 public boolean wasCached() { 187 public boolean wasCached() {
186 return mWasCached; 188 return mWasCached;
187 } 189 }
188 190
189 @Override 191 @Override
190 public String getNegotiatedProtocol() { 192 public String getNegotiatedProtocol() {
191 return mNegotiatedProtocol; 193 return mNegotiatedProtocol;
192 } 194 }
195
196 @Override
197 public String getProxyServer() {
198 return mProxyServer;
199 }
193 }; 200 };
194 201
195 static final class NativeExtendedResponseInfo implements 202 static final class NativeExtendedResponseInfo implements
196 ExtendedResponseInfo { 203 ExtendedResponseInfo {
197 private final ResponseInfo mResponseInfo; 204 private final ResponseInfo mResponseInfo;
198 private final long mTotalReceivedBytes; 205 private final long mTotalReceivedBytes;
199 206
200 NativeExtendedResponseInfo(ResponseInfo responseInfo, 207 NativeExtendedResponseInfo(ResponseInfo responseInfo,
201 long totalReceivedBytes) { 208 long totalReceivedBytes) {
202 mResponseInfo = responseInfo; 209 mResponseInfo = responseInfo;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // mUrlRequestAdapter is set to 0 from another thread the actual 404 // mUrlRequestAdapter is set to 0 from another thread the actual
398 // deletion of the adapter is posted to network thread, so it is 405 // deletion of the adapter is posted to network thread, so it is
399 // safe to preserve and use urlRequestAdapter outside the lock. 406 // safe to preserve and use urlRequestAdapter outside the lock.
400 urlRequestAdapter = mUrlRequestAdapter; 407 urlRequestAdapter = mUrlRequestAdapter;
401 } 408 }
402 NativeResponseInfo responseInfo = new NativeResponseInfo( 409 NativeResponseInfo responseInfo = new NativeResponseInfo(
403 mUrlChain.toArray(new String[mUrlChain.size()]), 410 mUrlChain.toArray(new String[mUrlChain.size()]),
404 httpStatusCode, 411 httpStatusCode,
405 nativeGetHttpStatusText(urlRequestAdapter), 412 nativeGetHttpStatusText(urlRequestAdapter),
406 nativeGetWasCached(urlRequestAdapter), 413 nativeGetWasCached(urlRequestAdapter),
407 nativeGetNegotiatedProtocol(urlRequestAdapter)); 414 nativeGetNegotiatedProtocol(urlRequestAdapter),
415 nativeGetProxyServer(urlRequestAdapter));
408 nativePopulateResponseHeaders(urlRequestAdapter, 416 nativePopulateResponseHeaders(urlRequestAdapter,
409 responseInfo.mAllHeaders); 417 responseInfo.mAllHeaders);
410 return responseInfo; 418 return responseInfo;
411 } 419 }
412 420
413 private void checkNotStarted() { 421 private void checkNotStarted() {
414 synchronized (mUrlRequestAdapterLock) { 422 synchronized (mUrlRequestAdapterLock) {
415 if (mStarted || isCanceled()) { 423 if (mStarted || isCanceled()) {
416 throw new IllegalStateException("Request is already started."); 424 throw new IllegalStateException("Request is already started.");
417 } 425 }
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 677
670 private native void nativeFollowDeferredRedirect(long urlRequestAdapter); 678 private native void nativeFollowDeferredRedirect(long urlRequestAdapter);
671 679
672 private native void nativeReceiveData(long urlRequestAdapter); 680 private native void nativeReceiveData(long urlRequestAdapter);
673 681
674 private native void nativePopulateResponseHeaders(long urlRequestAdapter, 682 private native void nativePopulateResponseHeaders(long urlRequestAdapter,
675 HeadersList headers); 683 HeadersList headers);
676 684
677 private native String nativeGetNegotiatedProtocol(long urlRequestAdapter); 685 private native String nativeGetNegotiatedProtocol(long urlRequestAdapter);
678 686
687 private native String nativeGetProxyServer(long urlRequestAdapter);
688
679 private native String nativeGetHttpStatusText(long urlRequestAdapter); 689 private native String nativeGetHttpStatusText(long urlRequestAdapter);
680 690
681 private native boolean nativeGetWasCached(long urlRequestAdapter); 691 private native boolean nativeGetWasCached(long urlRequestAdapter);
682 692
683 private native long nativeGetTotalReceivedBytes(long urlRequestAdapter); 693 private native long nativeGetTotalReceivedBytes(long urlRequestAdapter);
684 694
685 private native void nativeDisableCache(long urlRequestAdapter); 695 private native void nativeDisableCache(long urlRequestAdapter);
686 } 696 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698