Chromium Code Reviews| Index: net/base/upload_data.h |
| diff --git a/net/base/upload_data.h b/net/base/upload_data.h |
| index 6f7216250a40c536a8cbdf1eba70c02d67fdb342..7bfbb8b523dbe83f52c63cb59eac843bd46b396b 100644 |
| --- a/net/base/upload_data.h |
| +++ b/net/base/upload_data.h |
| @@ -13,6 +13,7 @@ |
| #include "base/gtest_prod_util.h" |
| #include "base/ref_counted.h" |
| #include "googleurl/src/gurl.h" |
| +#include "net/base/completion_callback.h" |
| #include "base/time.h" |
| namespace net { |
| @@ -23,10 +24,22 @@ class UploadData : public base::RefCounted<UploadData> { |
| public: |
| enum Type { |
| TYPE_BYTES, |
| + TYPE_CHUNK, // More data is to come and this should be sent immediately. |
|
wtc
2011/01/14 03:09:31
The comment should say:
The data should be sent
Satish
2011/01/14 18:09:29
Done.
|
| TYPE_FILE, |
| TYPE_BLOB |
| }; |
| + // Interface implemented by callers who require callbacks when new chunks |
| + // of data are received. |
|
vandebo (ex-Chrome)
2011/01/14 05:53:44
Note, applies only for TYPE_CHUNK.
|
| + class ChunkCallback { |
| + public: |
| + // Invoked when a new data chunk was given for a chunked transfer upload. |
| + virtual void OnChunkAvailable() = 0; |
| + |
| + protected: |
| + virtual ~ChunkCallback() {} |
|
vandebo (ex-Chrome)
2011/01/14 05:53:44
Does this need an implementation? If so, shouldn'
|
| + }; |
| + |
| class Element { |
| public: |
| Element(); |
| @@ -72,6 +85,13 @@ class UploadData : public base::RefCounted<UploadData> { |
| blob_url_ = blob_url; |
| } |
| + // Though similar to bytes, a chunk indicates that the stream has more such |
| + // items after this item. |
|
wtc
2011/01/14 03:09:31
Again, the difference is that a chunk should be se
Satish
2011/01/14 18:09:29
Done.
|
| + void SetToChunk(const char* bytes, int bytes_len); |
| + |
| + // Identifies this element as the last item in a series of chunks. |
| + void SetToLastChunk(); |
| + |
| // Returns the byte-length of the element. For files that do not exist, 0 |
| // is returned. This is done for consistency with Mozilla. |
| // Once called, this function will always return the same value. |
| @@ -119,6 +139,16 @@ class UploadData : public base::RefCounted<UploadData> { |
| void AppendBlob(const GURL& blob_url); |
| + void AppendChunk(const char* bytes, int bytes_len); |
| + |
| + // Sets the callback to be invoked when a new chunk is available to upload. |
| + void set_chunk_callback(ChunkCallback* callback); |
| + |
| + // Iniitalizes the object to receive chunks of upload data over time rather |
| + // than all at once. |
| + void set_is_chunked(bool set) { is_chunked_ = set; } |
| + bool is_chunked() { return is_chunked_; } |
|
wtc
2011/01/14 03:09:31
Nit: mark this method 'const'.
Satish
2011/01/14 18:09:29
Done.
|
| + |
| // Returns the total size in bytes of the data to upload. |
| uint64 GetContentLength(); |
| @@ -145,6 +175,8 @@ class UploadData : public base::RefCounted<UploadData> { |
| std::vector<Element> elements_; |
| int64 identifier_; |
| + ChunkCallback* chunk_callback_; |
| + bool is_chunked_; |
| DISALLOW_COPY_AND_ASSIGN(UploadData); |
| }; |