Known Direct Subclasses |
An abstract Cronet callback that reads the entire body to memory and optionally deserializes the body before passing it back to the issuer of the HTTP request.
The requester can subscribe for updates about the request by adding completion mListeners on the callback. When the request reaches a terminal state, the mListeners are informed in order of addition.
Public Constructor Summary
Public Method Summary
ImplicitFlowControlCallback |
addCompletionListener(CronetRequestCompletionListener<? super T> listener)
Adds a completion listener.
|
Protected Method Summary
final void |
onBodyChunkRead(UrlResponseInfo info, ByteBuffer bodyChunk)
Invoked whenever part of the response body has been read.
|
final void | |
final void |
onFailed(UrlResponseInfo info, CronetException exception)
Invoked if request failed for any reason after
UrlRequest.start() . |
final void |
onResponseStarted(UrlResponseInfo info)
Invoked when the final set of headers, after all redirects, is received.
|
final void | |
abstract T |
transformBodyBytes(UrlResponseInfo info, byte[] bodyBytes)
Transforms (deserializes) the plain full body into a user-defined object.
|
Inherited Method Summary
abstract void |
onBodyChunkRead(UrlResponseInfo info, ByteBuffer bodyChunk)
Invoked whenever part of the response body has been read.
|
abstract void | |
final void |
onCanceled(UrlRequest request, UrlResponseInfo info)
Invoked if request was canceled via
UrlRequest.cancel() . |
final void |
onFailed(UrlRequest request, UrlResponseInfo info, CronetException error)
Invoked if request failed for any reason after
UrlRequest.start() . |
abstract void |
onFailed(UrlResponseInfo info, CronetException exception)
Invoked if request failed for any reason after
UrlRequest.start() . |
final void |
onReadCompleted(UrlRequest request, UrlResponseInfo info, ByteBuffer byteBuffer)
Invoked whenever part of the response body has been read.
|
final void |
onRedirectReceived(UrlRequest request, UrlResponseInfo info, String newLocationUrl)
Invoked whenever a redirect is encountered.
|
abstract void |
onResponseStarted(UrlResponseInfo info)
Invoked when the final set of headers, after all redirects, is received.
|
final void |
onResponseStarted(UrlRequest request, UrlResponseInfo info)
Invoked when the final set of headers, after all redirects, is received.
|
final void |
onSucceeded(UrlRequest request, UrlResponseInfo info)
Invoked when request is completed successfully.
|
abstract void | |
abstract boolean |
shouldFollowRedirect(UrlResponseInfo info, String newLocationUrl)
Invoked whenever a redirect is encountered.
|
void |
onCanceled(UrlRequest request, UrlResponseInfo info)
Invoked if request was canceled via
UrlRequest.cancel() . |
abstract void |
onFailed(UrlRequest request, UrlResponseInfo info, CronetException error)
Invoked if request failed for any reason after
UrlRequest.start() . |
abstract void |
onReadCompleted(UrlRequest request, UrlResponseInfo info, ByteBuffer byteBuffer)
Invoked whenever part of the response body has been read.
|
abstract void |
onRedirectReceived(UrlRequest request, UrlResponseInfo info, String newLocationUrl)
Invoked whenever a redirect is encountered.
|
abstract void |
onResponseStarted(UrlRequest request, UrlResponseInfo info)
Invoked when the final set of headers, after all redirects, is received.
|
abstract void |
onSucceeded(UrlRequest request, UrlResponseInfo info)
Invoked when request is completed successfully.
|
Object |
clone()
|
boolean |
equals(Object arg0)
|
void |
finalize()
|
final Class<?> |
getClass()
|
int |
hashCode()
|
final void |
notify()
|
final void |
notifyAll()
|
String |
toString()
|
final void |
wait(long arg0, int arg1)
|
final void |
wait(long arg0)
|
final void |
wait()
|
Public Constructors
public InMemoryTransformCronetCallback ()
Public Methods
public ImplicitFlowControlCallback addCompletionListener (CronetRequestCompletionListener<? super T> listener)
Adds a completion listener. All listeners are informed when the request reaches a terminal state, in order of addition. If a listener is added multiple times, it will only be called once according to the first time it was added.
Parameters
listener |
---|
See Also
Protected Methods
protected final void onBodyChunkRead (UrlResponseInfo info, ByteBuffer bodyChunk)
Invoked whenever part of the response body has been read. Only part of the buffer may be populated, even if the entire response body has not yet been consumed. The buffer is ready for reading. Buffers are reused internally so the implementing class shouldn't store the buffer or use it anywhere else than in the implementation of this method.
Parameters
info | Response information. |
---|---|
bodyChunk | The buffer that contains the received data, flipped for reading. |
Throws
Exception |
---|
protected final void onCanceled (UrlResponseInfo info)
Invoked if request was canceled via UrlRequest.cancel()
. Once invoked, no other UrlRequest.Callback
methods will be invoked.
Parameters
info | Response information. May be null if no response was received.
|
---|
protected final void onFailed (UrlResponseInfo info, CronetException exception)
Invoked if request failed for any reason after UrlRequest.start()
. Once invoked, no
other
UrlRequest.Callback
methods will be invoked. error
provides information about
the failure.
Parameters
info | Response information. May be null if no response was received. |
---|---|
exception | information about error. |
protected final void onResponseStarted (UrlResponseInfo info)
Invoked when the final set of headers, after all redirects, is received. Will only be invoked once for each request. It's guaranteed that Cronet doesn't start reading the body until this method returns.
Parameters
info | Response information. |
---|
protected final void onSucceeded (UrlResponseInfo info)
Invoked when request is completed successfully. Once invoked, no other UrlRequest.Callback
methods will be invoked.
Parameters
info | Response information. |
---|
protected abstract T transformBodyBytes (UrlResponseInfo info, byte[] bodyBytes)
Transforms (deserializes) the plain full body into a user-defined object.
It is assumed that the implementing classes handle edge cases (such as empty and malformed bodies) appropriately. Cronet doesn't inspects the objects and passes them (or any exceptions) along to the issuer of the request.
Parameters
info | |
---|---|
bodyBytes |