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

Unified Diff: net/base/upload_element_reader.h

Issue 10910268: net: Make UploadDataStream::Read() asynchronous (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 2 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
« no previous file with comments | « net/base/upload_data_stream_unittest.cc ('k') | net/base/upload_element_reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/upload_element_reader.h
diff --git a/net/base/upload_element_reader.h b/net/base/upload_element_reader.h
index acb1ecabe4ac73089f80c6abc7e8a2b990a4a8d6..4ba973d61f065bb6e9e9a9cbd4c868e7d2f2db8f 100644
--- a/net/base/upload_element_reader.h
+++ b/net/base/upload_element_reader.h
@@ -11,6 +11,7 @@
namespace net {
+class IOBuffer;
class UploadElement;
// An interface to read an upload data element.
@@ -41,11 +42,18 @@ class NET_EXPORT UploadElementReader {
// The default implementation returns false.
virtual bool IsInMemory() const;
- // Reads up to |buf_length| bytes synchronously. Returns the number of bytes
- // read. This function never fails. If there's less data to read than we
- // initially observed, then pad with zero (this can happen with files).
- // |buf_length| must be greater than 0.
- virtual int ReadSync(char* buf, int buf_length) = 0;
+ // Reads up to |buf_length| bytes synchronously and returns the number of
+ // bytes read when possible, otherwise, returns ERR_IO_PENDING and runs
+ // |callback| with the result. This function never fails. If there's less data
+ // to read than we initially observed, then pad with zero (this can happen
+ // with files). |buf_length| must be greater than 0.
+ virtual int Read(IOBuffer* buf,
+ int buf_length,
+ const CompletionCallback& callback) = 0;
+
+ // Reads the data always synchronously.
+ // Use this method only if the thread is IO allowed or the data is in-memory.
+ virtual int ReadSync(IOBuffer* buf, int buf_length);
private:
DISALLOW_COPY_AND_ASSIGN(UploadElementReader);
« no previous file with comments | « net/base/upload_data_stream_unittest.cc ('k') | net/base/upload_element_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698