Index: net/base/upload_data.h |
diff --git a/net/base/upload_data.h b/net/base/upload_data.h |
index 6f7216250a40c536a8cbdf1eba70c02d67fdb342..b23614af1f7ca6a9ae2ecc59f7ebae26c53f19f3 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" |
vandebo (ex-Chrome)
2011/01/18 21:51:17
This header isn't needed.
|
#include "base/time.h" |
namespace net { |
@@ -24,7 +25,22 @@ class UploadData : public base::RefCounted<UploadData> { |
enum Type { |
TYPE_BYTES, |
TYPE_FILE, |
- TYPE_BLOB |
+ TYPE_BLOB, |
+ |
+ // A block of bytes to be sent in chunked encoding immediately, without |
+ // waiting for rest of the data. |
+ TYPE_CHUNK, |
+ }; |
+ |
+ // Interface implemented by callers who require callbacks when new chunks |
+ // of data are received. |
wtc
2011/01/20 00:29:47
Nit: received => added
Make the same change to up
|
+ class ChunkCallback { |
willchan no longer on Chromium
2011/01/20 08:51:04
I don't understand this. Why don't you just typede
Satish
2011/01/20 18:02:36
I used a callback initially and was suggested an i
vandebo (ex-Chrome)
2011/01/21 18:08:41
Will implied that using Callback0::Type would woul
willchan no longer on Chromium
2011/01/21 18:16:19
Callback0::Type by itself isn't safer. But ScopedC
|
+ public: |
+ // Invoked when a new data chunk was given for a chunked transfer upload. |
+ virtual void OnChunkAvailable() = 0; |
+ |
+ protected: |
+ virtual ~ChunkCallback() {} |
}; |
class Element { |
@@ -72,6 +88,13 @@ class UploadData : public base::RefCounted<UploadData> { |
blob_url_ = blob_url; |
} |
+ // Though similar to bytes, a chunk indicates that the stream is sent via |
wtc
2011/01/20 00:29:47
Nit: stream => element
|
+ // chunked transfer encoding and not buffered until the full upload data |
+ // is available. |
+ void SetToChunk(const char* bytes, int bytes_len); |
+ |
+ void SetToEndOfChunksMarker(); |
+ |
// 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 +142,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 |
wtc
2011/01/20 00:29:47
Nit: receive => send ?
|
+ // than all at once. |
+ void set_is_chunked(bool set) { is_chunked_ = set; } |
+ bool is_chunked() const { return is_chunked_; } |
+ |
// Returns the total size in bytes of the data to upload. |
uint64 GetContentLength(); |
@@ -145,6 +178,8 @@ class UploadData : public base::RefCounted<UploadData> { |
std::vector<Element> elements_; |
int64 identifier_; |
+ ChunkCallback* chunk_callback_; |
+ bool is_chunked_; |
DISALLOW_COPY_AND_ASSIGN(UploadData); |
}; |