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

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

Issue 1307863006: [Cronet] Change interface APIs to abstract classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.net; 5 package org.chromium.net;
6 6
7 import java.io.IOException; 7 import java.io.IOException;
8 import java.nio.ByteBuffer; 8 import java.nio.ByteBuffer;
9 9
10 /** 10 /**
11 * Interface allowing the embedder to provide an upload body to 11 * Interface allowing the embedder to provide an upload body to
xunjieli 2015/09/03 04:32:02 nit: s/Interface/Abstract class
pauljensen 2015/09/11 15:20:41 Done.
12 * {@link UrlRequest}. It supports both non-chunked (size known in advanced) and 12 * {@link UrlRequest}. It supports both non-chunked (size known in advanced) and
13 * chunked (size not known in advance) uploads. Be aware that not all servers 13 * chunked (size not known in advance) uploads. Be aware that not all servers
14 * support chunked uploads. 14 * support chunked uploads.
15 * 15 *
16 * <p>An upload is either always chunked, across multiple uploads if the data 16 * <p>An upload is either always chunked, across multiple uploads if the data
17 * ends up being sent more than once, or never chunked. 17 * ends up being sent more than once, or never chunked.
18 */ 18 */
19 public interface UploadDataProvider { 19 public abstract class UploadDataProvider {
xunjieli 2015/09/03 04:32:02 Although the guideline says we should *always* pre
pauljensen 2015/09/11 15:20:41 I'm just trying to future-proof us. I could image
20 /** 20 /**
21 * If this is a non-chunked upload, returns the length of the upload. Must 21 * If this is a non-chunked upload, returns the length of the upload. Must
22 * always return -1 if this is a chunked upload. 22 * always return -1 if this is a chunked upload.
23 * @return the length of the upload for non-chunked uploads, -1 otherwise. 23 * @return the length of the upload for non-chunked uploads, -1 otherwise.
24 */ 24 */
25 public long getLength(); 25 public abstract long getLength();
26 26
27 /** 27 /**
28 * Reads upload data into {@code byteBuffer}. Upon completion, the buffer's 28 * Reads upload data into {@code byteBuffer}. Upon completion, the buffer's
29 * position is updated to the end of the bytes that were read. The buffer's 29 * position is updated to the end of the bytes that were read. The buffer's
30 * limit is not changed. Each call of this method must be followed be a 30 * limit is not changed. Each call of this method must be followed be a
31 * single call, either synchronous or asynchronous, to 31 * single call, either synchronous or asynchronous, to
32 * {@code uploadDataSink}: {@link UploadDataSink#onReadSucceeded} on success 32 * {@code uploadDataSink}: {@link UploadDataSink#onReadSucceeded} on success
33 * or {@link UploadDataSink#onReadError} on failure. Neither read nor rewind 33 * or {@link UploadDataSink#onReadError} on failure. Neither read nor rewind
34 * will be called until one of those methods or the other is called. Even if 34 * will be called until one of those methods or the other is called. Even if
35 * the associated {@link UrlRequest} is cancelled, one or the other must 35 * the associated {@link UrlRequest} is cancelled, one or the other must
36 * still be called before resources can be safely freed. Throwing an 36 * still be called before resources can be safely freed. Throwing an
37 * exception will also result in resources being freed and the request being 37 * exception will also result in resources being freed and the request being
38 * errored out. 38 * errored out.
39 * 39 *
40 * @param uploadDataSink The object to notify when the read has completed, 40 * @param uploadDataSink The object to notify when the read has completed,
41 * successfully or otherwise. 41 * successfully or otherwise.
42 * @param byteBuffer The buffer to copy the read bytes into. 42 * @param byteBuffer The buffer to copy the read bytes into.
43 * @throws IOException if any IOException occurred during the process. 43 * @throws IOException if any IOException occurred during the process.
44 */ 44 */
45 public void read(UploadDataSink uploadDataSink, ByteBuffer byteBuffer) 45 public abstract void read(UploadDataSink uploadDataSink, ByteBuffer byteBuff er)
46 throws IOException; 46 throws IOException;
47 47
48 /** 48 /**
49 * Rewinds upload data. Each call must be followed be a single 49 * Rewinds upload data. Each call must be followed be a single
50 * call, either synchronous or asynchronous, to {@code uploadDataSink}: 50 * call, either synchronous or asynchronous, to {@code uploadDataSink}:
51 * {@link UploadDataSink#onRewindSucceeded} on success or 51 * {@link UploadDataSink#onRewindSucceeded} on success or
52 * {@link UploadDataSink#onRewindError} on failure. Neither read nor rewind 52 * {@link UploadDataSink#onRewindError} on failure. Neither read nor rewind
53 * will be called until one of those methods or the other is called. 53 * will be called until one of those methods or the other is called.
54 * Even if the associated {@link UrlRequest} is cancelled, one or the other 54 * Even if the associated {@link UrlRequest} is cancelled, one or the other
55 * must still be called before resources can be safely freed. Throwing an 55 * must still be called before resources can be safely freed. Throwing an
56 * exception will also result in resources being freed and the request being 56 * exception will also result in resources being freed and the request being
57 * errored out. 57 * errored out.
58 * 58 *
59 * <p>If rewinding is not supported, this should call 59 * <p>If rewinding is not supported, this should call
60 * {@link UploadDataSink#onRewindError}. Note that rewinding is required to 60 * {@link UploadDataSink#onRewindError}. Note that rewinding is required to
61 * follow redirects that preserve the upload body, and for retrying when the 61 * follow redirects that preserve the upload body, and for retrying when the
62 * server times out stale sockets. 62 * server times out stale sockets.
63 * 63 *
64 * @param uploadDataSink The object to notify when the rewind operation has 64 * @param uploadDataSink The object to notify when the rewind operation has
65 * completed, successfully or otherwise. 65 * completed, successfully or otherwise.
66 * @throws IOException if any IOException occurred during the process. 66 * @throws IOException if any IOException occurred during the process.
67 */ 67 */
68 public void rewind(UploadDataSink uploadDataSink) 68 public abstract void rewind(UploadDataSink uploadDataSink) throws IOExceptio n;
69 throws IOException;
70 } 69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698