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..b20d2ea0554ef5540b9198b7790f0ceb41de0671 |
--- /dev/null |
+++ b/components/cronet/android/java/src/org/chromium/net/AsyncUrlRequestListener.java |
@@ -0,0 +1,62 @@ |
+// 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 |
mmenke
2014/09/03 21:19:20
Looper -> Executor
mef
2014/09/03 21:55:39
Done.
|
+ * 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 Request being redirected |
+ * @param info Response information. |
+ * @param new_location Location where request is redirected |
mmenke
2014/09/03 21:19:20
nit: +period
mef
2014/09/03 21:55:39
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 whenever data is received. The ByteBuffer remains |
+ * 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. |
+ * |
+ * @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. |
mmenke
2014/09/03 21:19:20
Remove comment about CronetError
mef
2014/09/03 21:55:39
Done.
|
+ * @param request |
+ * @param error |
+ */ |
+ public void onError(AsyncUrlRequest request, |
+ AsyncUrlRequestException error); |
+} |