summaryrefslogtreecommitdiffstats
path: root/net/base
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 15:13:08 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 15:13:08 +0000
commitd7f5ecd6dc2156872e641cf892a39a3d6b62d386 (patch)
tree3ee768538c2a7fc8decac8f8d8a389f9d8b2b3c7 /net/base
parent91ee3680d8087a7877a866114df12842a95a3229 (diff)
downloadchromium_src-d7f5ecd6dc2156872e641cf892a39a3d6b62d386.zip
chromium_src-d7f5ecd6dc2156872e641cf892a39a3d6b62d386.tar.gz
chromium_src-d7f5ecd6dc2156872e641cf892a39a3d6b62d386.tar.bz2
Revert 118265 (added a static initializer on linux)
- Factor out chunk encoding logic into HttpStreamParser::EncodeChunk(). The logic is meaty enough to be factored out. Add unit tests along the way. BUG=72001 TEST=add unit tests. Review URL: http://codereview.chromium.org/9242018 TBR=satorux@chromium.org Review URL: https://chromiumcodereview.appspot.com/9264010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118295 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r--net/base/upload_data_stream.cc7
-rw-r--r--net/base/upload_data_stream.h10
2 files changed, 8 insertions, 9 deletions
diff --git a/net/base/upload_data_stream.cc b/net/base/upload_data_stream.cc
index 2153119..3300cd7 100644
--- a/net/base/upload_data_stream.cc
+++ b/net/base/upload_data_stream.cc
@@ -13,7 +13,6 @@
namespace net {
-const size_t UploadDataStream::kBufferSize = 16384;
bool UploadDataStream::merge_chunks_ = true;
UploadDataStream::~UploadDataStream() {
@@ -47,7 +46,7 @@ void UploadDataStream::MarkConsumedAndFillBuffer(size_t num_bytes) {
UploadDataStream::UploadDataStream(UploadData* data)
: data_(data),
- buf_(new IOBuffer(kBufferSize)),
+ buf_(new IOBuffer(kBufSize)),
buf_len_(0),
next_element_(0),
next_element_offset_(0),
@@ -60,12 +59,12 @@ UploadDataStream::UploadDataStream(UploadData* data)
int UploadDataStream::FillBuf() {
std::vector<UploadData::Element>& elements = *data_->elements();
- while (buf_len_ < kBufferSize && next_element_ < elements.size()) {
+ while (buf_len_ < kBufSize && next_element_ < elements.size()) {
bool advance_to_next_element = false;
UploadData::Element& element = elements[next_element_];
- size_t size_remaining = kBufferSize - buf_len_;
+ size_t size_remaining = kBufSize - buf_len_;
if (element.type() == UploadData::TYPE_BYTES ||
element.type() == UploadData::TYPE_CHUNK) {
const std::vector<char>& d = element.bytes();
diff --git a/net/base/upload_data_stream.h b/net/base/upload_data_stream.h
index d0db3ff..df21e63 100644
--- a/net/base/upload_data_stream.h
+++ b/net/base/upload_data_stream.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -30,11 +30,9 @@ class NET_EXPORT UploadDataStream {
// 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 constant and make the interface cleaner as well with less memmove
+ // with this method and make the interface cleaner as well with less memmove
// calls.
- //
- // The size of the stream's buffer pointed by buf().
- static const size_t kBufferSize;
+ size_t GetMaxBufferSize() const { return kBufSize; }
// 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
@@ -69,6 +67,8 @@ 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);