Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 java.util.ArrayList; | 7 import java.util.ArrayList; |
| 8 import java.util.Collections; | 8 import java.util.Collections; |
| 9 import java.util.List; | 9 import java.util.List; |
| 10 import java.util.Locale; | 10 import java.util.Locale; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 values.addAll(map.get(entry.getKey())); | 69 values.addAll(map.get(entry.getKey())); |
| 70 } | 70 } |
| 71 values.add(entry.getValue()); | 71 values.add(entry.getValue()); |
| 72 map.put(entry.getKey(), Collections.unmodifiableList(values)); | 72 map.put(entry.getKey(), Collections.unmodifiableList(values)); |
| 73 } | 73 } |
| 74 mHeadersMap = Collections.unmodifiableMap(map); | 74 mHeadersMap = Collections.unmodifiableMap(map); |
| 75 return mHeadersMap; | 75 return mHeadersMap; |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 UrlResponseInfo(List<String> urlChain, int httpStatusCode, String httpStatus Text, | 79 /** |
| 80 * Creates a {@link UrlResponseInfo} object. Provied to facilitate testing. | |
|
mef
2015/10/30 15:24:19
Provied -> Provided or Public?
pauljensen
2015/10/30 15:29:19
Done.
| |
| 81 * | |
| 82 * @param urlChain the URL chain. The first entry is the origianlly requeste d URL; | |
|
mef
2015/10/30 15:24:19
origianlly
pauljensen
2015/10/30 15:29:19
Done.
| |
| 83 * the following entries are redirects followed. | |
| 84 * @param httpStatusCode the HTTP status code. | |
| 85 * @param httpStatusText the HTTP status text of the status line. | |
| 86 * @param allHeadersList list of response header field and value pairs. | |
| 87 * @param wasCached {@code true} if the response came from the cache, {@code false} | |
| 88 * otherwise. | |
| 89 * @param negotiatedProtocol the protocol negotiated with the server. | |
| 90 * @param proxyServer the proxy server that was used for the request. | |
| 91 */ | |
| 92 public UrlResponseInfo(List<String> urlChain, int httpStatusCode, String htt pStatusText, | |
| 80 List<Map.Entry<String, String>> allHeadersList, boolean wasCached, | 93 List<Map.Entry<String, String>> allHeadersList, boolean wasCached, |
| 81 String negotiatedProtocol, String proxyServer) { | 94 String negotiatedProtocol, String proxyServer) { |
| 82 mResponseInfoUrlChain = Collections.unmodifiableList(urlChain); | 95 mResponseInfoUrlChain = Collections.unmodifiableList(urlChain); |
| 83 mHttpStatusCode = httpStatusCode; | 96 mHttpStatusCode = httpStatusCode; |
| 84 mHttpStatusText = httpStatusText; | 97 mHttpStatusText = httpStatusText; |
| 85 mHeaders = new HeaderBlock(Collections.unmodifiableList(allHeadersList)) ; | 98 mHeaders = new HeaderBlock(Collections.unmodifiableList(allHeadersList)) ; |
| 86 mWasCached = wasCached; | 99 mWasCached = wasCached; |
| 87 mNegotiatedProtocol = negotiatedProtocol; | 100 mNegotiatedProtocol = negotiatedProtocol; |
| 88 mProxyServer = proxyServer; | 101 mProxyServer = proxyServer; |
| 89 mReceivedBytesCount = new AtomicLong(); | 102 mReceivedBytesCount = new AtomicLong(); |
| 90 } | 103 } |
| 91 | 104 |
| 92 /** | 105 /** |
| 93 * Returns the URL the response is for. This is the URL after following | 106 * Returns the URL the response is for. This is the URL after following |
| 94 * redirects, so it may not be the originally requested URL. | 107 * redirects, so it may not be the originally requested URL. |
| 95 * @return the URL the response is for. | 108 * @return the URL the response is for. |
| 96 */ | 109 */ |
| 97 public String getUrl() { | 110 public String getUrl() { |
| 98 return mResponseInfoUrlChain.get(mResponseInfoUrlChain.size() - 1); | 111 return mResponseInfoUrlChain.get(mResponseInfoUrlChain.size() - 1); |
| 99 } | 112 } |
| 100 | 113 |
| 101 /** | 114 /** |
| 102 * Returns the URL chain. The first entry is the origianlly requested URL; | 115 * Returns the URL chain. The first entry is the origianlly requested URL; |
|
mef
2015/10/30 15:24:19
origianlly -> originally
pauljensen
2015/10/30 15:29:19
Done.
| |
| 103 * the following entries are redirects followed. | 116 * the following entries are redirects followed. |
| 104 * @return the URL chain. | 117 * @return the URL chain. |
| 105 */ | 118 */ |
| 106 public List<String> getUrlChain() { | 119 public List<String> getUrlChain() { |
| 107 return mResponseInfoUrlChain; | 120 return mResponseInfoUrlChain; |
| 108 } | 121 } |
| 109 | 122 |
| 110 /** | 123 /** |
| 111 * Returns the HTTP status code. When a resource is retrieved from the cache , | 124 * Returns the HTTP status code. When a resource is retrieved from the cache , |
| 112 * whether it was revalidated or not, the original status code is returned. | 125 * whether it was revalidated or not, the original status code is returned. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 getUrl(), getUrlChain().toString(), getHttpStatusCode(), getHttp StatusText(), | 211 getUrl(), getUrlChain().toString(), getHttpStatusCode(), getHttp StatusText(), |
| 199 getAllHeadersAsList().toString(), wasCached(), getNegotiatedProt ocol(), | 212 getAllHeadersAsList().toString(), wasCached(), getNegotiatedProt ocol(), |
| 200 getProxyServer(), getReceivedBytesCount()); | 213 getProxyServer(), getReceivedBytesCount()); |
| 201 } | 214 } |
| 202 | 215 |
| 203 // Sets mReceivedBytesCount. Must not be called after request completion or cancellation. | 216 // Sets mReceivedBytesCount. Must not be called after request completion or cancellation. |
| 204 void setReceivedBytesCount(long currentReceivedBytesCount) { | 217 void setReceivedBytesCount(long currentReceivedBytesCount) { |
| 205 mReceivedBytesCount.set(currentReceivedBytesCount); | 218 mReceivedBytesCount.set(currentReceivedBytesCount); |
| 206 } | 219 } |
| 207 } | 220 } |
| OLD | NEW |