diff options
author | tyoshino@chromium.org <tyoshino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-06 20:18:42 +0000 |
---|---|---|
committer | tyoshino@chromium.org <tyoshino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-06 20:18:42 +0000 |
commit | 6a14c19a4fbcfe5b21b1b6b3aa2f01874732d909 (patch) | |
tree | 61551b53803d55bcccbcd4eab942148d9b4918b2 /content | |
parent | cb2e43c4ce1e13377a318eb9b0f5390349da8f64 (diff) | |
download | chromium_src-6a14c19a4fbcfe5b21b1b6b3aa2f01874732d909.zip chromium_src-6a14c19a4fbcfe5b21b1b6b3aa2f01874732d909.tar.gz chromium_src-6a14c19a4fbcfe5b21b1b6b3aa2f01874732d909.tar.bz2 |
Clean up on byte_stream (mainly style and includes)
- Don't allocate ContentVector if input_contents_size_ is 0
- Remove unused weak_ptr.h and lock.h
- Add comments required by style guide
- Move includes not used in .h to .cc
BUG=
Review URL: https://chromiumcodereview.appspot.com/21839002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215958 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/byte_stream.cc | 12 | ||||
-rw-r--r-- | content/browser/byte_stream.h | 6 | ||||
-rw-r--r-- | content/browser/byte_stream_unittest.cc | 38 |
3 files changed, 46 insertions, 10 deletions
diff --git a/content/browser/byte_stream.cc b/content/browser/byte_stream.cc index d1f5e17..a8b8f29 100644 --- a/content/browser/byte_stream.cc +++ b/content/browser/byte_stream.cc @@ -4,10 +4,13 @@ #include "content/browser/byte_stream.h" +#include <deque> +#include <set> +#include <utility> + #include "base/bind.h" #include "base/location.h" #include "base/memory/ref_counted.h" -#include "base/memory/weak_ptr.h" #include "base/sequenced_task_runner.h" namespace content { @@ -263,7 +266,7 @@ void ByteStreamWriterImpl::PostToPeer(bool complete, int status) { // Valid contexts in which to call. DCHECK(complete || 0 != input_contents_size_); - scoped_ptr<ContentVector> transfer_buffer(new ContentVector); + scoped_ptr<ContentVector> transfer_buffer; size_t buffer_size = 0; if (0 != input_contents_size_) { transfer_buffer.reset(new ContentVector); @@ -370,8 +373,8 @@ void ByteStreamReaderImpl::TransferDataInternal( if (transfer_buffer) { available_contents_.insert(available_contents_.end(), - transfer_buffer->begin(), - transfer_buffer->end()); + transfer_buffer->begin(), + transfer_buffer->end()); } if (source_complete) { @@ -408,7 +411,6 @@ void ByteStreamReaderImpl::MaybeUpdateInput() { } // namespace - const int ByteStreamWriter::kFractionBufferBeforeSending = 3; const int ByteStreamReader::kFractionReadBeforeWindowUpdate = 3; diff --git a/content/browser/byte_stream.h b/content/browser/byte_stream.h index b16664f..0b5640d 100644 --- a/content/browser/byte_stream.h +++ b/content/browser/byte_stream.h @@ -5,13 +5,9 @@ #ifndef CONTENT_BROWSER_BYTE_STREAM_H_ #define CONTENT_BROWSER_BYTE_STREAM_H_ -#include <deque> -#include <set> -#include <utility> - #include "base/callback.h" #include "base/memory/ref_counted.h" -#include "base/synchronization/lock.h" +#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "net/base/io_buffer.h" diff --git a/content/browser/byte_stream_unittest.cc b/content/browser/byte_stream_unittest.cc index 925467c..04c5ae3 100644 --- a/content/browser/byte_stream_unittest.cc +++ b/content/browser/byte_stream_unittest.cc @@ -541,4 +541,42 @@ TEST_F(ByteStreamTest, ByteStream_ZeroCallback) { EXPECT_EQ(1, num_callbacks); } +TEST_F(ByteStreamTest, ByteStream_CloseWithoutAnyWrite) { + scoped_ptr<ByteStreamWriter> byte_stream_input; + scoped_ptr<ByteStreamReader> byte_stream_output; + CreateByteStream( + message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), + 3 * 1024, &byte_stream_input, &byte_stream_output); + + byte_stream_input->Close(0); + message_loop_.RunUntilIdle(); + + scoped_refptr<net::IOBuffer> output_io_buffer; + size_t output_length; + EXPECT_EQ(ByteStreamReader::STREAM_COMPLETE, + byte_stream_output->Read(&output_io_buffer, &output_length)); +} + +TEST_F(ByteStreamTest, ByteStream_FlushWithoutAnyWrite) { + scoped_ptr<ByteStreamWriter> byte_stream_input; + scoped_ptr<ByteStreamReader> byte_stream_output; + CreateByteStream( + message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), + 3 * 1024, &byte_stream_input, &byte_stream_output); + + byte_stream_input->Flush(); + message_loop_.RunUntilIdle(); + + scoped_refptr<net::IOBuffer> output_io_buffer; + size_t output_length; + EXPECT_EQ(ByteStreamReader::STREAM_EMPTY, + byte_stream_output->Read(&output_io_buffer, &output_length)); + + byte_stream_input->Close(0); + message_loop_.RunUntilIdle(); + + EXPECT_EQ(ByteStreamReader::STREAM_COMPLETE, + byte_stream_output->Read(&output_io_buffer, &output_length)); +} + } // namespace content |