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

Side by Side Diff: components/cronet/android/java/src/org/chromium/net/UploadDataProvider.java

Issue 849903002: [Cronet] Upload support for async APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 * Interface allowing the embedder to provide an upload body to UrlRequest.
11 * It supports both non-chunked (size known in advanced) and chunked (size not
12 * known in advance) uploads. Be aware that not all servers support chunked
13 * uploads.
14 *
15 * An upload is either always chunked, across multiple uploads if the data ends
miloslav 2015/02/17 18:14:01 Need to insert <p> in the beginning of paragraphs.
xunjieli 2015/02/19 14:59:09 Done.
16 * up being sent more than once, or never chunked.
17 */
18 public interface UploadDataProvider {
19 /**
20 * @return if this is a non-chunked upload, returns the length of the
21 * upload. Must always return -1 if this is a chunked upload.
22 */
23 public long getLength();
24
25 /**
26 * Reads upload data into {@code byteBuffer}. Upon completion, the buffer's
27 * position is updated to the end of the bytes that were read. The buffer's
28 * limit is not changed. Each call of this method must be followed be a
29 * single call, either synchronous or asynchronous, to
30 * {@code uploadDataSink}: {@link #onReadSucceeded} on success or
pauljensen 2015/02/17 15:55:40 Do these @links work? I thought you could drop th
xunjieli 2015/02/17 17:56:07 Done. You are right, It should be prefixed by clas
31 * {@link #onReadError} on failure. Neither read nor rewind
32 * will be called until one of those methods or the other is called. Even if
33 * the associated {@link UrlRequest} is cancelled, one or the other must
34 * still be called before resources can be safely freed. Throwing an
35 * exception will also result in resources being freed and the request being
36 * cancelled.
37 *
38 * @param uploadDataSink The object to notify when the read has completed,
39 * successfully or otherwise.
40 * @param byteBuffer The buffer to copy the read bytes into.
41 */
42 public void read(UploadDataSink uploadDataSink, ByteBuffer byteBuffer);
miloslav 2015/02/17 18:14:00 Maybe returning an int code instead of having to c
mmenke 2015/02/17 20:25:49 I'm very reluctant to force embedders to use a blo
mmenke 2015/02/17 20:29:33 Oh, and I'm fine with adding "throws IOException".
43
44 /**
45 * Rewinds upload data. Each call must be followed be a single
46 * call, either synchronous or asynchronous, to {@code uploadDataSink}:
47 * {@link #onRewindSucceeded} on success or {@link #onRewindError} on
48 * failure. Neither read nor rewind will be called until one of those
49 * methods or the other is called. Even if the associated {@link UrlRequest}
50 * is cancelled, one or the other must still be called before resources can
51 * be safely freed. Throwing an exception will also result in resources
52 * being freed and the request being cancelled.
53 *
54 * If rewinding is not supported, this should call {@link #onRewindError}.
miloslav 2015/02/17 18:14:01 <p>
xunjieli 2015/02/19 14:59:09 Done.
55 * Note that rewinding is required to follow redirects that preserve the
56 * upload body, and for retrying when the server times out stale sockets.
57 *
58 * @param uploadDataSink The object to notify when the rewind operation has
59 * completed, successfully or otherwise.
60 */
61 public void rewind(UploadDataSink uploadDataSink);
miloslav 2015/02/17 18:14:01 Similarly, maybe throws an IOException and returni
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698