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

Unified Diff: net/base/upload_data_stream.h

Issue 6134003: Prototype of chunked transfer encoded POST. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 11 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
Index: net/base/upload_data_stream.h
diff --git a/net/base/upload_data_stream.h b/net/base/upload_data_stream.h
index 0d179d217bcfdd80c8d0915c84268e5fda856167..1870e914c1d488d452de3da1d7b95e4715821467 100644
--- a/net/base/upload_data_stream.h
+++ b/net/base/upload_data_stream.h
@@ -7,6 +7,7 @@
#pragma once
#include "base/scoped_ptr.h"
+#include "net/base/completion_callback.h"
vandebo (ex-Chrome) 2011/01/18 21:51:17 This header isn't needed.
#include "net/base/upload_data.h"
namespace net {
@@ -14,8 +15,19 @@ namespace net {
class FileStream;
class IOBuffer;
-class UploadDataStream {
+class UploadDataStream : public UploadData::ChunkCallback {
vandebo (ex-Chrome) 2011/01/18 21:51:17 nit: This class doesn't really have to implement C
Satish 2011/01/19 16:05:25 Could you clarify the last part? OnChunkAvailable
vandebo (ex-Chrome) 2011/01/19 17:00:49 Sorry, I mistyped. I meant "... and call DidConsu
vandebo (ex-Chrome) 2011/01/19 19:26:01 It occurs to me, if you do decide to do this, you
public:
+ // Interface implemented by callers who require callbacks when new chunks
+ // of data are received.
+ class ChunkCallback {
vandebo (ex-Chrome) 2011/01/18 21:51:17 This is the same interface as UploadData::ChunkCal
+ public:
+ // Invoked when a new data chunk was given for a chunked transfer upload.
+ virtual void OnChunkAvailable() = 0;
+
+ protected:
+ virtual ~ChunkCallback() {}
+ };
+
// Returns a new instance of UploadDataStream if it can be created and
// initialized successfully. If not, NULL will be returned and the error
// code will be set if the output parameter error_code is not empty.
@@ -32,6 +44,11 @@ class UploadDataStream {
// the upload data to be consumed.
void DidConsume(size_t num_bytes);
+ // Sets the callback to be invoked when new data is available to upload.
vandebo (ex-Chrome) 2011/01/18 21:51:17 This comment is out dated, please update.
+ // The callback is invoked only once and needs to be set again if the caller
+ // needs to be indicated again in future.
+ void set_chunk_callback(ChunkCallback* callback);
+
// Returns the total size of the data stream and the current position.
// size() is not to be used to determine whether the stream has ended
// because it is possible for the stream to end before its size is reached,
@@ -39,10 +56,17 @@ class UploadDataStream {
uint64 size() const { return total_size_; }
uint64 position() const { return current_position_; }
+ bool is_chunked() const { return data_->is_chunked(); }
+
// Returns whether there is no more data to read, regardless of whether
// position < size.
bool eof() const { return eof_; }
+ // UploadData::ChunkCallback members.
+
+ // Callback invoked by UploadData when new data is available.
wtc 2011/01/20 00:29:47 Nit: new data => new chunk Make the same change t
+ void OnChunkAvailable();
+
private:
// Protects from public access since now we have a static creator function
// which will do both creation and initialization and might return an error.
@@ -63,8 +87,8 @@ class UploadDataStream {
scoped_refptr<IOBuffer> buf_;
size_t buf_len_;
- // Iterator to the upload element to be written to the send buffer next.
- std::vector<UploadData::Element>::iterator next_element_;
+ // Index of the upload element to be written to the send buffer next.
+ size_t next_element_;
// The byte offset into next_element_'s data buffer if the next element is
// a TYPE_BYTES element.
@@ -82,6 +106,9 @@ class UploadDataStream {
uint64 total_size_;
uint64 current_position_;
+ // Callback to be invoked by us when new data is available.
+ ChunkCallback* chunk_callback_;
+
// Whether there is no data left to read.
bool eof_;

Powered by Google App Engine
This is Rietveld 408576698