diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-21 00:45:19 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-21 00:45:19 +0000 |
commit | 6db833d1d8cd28e31a3cc816c397a32d795f849e (patch) | |
tree | 832665ef8ab651c36e30db20e7f559bb392a37da /net/base/upload_data_stream.h | |
parent | d4362e74b269497a790eb19da357ed76fb0a2357 (diff) | |
download | chromium_src-6db833d1d8cd28e31a3cc816c397a32d795f849e.zip chromium_src-6db833d1d8cd28e31a3cc816c397a32d795f849e.tar.gz chromium_src-6db833d1d8cd28e31a3cc816c397a32d795f849e.tar.bz2 |
Factor out chunk encoding logic into HttpStreamParser::EncodeChunk().
The logic is meaty enough to be factored out.
Add unit tests along the way.
The original patch (crrev.com/118265) was reverted as it introduced
a new static initializer. This version fixed that problem by defining
the constant in the .h file. To be extra careful, replaced
kChunkBufferSize with a member variable chunk_buffer_size_.
BUG=72001
TEST=add unit tests. run tools/linux/dump-static-initializers.py locally to confirm that new static initializers are not introduced.
Review URL: http://codereview.chromium.org/9176009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118566 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/upload_data_stream.h')
-rw-r--r-- | net/base/upload_data_stream.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/net/base/upload_data_stream.h b/net/base/upload_data_stream.h index df21e63..a30850a 100644 --- a/net/base/upload_data_stream.h +++ b/net/base/upload_data_stream.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -24,15 +24,18 @@ class NET_EXPORT UploadDataStream { // code will be set if the output parameter error_code is not empty. static UploadDataStream* Create(UploadData* data, int* error_code); - // Returns the stream's buffer and buffer length. + // Returns the stream's buffer. IOBuffer* buf() const { return buf_; } + // Returns the length of the data in the stream's buffer. size_t buf_len() const { return buf_len_; } // TODO(satish): We should ideally have UploadDataStream expose a Read() // method which returns data in a caller provided IOBuffer. That would do away - // with this method and make the interface cleaner as well with less memmove + // with this function and make the interface cleaner as well with less memmove // calls. - size_t GetMaxBufferSize() const { return kBufSize; } + // + // Returns the size of the stream's buffer pointed by buf(). + static size_t GetBufferSize(); // Call to indicate that a portion of the stream's buffer was consumed. This // call modifies the stream's buffer so that it contains the next segment of @@ -67,8 +70,6 @@ class NET_EXPORT UploadDataStream { static void set_merge_chunks(bool merge) { merge_chunks_ = merge; } private: - enum { kBufSize = 16384 }; - // Protects from public access since now we have a static creator function // which will do both creation and initialization and might return an error. explicit UploadDataStream(UploadData* data); @@ -112,6 +113,8 @@ class NET_EXPORT UploadDataStream { // TODO(satish): Remove this once we have a better way to unit test POST // requests with chunked uploads. static bool merge_chunks_; + // The size of the stream's buffer pointed by buf_. + static const size_t kBufferSize; DISALLOW_COPY_AND_ASSIGN(UploadDataStream); }; |