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

Unified Diff: net/http/http_stream_parser.h

Issue 9242018: Factor out chunk encoding logic into HttpStreamParser::EncodeChunk(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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/http/http_stream_parser.h
diff --git a/net/http/http_stream_parser.h b/net/http/http_stream_parser.h
index ae9fc3e3ed5cfcb151ec3525a4b6da2b5a367298..ee39b83e11c35303ecf81956dfc8e7b34a5c3da2 100644
--- a/net/http/http_stream_parser.h
+++ b/net/http/http_stream_parser.h
@@ -9,6 +9,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/string_piece.h"
#include "net/base/completion_callback.h"
#include "net/base/net_log.h"
#include "net/base/upload_data_stream.h"
@@ -77,6 +78,20 @@ class HttpStreamParser : public ChunkCallback {
// ChunkCallback methods.
virtual void OnChunkAvailable() OVERRIDE;
+ // Encodes the given |payload| in the chunked format to |output|.
+ // Returns the number of bytes written to |output|. |output_size| should
+ // be large enough to store the encoded chunk, which is payload.size() +
+ // kChunkHeaderFooterSize. Returns -1 if |output_size| is not large
wtc 2012/01/18 22:49:24 Instead of -1, you can return a network error code
satorux1 2012/01/18 23:42:30 Good idea. I chose to use ERR_FAILED.
satorux1 2012/01/18 23:44:02 Changed it to ERR_INVALID_ARGUMENT as it sounded a
+ // enough.
+ //
+ // The output will look like: "HEX\r\n[payload]\r\n".
wtc 2012/01/18 22:49:24 Nit: should explain what HEX is. For example, w
satorux1 2012/01/18 23:42:30 Good idea. Done.
+ static int EncodeChunk(const base::StringPiece& payload,
+ char* output,
+ size_t output_size);
+
+ // The number of extra bytes required to encode a chunk.
+ static const int kChunkHeaderFooterSize;
wtc 2012/01/18 22:49:24 This constant should have the type size_t.
satorux1 2012/01/18 23:42:30 Done.
+
private:
// FOO_COMPLETE states implement the second half of potentially asynchronous
// operations and don't necessarily mean that FOO is complete.

Powered by Google App Engine
This is Rietveld 408576698