| Index: net/base/filter.cc
|
| diff --git a/net/base/filter.cc b/net/base/filter.cc
|
| index 38e66512cf4b7e01413602245118d3a7225a2482..128140d6658335f8ca4352d3a6f8d0822ef493cc 100644
|
| --- a/net/base/filter.cc
|
| +++ b/net/base/filter.cc
|
| @@ -34,6 +34,9 @@ const char kApplicationXCompress[] = "application/x-compress";
|
| const char kApplicationCompress[] = "application/compress";
|
| const char kTextHtml[] = "text/html";
|
|
|
| +// Buffer size allocated when de-compressing data.
|
| +const int kFilterBufSize = 32 * 1024;
|
| +
|
| } // namespace
|
|
|
| FilterContext::~FilterContext() {
|
| @@ -43,11 +46,9 @@ Filter::~Filter() {}
|
|
|
| Filter* Filter::Factory(const std::vector<FilterType>& filter_types,
|
| const FilterContext& filter_context) {
|
| - DCHECK_GT(filter_context.GetInputStreamBufferSize(), 0);
|
| - if (filter_types.empty() || filter_context.GetInputStreamBufferSize() <= 0)
|
| + if (filter_types.empty())
|
| return NULL;
|
|
|
| -
|
| Filter* filter_list = NULL; // Linked list of filters.
|
| for (size_t i = 0; i < filter_types.size(); i++) {
|
| filter_list = PrependNewFilter(filter_types[i], filter_context,
|
| @@ -291,8 +292,8 @@ void Filter::FixupEncodingTypes(
|
| }
|
|
|
| Filter::Filter(const FilterContext& filter_context)
|
| - : stream_buffer_(NULL),
|
| - stream_buffer_size_(0),
|
| + : stream_buffer_(new net::IOBuffer(kFilterBufSize)),
|
| + stream_buffer_size_(kFilterBufSize),
|
| next_stream_data_(NULL),
|
| stream_data_len_(0),
|
| next_filter_(NULL),
|
| @@ -337,10 +338,8 @@ Filter* Filter::PrependNewFilter(FilterType type_id,
|
| case FILTER_TYPE_GZIP: {
|
| scoped_ptr<net::GZipFilter> gz_filter(
|
| new net::GZipFilter(filter_context));
|
| - if (gz_filter->InitBuffer()) {
|
| - if (gz_filter->InitDecoding(type_id)) {
|
| - first_filter = gz_filter.release();
|
| - }
|
| + if (gz_filter->InitDecoding(type_id)) {
|
| + first_filter = gz_filter.release();
|
| }
|
| break;
|
| }
|
| @@ -348,10 +347,8 @@ Filter* Filter::PrependNewFilter(FilterType type_id,
|
| case FILTER_TYPE_SDCH_POSSIBLE: {
|
| scoped_ptr<net::SdchFilter> sdch_filter(
|
| new net::SdchFilter(filter_context));
|
| - if (sdch_filter->InitBuffer()) {
|
| - if (sdch_filter->InitDecoding(type_id)) {
|
| - first_filter = sdch_filter.release();
|
| - }
|
| + if (sdch_filter->InitDecoding(type_id)) {
|
| + first_filter = sdch_filter.release();
|
| }
|
| break;
|
| }
|
| @@ -370,22 +367,6 @@ Filter* Filter::PrependNewFilter(FilterType type_id,
|
| return first_filter;
|
| }
|
|
|
| -bool Filter::InitBuffer() {
|
| - int buffer_size = filter_context_.GetInputStreamBufferSize();
|
| - DCHECK_GT(buffer_size, 0);
|
| - if (buffer_size <= 0 || stream_buffer())
|
| - return false;
|
| -
|
| - stream_buffer_ = new net::IOBuffer(buffer_size);
|
| -
|
| - if (stream_buffer()) {
|
| - stream_buffer_size_ = buffer_size;
|
| - return true;
|
| - }
|
| -
|
| - return false;
|
| -}
|
| -
|
| void Filter::PushDataIntoNextFilter() {
|
| net::IOBuffer* next_buffer = next_filter_->stream_buffer();
|
| int next_size = next_filter_->stream_buffer_size();
|
| @@ -393,3 +374,8 @@ void Filter::PushDataIntoNextFilter() {
|
| if (FILTER_ERROR != last_status_)
|
| next_filter_->FlushStreamBuffer(next_size);
|
| }
|
| +
|
| +void Filter::ResetInputBufferForTest(int size) {
|
| + stream_buffer_ = new net::IOBuffer(size);
|
| + stream_buffer_size_ = size;
|
| +}
|
|
|