Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1428)

Unified Diff: components/cronet/android/java/src/org/chromium/net/AsyncUrlRequestListener.java

Issue 520093002: Initial declaration of Cronet Async API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments, add to cronet.gyp Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
+}

Powered by Google App Engine
This is Rietveld 408576698