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

Unified Diff: components/cronet/android/java/src/org/chromium/net/urlconnection/CronetHttpURLConnection.java

Issue 1359343005: Update ResponseInfo to UrlResponseInfo with API review comments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to CronetEngine builders. Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: components/cronet/android/java/src/org/chromium/net/urlconnection/CronetHttpURLConnection.java
diff --git a/components/cronet/android/java/src/org/chromium/net/urlconnection/CronetHttpURLConnection.java b/components/cronet/android/java/src/org/chromium/net/urlconnection/CronetHttpURLConnection.java
index 8726e2aa237b39ec10109021cb70b5ad917c95a4..5bbf6d6f25fc3e2dcfd735e4e5cbb2c613c5e810 100644
--- a/components/cronet/android/java/src/org/chromium/net/urlconnection/CronetHttpURLConnection.java
+++ b/components/cronet/android/java/src/org/chromium/net/urlconnection/CronetHttpURLConnection.java
@@ -8,11 +8,10 @@ import android.util.Pair;
import org.chromium.base.Log;
import org.chromium.net.CronetEngine;
-import org.chromium.net.ExtendedResponseInfo;
-import org.chromium.net.ResponseInfo;
import org.chromium.net.UrlRequest;
import org.chromium.net.UrlRequestException;
import org.chromium.net.UrlRequestListener;
+import org.chromium.net.UrlResponseInfo;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -43,7 +42,7 @@ class CronetHttpURLConnection extends HttpURLConnection {
private CronetInputStream mInputStream;
private CronetOutputStream mOutputStream;
- private ResponseInfo mResponseInfo;
+ private UrlResponseInfo mResponseInfo;
private UrlRequestException mException;
private boolean mOnRedirectCalled = false;
private boolean mHasResponse = false;
@@ -141,11 +140,11 @@ class CronetHttpURLConnection extends HttpURLConnection {
*/
@Override
public final String getHeaderFieldKey(int pos) {
- Pair<String, String> header = getHeaderFieldPair(pos);
+ Map.Entry<String, String> header = getHeaderFieldEntry(pos);
if (header == null) {
return null;
}
- return header.first;
+ return header.getKey();
}
/**
@@ -154,11 +153,11 @@ class CronetHttpURLConnection extends HttpURLConnection {
*/
@Override
public final String getHeaderField(int pos) {
- Pair<String, String> header = getHeaderFieldPair(pos);
+ Map.Entry<String, String> header = getHeaderFieldEntry(pos);
if (header == null) {
return null;
}
- return header.second;
+ return header.getValue();
}
/**
@@ -422,22 +421,22 @@ class CronetHttpURLConnection extends HttpURLConnection {
}
@Override
- public void onResponseStarted(UrlRequest request, ResponseInfo info) {
+ public void onResponseStarted(UrlRequest request, UrlResponseInfo info) {
mResponseInfo = info;
// Quits the message loop since we have the headers now.
mMessageLoop.quit();
}
@Override
- public void onReadCompleted(UrlRequest request, ResponseInfo info,
- ByteBuffer byteBuffer) {
+ public void onReadCompleted(
+ UrlRequest request, UrlResponseInfo info, ByteBuffer byteBuffer) {
mResponseInfo = info;
mMessageLoop.quit();
}
@Override
- public void onReceivedRedirect(UrlRequest request, ResponseInfo info,
- String newLocationUrl) {
+ public void onReceivedRedirect(
+ UrlRequest request, UrlResponseInfo info, String newLocationUrl) {
mOnRedirectCalled = true;
if (instanceFollowRedirects) {
try {
@@ -454,14 +453,14 @@ class CronetHttpURLConnection extends HttpURLConnection {
}
@Override
- public void onSucceeded(UrlRequest request, ExtendedResponseInfo info) {
- mResponseInfo = info.getResponseInfo();
+ public void onSucceeded(UrlRequest request, UrlResponseInfo info) {
+ mResponseInfo = info;
setResponseDataCompleted();
}
@Override
- public void onFailed(UrlRequest request, ResponseInfo info,
- UrlRequestException exception) {
+ public void onFailed(
+ UrlRequest request, UrlResponseInfo info, UrlRequestException exception) {
if (exception == null) {
throw new IllegalStateException(
"Exception cannot be null in onFailed.");
@@ -522,14 +521,13 @@ class CronetHttpURLConnection extends HttpURLConnection {
/**
* Helper method to return the response header field at position pos.
*/
- private Pair<String, String> getHeaderFieldPair(int pos) {
+ private Map.Entry<String, String> getHeaderFieldEntry(int pos) {
try {
getResponse();
} catch (IOException e) {
return null;
}
- List<Pair<String, String>> headers =
- mResponseInfo.getAllHeadersAsList();
+ List<Map.Entry<String, String>> headers = mResponseInfo.getAllHeadersAsList();
if (pos >= headers.size()) {
return null;
}

Powered by Google App Engine
This is Rietveld 408576698