RequestFinishedInfo

public abstract class RequestFinishedInfo


Information about a finished request. Passed to RequestFinishedInfo.Listener.

To associate the data with the original request, use addRequestAnnotation to add a unique identifier when creating the request, and call getAnnotations when the RequestFinishedInfo is received to retrieve the identifier.

Summary

Nested types

public abstract class RequestFinishedInfo.Listener

Listens for finished requests for the purpose of collecting metrics.

public abstract class RequestFinishedInfo.Metrics

Metrics collected for a single request.

Constants

static final int

Reason value indicating that the request was canceled.

static final int
FAILED = 1

Reason value indicating that the request failed or returned an error.

static final int

Reason value indicating that the request succeeded.

Public constructors

Public methods

abstract Collection<Object>

Returns the objects that the caller has supplied when initiating the request, using addRequestAnnotation.

abstract @Nullable CronetException

If the request failed, returns the same CronetException provided to onFailed.

abstract int

Returns the reason why the request finished.

abstract RequestFinishedInfo.Metrics

Returns metrics collected for this request.

abstract @Nullable UrlResponseInfo

Returns a UrlResponseInfo for the request, if its response had started.

abstract String

Returns the request's original URL.

Constants

CANCELED

public static final int CANCELED = 2

Reason value indicating that the request was canceled. Returned from getFinishedReason.

FAILED

public static final int FAILED = 1

Reason value indicating that the request failed or returned an error. Returned from getFinishedReason.

SUCCEEDED

public static final int SUCCEEDED = 0

Reason value indicating that the request succeeded. Returned from getFinishedReason.

Public constructors

RequestFinishedInfo

public RequestFinishedInfo()

Public methods

getAnnotations

public abstract Collection<ObjectgetAnnotations()

Returns the objects that the caller has supplied when initiating the request, using addRequestAnnotation. Annotations can be used to associate a RequestFinishedInfo with the original request or type of request.

Returns
Collection<Object>

annotations supplied when creating the request

getException

public abstract @Nullable CronetException getException()

If the request failed, returns the same CronetException provided to onFailed.

Returns
@Nullable CronetException

the request's CronetException, if the request failed

getFinishedReason

public abstract int getFinishedReason()

Returns the reason why the request finished.

Returns
int

one of SUCCEEDED, FAILED, or CANCELED

getMetrics

public abstract RequestFinishedInfo.Metrics getMetrics()

Returns metrics collected for this request.

The reported times and bytes account for all redirects, i.e. the TTFB is from the start of the original request to the ultimate response headers, the TTLB is from the start of the original request to the end of the ultimate response, the received byte count is for all redirects and the ultimate response combined. These cumulative metric definitions are debatable, but are chosen to make sense for user-facing latency analysis.

Returns
RequestFinishedInfo.Metrics

metrics collected for this request.

getResponseInfo

public abstract @Nullable UrlResponseInfo getResponseInfo()

Returns a UrlResponseInfo for the request, if its response had started.

Returns
@Nullable UrlResponseInfo

UrlResponseInfo for the request, if its response had started.

getUrl

public abstract String getUrl()

Returns the request's original URL.

Returns
String

the request's original URL