Index: components/cronet/android/java/src/org/chromium/net/AsyncUrlRequestListener.java |
diff --git a/components/cronet/android/java/src/org/chromium/net/AsyncUrlRequestListener.java b/components/cronet/android/java/src/org/chromium/net/AsyncUrlRequestListener.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..67d9150d2819d7f09ed26c77fb747c2f98bf9943 |
--- /dev/null |
+++ b/components/cronet/android/java/src/org/chromium/net/AsyncUrlRequestListener.java |
@@ -0,0 +1,85 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.net; |
+ |
+import java.net.URL; |
+import java.nio.ByteBuffer; |
+ |
+/** |
+ * Note: All methods will be called on the thread of the Looper used during |
+ * construction of the AsyncUrlRequest. |
+ */ |
+public abstract interface AsyncUrlRequestListener { |
+ /** |
+ * Called before following redirects. The redirect will automatically be |
+ * followed, unless the request is paused or cancelled during this |
+ * callback. If the redirect response has a body, it will be ignored. |
+ * This will only be called between start and onResponseStarted. |
+ * @param request |
+ * @param info |
+ * @param new_location |
mmenke
2014/09/02 19:48:04
Should we add documentation now?
mef
2014/09/03 20:58:58
Done.
|
+ */ |
+ public void onRedirect(AsyncUrlRequest request, ResponseInfo info, |
+ URL new_location); |
+ |
+ /** |
+ * Called when the final set of headers, after all redirects, |
+ * is received. Can only be called once for each request. |
+ * @param request |
+ * @param info |
+ */ |
+ public void onResponseStarted(AsyncUrlRequest request, ResponseInfo info); |
+ |
+ /** |
+ * Called for each chunk of data that’s received. The ByteBuffer remains |
mmenke
2014/09/02 19:48:03
nit: --chunk.
Maybe "called whenever data is rec
mef
2014/09/03 20:58:58
Done.
|
+ * valid only for the duration of the callback. Or if the callback |
+ * pauses the request, it remains valid until the request is resumed. |
+ * Cancelling the request also invalidates the buffer. |
+ |
mmenke
2014/09/02 19:48:04
*
mef
2014/09/03 20:58:58
Done.
|
+ * @param request |
+ * @param byteBuffer |
+ */ |
+ public void onDataReceived(AsyncUrlRequest request, ByteBuffer byteBuffer); |
+ |
+ /** |
+ * Called when request is complete, no callbacks will be called afterwards. |
+ * @param request |
+ */ |
+ public void onComplete(AsyncUrlRequest request); |
+ |
+ /** |
+ * Can be called at any point between start() and onComplete(). Once |
+ * called, no other functions can be called. CronetError just provide a |
+ * raw numeric error code, and a string version of the error. |
+ * @param request |
+ * @param error |
+ */ |
+ public void onError(AsyncUrlRequest request, |
+ AsyncUrlRequestException error); |
+ |
+ /** |
+ * Streaming upload functions. Note: Could optionally put these in |
+ * another class. |
+ */ |
+ |
+ /** |
+ * Called when the AsyncUrlRequest using a streaming upload body has |
+ * uploaded all of the previously appended upload data. The request can |
+ * not continue until the embedder appends more of the body to the |
+ * request, or tells the request that the upload is complete. |
+ * @param request |
+ */ |
+ public void needUploadData(AsyncUrlRequest request); |
+ |
+ /** |
+ * Tells the listener to restarts the request body. All previously |
+ * appended data will be discarded. Used in the case of retries and |
+ * redirects. Must return false if rewinding is not supported. In that |
+ * case the request will fail with an error code (Exact error code TBD). |
+ * @param request |
+ * @return |
+ */ |
+ public boolean rewindUploadData(AsyncUrlRequest request); |
mmenke
2014/09/02 19:48:04
Again, let's get rid of these two upload functions
mef
2014/09/03 20:58:58
Done.
|
+} |