Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / cronet / android / java / src / org / chromium / net / UrlRequestListener.java
1 // Copyright 2014 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 java.nio.ByteBuffer;
8
9 /**
10  * Note:  All methods will be called on the thread of the Executor used during
11  * construction of the UrlRequest.
12  */
13 public interface UrlRequestListener {
14     /**
15      * Called before following redirects.  The redirect will automatically be
16      * followed, unless the request is paused or cancelled during this
17      * callback.  If the redirect response has a body, it will be ignored.
18      * This will only be called between start and onResponseStarted.
19      *
20      * @param request Request being redirected.
21      * @param info Response information.
22      * @param newLocationUrl Location where request is redirected.
23      */
24     public void onRedirect(UrlRequest request,
25             ResponseInfo info,
26             String newLocationUrl);
27
28     /**
29      * Called when the final set of headers, after all redirects,
30      * is received. Can only be called once for each request.
31      *
32      * @param request Request that started to get response.
33      * @param info Response information.
34      */
35     public void onResponseStarted(UrlRequest request, ResponseInfo info);
36
37     /**
38      * Called whenever data is received.  The ByteBuffer remains
39      * valid only for the duration of the callback.  Or if the callback
40      * pauses the request, it remains valid until the request is resumed.
41      * Cancelling the request also invalidates the buffer.
42      *
43      * @param request Request that received data.
44      * @param info Response information.
45      * @param byteBuffer Received data.
46      */
47     public void onDataReceived(UrlRequest request,
48             ResponseInfo info,
49             ByteBuffer byteBuffer);
50
51     /**
52      * Called when request is completed successfully, no callbacks will be
53      * called afterwards.
54      *
55      * @param request Request that succeeded.
56      * @param info Response information.
57      */
58     public void onSucceeded(UrlRequest request, ExtendedResponseInfo info);
59
60     /**
61      * Called if request failed for any reason after start().  Once
62      * called, no other functions can be called.  UrlRequestException
63      * provides information about error.
64      *
65      * @param request Request that failed.
66      * @param info Response information.
67      * @param error information about error.
68      */
69     public void onFailed(UrlRequest request,
70             ResponseInfo info,
71             UrlRequestException error);
72 }