Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.net; | |
| 6 | |
| 7 import android.support.annotation.Nullable; | |
| 8 | |
| 9 import java.util.Collection; | |
| 10 | |
| 11 /** | |
| 12 * Information about a finished request. Passed to {@link RequestFinishedListene r}. | |
| 13 * | |
| 14 * {@hide} as it's a prototype. | |
| 15 */ | |
| 16 public final class RequestFinishedInfo { | |
|
xunjieli
2016/08/01 20:40:05
I like the new name! What do you think about movin
| |
| 17 private final String mUrl; | |
| 18 private final Collection<Object> mAnnotations; | |
| 19 private final UrlRequestMetrics mMetrics; | |
| 20 @Nullable | |
| 21 private final UrlResponseInfo mResponseInfo; | |
| 22 | |
| 23 /** | |
| 24 * @hide only used by internal implementation. | |
| 25 */ | |
| 26 public RequestFinishedInfo(String url, Collection<Object> annotations, | |
| 27 UrlRequestMetrics metrics, @Nullable UrlResponseInfo responseInfo) { | |
| 28 mUrl = url; | |
| 29 mAnnotations = annotations; | |
| 30 mMetrics = metrics; | |
| 31 mResponseInfo = responseInfo; | |
| 32 } | |
| 33 | |
| 34 /** Returns the request's original URL. */ | |
| 35 public String getUrl() { | |
| 36 return mUrl; | |
| 37 } | |
| 38 | |
| 39 /** Returns the objects that the caller has supplied when initiating the req uest. */ | |
| 40 public Collection<Object> getAnnotations() { | |
| 41 return mAnnotations; | |
| 42 } | |
| 43 | |
| 44 // TODO(klm): Collect and return a chain of Metrics objects for redirect res ponses. | |
| 45 /** | |
| 46 * Returns metrics collected for this request. | |
| 47 * | |
| 48 * <p>The reported times and bytes account for all redirects, i.e. | |
| 49 * the TTFB is from the start of the original request to the ultimate respon se headers, | |
| 50 * the TTLB is from the start of the original request to the end of the ulti mate response, | |
| 51 * the received byte count is for all redirects and the ultimate response co mbined. | |
| 52 * These cumulative metric definitions are debatable, but are chosen to make sense | |
| 53 * for user-facing latency analysis. | |
| 54 * | |
| 55 * <p>Must call {@link #enableNetworkQualityEstimator} to enable request met rics collection. | |
| 56 * @return metrics collected for this request. | |
| 57 */ | |
| 58 public UrlRequestMetrics getMetrics() { | |
| 59 return mMetrics; | |
| 60 } | |
| 61 | |
| 62 /** | |
| 63 * Returns a {@link UrlResponseInfo} for the request, if its response had st arted. | |
| 64 * @return {@link UrlResponseInfo} for the request, if its response had star ted. | |
| 65 */ | |
| 66 @Nullable | |
| 67 public UrlResponseInfo getResponseInfo() { | |
| 68 return mResponseInfo; | |
| 69 } | |
| 70 } | |
| OLD | NEW |