| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 * Each list of values for a single header field is in the same order th
ey | 54 * Each list of values for a single header field is in the same order th
ey |
| 55 * were received over the wire. | 55 * were received over the wire. |
| 56 * | 56 * |
| 57 * @return an unmodifiable map from response-header field names to lists
of values | 57 * @return an unmodifiable map from response-header field names to lists
of values |
| 58 */ | 58 */ |
| 59 public Map<String, List<String>> getAsMap() { | 59 public Map<String, List<String>> getAsMap() { |
| 60 // This is potentially racy...but races will only result in wasted r
esource. | 60 // This is potentially racy...but races will only result in wasted r
esource. |
| 61 if (mHeadersMap != null) { | 61 if (mHeadersMap != null) { |
| 62 return mHeadersMap; | 62 return mHeadersMap; |
| 63 } | 63 } |
| 64 Map<String, List<String>> map = | 64 Map<String, List<String>> map = new TreeMap<>(String.CASE_INSENSITIV
E_ORDER); |
| 65 new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_OR
DER); | |
| 66 for (Map.Entry<String, String> entry : mAllHeadersList) { | 65 for (Map.Entry<String, String> entry : mAllHeadersList) { |
| 67 List<String> values = new ArrayList<String>(); | 66 List<String> values = new ArrayList<String>(); |
| 68 if (map.containsKey(entry.getKey())) { | 67 if (map.containsKey(entry.getKey())) { |
| 69 values.addAll(map.get(entry.getKey())); | 68 values.addAll(map.get(entry.getKey())); |
| 70 } | 69 } |
| 71 values.add(entry.getValue()); | 70 values.add(entry.getValue()); |
| 72 map.put(entry.getKey(), Collections.unmodifiableList(values)); | 71 map.put(entry.getKey(), Collections.unmodifiableList(values)); |
| 73 } | 72 } |
| 74 mHeadersMap = Collections.unmodifiableMap(map); | 73 mHeadersMap = Collections.unmodifiableMap(map); |
| 75 return mHeadersMap; | 74 return mHeadersMap; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 * progresses until completion, when {@link UrlRequest.Callback#onSucceeded
onSucceeded()}, | 197 * progresses until completion, when {@link UrlRequest.Callback#onSucceeded
onSucceeded()}, |
| 199 * {@link UrlRequest.Callback#onFailed onFailed()}, or | 198 * {@link UrlRequest.Callback#onFailed onFailed()}, or |
| 200 * {@link UrlRequest.Callback#onCanceled onCanceled()} is called. | 199 * {@link UrlRequest.Callback#onCanceled onCanceled()} is called. |
| 201 */ | 200 */ |
| 202 public long getReceivedBytesCount() { | 201 public long getReceivedBytesCount() { |
| 203 return mReceivedBytesCount.get(); | 202 return mReceivedBytesCount.get(); |
| 204 } | 203 } |
| 205 | 204 |
| 206 @Override | 205 @Override |
| 207 public String toString() { | 206 public String toString() { |
| 208 return String.format(Locale.ROOT, "UrlResponseInfo[%s]: urlChain = %s, " | 207 return String.format(Locale.ROOT, "UrlResponseInfo@[%s][%s]: urlChain =
%s, " |
| 209 + "httpStatus = %d %s, headers = %s, wasCached = %b, " | 208 + "httpStatus = %d %s, headers = %s, wasCached = %b, " |
| 210 + "negotiatedProtocol = %s, proxyServer= %s, receivedByt
esCount = %d", | 209 + "negotiatedProtocol = %s, proxyServer= %s, receivedByt
esCount = %d", |
| 211 getUrl(), getUrlChain().toString(), getHttpStatusCode(), getHttp
StatusText(), | 210 // Prevent asserting on the contents of this string |
| 211 Integer.toHexString(System.identityHashCode(this)), getUrl(), |
| 212 getUrlChain().toString(), getHttpStatusCode(), getHttpStatusText
(), |
| 212 getAllHeadersAsList().toString(), wasCached(), getNegotiatedProt
ocol(), | 213 getAllHeadersAsList().toString(), wasCached(), getNegotiatedProt
ocol(), |
| 213 getProxyServer(), getReceivedBytesCount()); | 214 getProxyServer(), getReceivedBytesCount()); |
| 214 } | 215 } |
| 215 | 216 |
| 216 // Sets mReceivedBytesCount. Must not be called after request completion or
cancellation. | 217 // Sets mReceivedBytesCount. Must not be called after request completion or
cancellation. |
| 217 void setReceivedBytesCount(long currentReceivedBytesCount) { | 218 void setReceivedBytesCount(long currentReceivedBytesCount) { |
| 218 mReceivedBytesCount.set(currentReceivedBytesCount); | 219 mReceivedBytesCount.set(currentReceivedBytesCount); |
| 219 } | 220 } |
| 220 } | 221 } |
| OLD | NEW |