diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-08 08:28:17 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-08 08:28:17 +0000 |
commit | fb6f7180a951efeff59918c3b1e8493f20efd0d8 (patch) | |
tree | 2c77cf41bd78917cf8f48b944f44c502377cce72 /net | |
parent | 274323c679690cd7d71c80989977812c9959e001 (diff) | |
download | chromium_src-fb6f7180a951efeff59918c3b1e8493f20efd0d8.zip chromium_src-fb6f7180a951efeff59918c3b1e8493f20efd0d8.tar.gz chromium_src-fb6f7180a951efeff59918c3b1e8493f20efd0d8.tar.bz2 |
Remove bzip2 decoding support completely.
BUG=14801,26577
TEST=see bug.
Review URL: http://codereview.chromium.org/466038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34047 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/DEPS | 1 | ||||
-rw-r--r-- | net/base/bzip2_filter.cc | 99 | ||||
-rw-r--r-- | net/base/bzip2_filter.h | 88 | ||||
-rw-r--r-- | net/base/bzip2_filter_unittest.cc | 406 | ||||
-rw-r--r-- | net/base/filter.cc | 15 | ||||
-rw-r--r-- | net/base/filter.h | 1 | ||||
-rw-r--r-- | net/base/filter_unittest.cc | 8 | ||||
-rw-r--r-- | net/net.gyp | 6 | ||||
-rw-r--r-- | net/url_request/url_request_unittest.cc | 56 |
9 files changed, 0 insertions, 680 deletions
diff --git a/net/base/DEPS b/net/base/DEPS index 8bd50c3..a9837b3 100644 --- a/net/base/DEPS +++ b/net/base/DEPS @@ -1,5 +1,4 @@ include_rules = [ - "+third_party/bzip2", "+third_party/npapi", "+third_party/zlib", "+grit", # For generated headers diff --git a/net/base/bzip2_filter.cc b/net/base/bzip2_filter.cc deleted file mode 100644 index ce825a3..0000000 --- a/net/base/bzip2_filter.cc +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#include "net/base/bzip2_filter.h" - -BZip2Filter::BZip2Filter(const FilterContext& filter_context) - : Filter(filter_context), - decoding_status_(DECODING_UNINITIALIZED), - bzip2_data_stream_(NULL) { -} - -BZip2Filter::~BZip2Filter() { - if (bzip2_data_stream_.get() && - decoding_status_ != DECODING_UNINITIALIZED) { - BZ2_bzDecompressEnd(bzip2_data_stream_.get()); - } -} - -bool BZip2Filter::InitDecoding(bool use_small_memory) { - if (decoding_status_ != DECODING_UNINITIALIZED) - return false; - - // Initialize zlib control block - bzip2_data_stream_.reset(new bz_stream); - if (!bzip2_data_stream_.get()) - return false; - memset(bzip2_data_stream_.get(), 0, sizeof(bz_stream)); - - int result = BZ2_bzDecompressInit(bzip2_data_stream_.get(), - 0, - use_small_memory ? 1 : 0); - - if (result != BZ_OK) - return false; - - decoding_status_ = DECODING_IN_PROGRESS; - return true; -} - -Filter::FilterStatus BZip2Filter::ReadFilteredData(char* dest_buffer, - int* dest_len) { - Filter::FilterStatus status = Filter::FILTER_ERROR; - - // check output - if (!dest_buffer || !dest_len || *dest_len <= 0) - return status; - - if (DECODING_DONE == decoding_status_) { - // this logic just follow gzip_filter, which be used to deal wth some - // server might send extra data after finish sending compress data - return CopyOut(dest_buffer, dest_len); - } - - if (decoding_status_ != DECODING_IN_PROGRESS) - return status; - - // Make sure we have valid input data - if (!next_stream_data_ || stream_data_len_ <= 0) { - *dest_len = 0; - return Filter::FILTER_NEED_MORE_DATA; - } - - // Fill in bzip2 control block - int ret, output_len = *dest_len; - *dest_len = 0; - - bzip2_data_stream_->next_in = next_stream_data_; - bzip2_data_stream_->avail_in = stream_data_len_; - bzip2_data_stream_->next_out = dest_buffer; - bzip2_data_stream_->avail_out = output_len; - - ret = BZ2_bzDecompress(bzip2_data_stream_.get()); - - // get real output length, rest data and rest data length - *dest_len = output_len - bzip2_data_stream_->avail_out; - - if (0 == bzip2_data_stream_->avail_in) { - next_stream_data_ = NULL; - stream_data_len_ = 0; - } else { - next_stream_data_ = bzip2_data_stream_->next_in; - stream_data_len_ = bzip2_data_stream_->avail_in; - } - - if (BZ_OK == ret) { - if (stream_data_len_) - status = Filter::FILTER_OK; - else - status = Filter::FILTER_NEED_MORE_DATA; - } else if (BZ_STREAM_END == ret) { - status = Filter::FILTER_DONE; - decoding_status_ = DECODING_DONE; - } else { - decoding_status_ = DECODING_ERROR; - } - - return status; -} diff --git a/net/base/bzip2_filter.h b/net/base/bzip2_filter.h deleted file mode 100644 index 5a9e7b6..0000000 --- a/net/base/bzip2_filter.h +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2006-2008 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. -// -// BZip2Filter applies bzip2 content encoding/decoding to a datastream. -// Since it is a new feature, and no specification said what 's bzip2 content -// composed of in http protocol. So I assume with bzip2 encoding the content -// is full format, which means the content should carry complete bzip2 head, -// such as inlcude magic number 1(BZh), block size bit, magic number 2(0x31, -// 0x41, 0x59, 0x26, 0xx53, 0x59) -// Maybe need to inserts a bzlib2 header to the data stream before calling -// decompression functionality, but at now I do not meet this sort of real -// scenarios. So let's see the further requests. -// -// This BZip2Filter internally uses third_party/bzip2 library to do decoding. -// -// BZip2Filter is also a subclass of Filter. See the latter's header file -// filter.h for sample usage. - -#ifndef NET_BASE_BZIP2_FILTER_H_ -#define NET_BASE_BZIP2_FILTER_H_ - -#if defined(USE_SYSTEM_LIBBZ2) -#include <bzlib.h> -#else -#include "third_party/bzip2/bzlib.h" -#endif - -#include "base/scoped_ptr.h" -#include "net/base/filter.h" - -class BZip2Filter : public Filter { - public: - explicit BZip2Filter(const FilterContext& filter_context); - - virtual ~BZip2Filter(); - - // Initializes filter decoding mode and internal control blocks. - // Parameter use_small_memory specifies whether use small memory - // to decompresss data. If small is nonzero, the bzip2 library will - // use an alternative decompression algorithm which uses less memory - // but at the cost of decompressing more slowly (roughly speaking, - // half the speed, but the maximum memory requirement drops to - // around 2300k). For more information, see doc in http://www.bzip.org. - // The function returns true if success and false otherwise. - // The filter can only be initialized once. - bool InitDecoding(bool use_small_memory); - - // Decodes the pre-filter data and writes the output into the dest_buffer - // passed in. - // The function returns FilterStatus. See filter.h for its description. - // - // Since BZ2_bzDecompress need a full BZip header for decompression, so - // the incoming data should have the full BZip header, otherwise this - // function will give you nothing with FILTER_ERROR. - // - // Upon entry, *dest_len is the total size (in number of chars) of the - // destination buffer. Upon exit, *dest_len is the actual number of chars - // written into the destination buffer. - // - // This function will fail if there is no pre-filter data in the - // stream_buffer_. On the other hand, *dest_len can be 0 upon successful - // return. For example, the internal zlib may process some pre-filter data - // but not produce output yet. - virtual FilterStatus ReadFilteredData(char* dest_buffer, int* dest_len); - - private: - enum DecodingStatus { - DECODING_UNINITIALIZED, - DECODING_IN_PROGRESS, - DECODING_DONE, - DECODING_ERROR - }; - - // Tracks the status of decoding. - // This variable is initialized by InitDecoding and updated only by - // ReadFilteredData. - DecodingStatus decoding_status_; - - // The control block of bzip which actually does the decoding. - // This data structure is initialized by InitDecoding and updated in - // ReadFilteredData. - scoped_ptr<bz_stream> bzip2_data_stream_; - - DISALLOW_COPY_AND_ASSIGN(BZip2Filter); -}; - -#endif // NET_BASE_BZIP2_FILTER_H_ diff --git a/net/base/bzip2_filter_unittest.cc b/net/base/bzip2_filter_unittest.cc deleted file mode 100644 index 4e6ec54..0000000 --- a/net/base/bzip2_filter_unittest.cc +++ /dev/null @@ -1,406 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#include <fstream> -#include <iostream> - -#if defined(USE_SYSTEM_LIBBZ2) -#include <bzlib.h> -#else -#include "third_party/bzip2/bzlib.h" -#endif - -#include "base/file_util.h" -#include "base/path_service.h" -#include "base/scoped_ptr.h" -#include "net/base/bzip2_filter.h" -#include "net/base/filter_unittest.h" -#include "net/base/io_buffer.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "testing/platform_test.h" - -namespace { - -const char* kExtraData = "Test Data, More Test Data, Even More Data of Test"; -const int kExtraDataBufferSize = 49; -const int kDefaultBufferSize = 4096; -const int kSmallBufferSize = 128; -const int kMaxBufferSize = 1048576; // 1048576 == 2^20 == 1 MB - -const char kApplicationOctetStream[] = "application/octet-stream"; - -// These tests use the path service, which uses autoreleased objects on the -// Mac, so this needs to be a PlatformTest. -class BZip2FilterUnitTest : public PlatformTest { - protected: - virtual void SetUp() { - PlatformTest::SetUp(); - - bzip2_encode_buffer_ = NULL; - - // Get the path of source data file. - FilePath file_path; - PathService::Get(base::DIR_SOURCE_ROOT, &file_path); - file_path = file_path.AppendASCII("net"); - file_path = file_path.AppendASCII("data"); - file_path = file_path.AppendASCII("filter_unittests"); - file_path = file_path.AppendASCII("google.txt"); - - // Read data from the file into buffer. - ASSERT_TRUE(file_util::ReadFileToString(file_path, &source_buffer_)); - - // Append the extra data to end of source - source_buffer_.append(kExtraData, kExtraDataBufferSize); - - // Encode the whole data with bzip2 for next testing - bzip2_data_stream_.reset(new bz_stream); - ASSERT_TRUE(bzip2_data_stream_.get()); - memset(bzip2_data_stream_.get(), 0, sizeof(bz_stream)); - - int result = BZ2_bzCompressInit(bzip2_data_stream_.get(), - 9, // 900k block size - 0, // quiet - 0); // default work factor - ASSERT_EQ(BZ_OK, result); - - bzip2_encode_buffer_ = new char[kDefaultBufferSize]; - ASSERT_TRUE(bzip2_encode_buffer_ != NULL); - bzip2_encode_len_ = kDefaultBufferSize; - - bzip2_data_stream_->next_in = const_cast<char*>(source_buffer()); - bzip2_data_stream_->avail_in = source_len(); - bzip2_data_stream_->next_out = bzip2_encode_buffer_; - bzip2_data_stream_->avail_out = bzip2_encode_len_; - do { - result = BZ2_bzCompress(bzip2_data_stream_.get(), BZ_FINISH); - } while (result == BZ_FINISH_OK); - - ASSERT_EQ(BZ_STREAM_END, result); - result = BZ2_bzCompressEnd(bzip2_data_stream_.get()); - ASSERT_EQ(BZ_OK, result); - bzip2_encode_len_ = bzip2_data_stream_->total_out_lo32; - - // Make sure we wrote something; otherwise not sure what to expect - ASSERT_GT(bzip2_encode_len_, 0); - ASSERT_LE(bzip2_encode_len_, kDefaultBufferSize); - } - - virtual void TearDown() { - delete[] bzip2_encode_buffer_; - bzip2_encode_buffer_ = NULL; - - PlatformTest::TearDown(); - } - - // Use filter to decode compressed data, and compare the decoding result with - // the orginal Data. - // Parameters: Source and source_len are original data and its size. - // Encoded_source and encoded_source_len are compressed data and its size. - // Output_buffer_size specifies the size of buffer to read out data from - // filter. - // get_extra_data specifies whether get the extra data because maybe some - // server might send extra data after finish sending compress data. - void DecodeAndCompareWithFilter(Filter* filter, - const char* source, - int source_len, - const char* encoded_source, - int encoded_source_len, - int output_buffer_size, - bool get_extra_data) { - // Make sure we have enough space to hold the decoding output. - ASSERT_LE(source_len, kDefaultBufferSize); - ASSERT_LE(output_buffer_size, kDefaultBufferSize); - - int total_output_len = kDefaultBufferSize; - if (get_extra_data) - total_output_len += kExtraDataBufferSize; - char decode_buffer[kDefaultBufferSize + kExtraDataBufferSize]; - char* decode_next = decode_buffer; - int decode_avail_size = total_output_len; - - const char* encode_next = encoded_source; - int encode_avail_size = encoded_source_len; - - Filter::FilterStatus code = Filter::FILTER_OK; - while (code != Filter::FILTER_DONE) { - int encode_data_len; - if (get_extra_data && !encode_avail_size) - break; - encode_data_len = std::min(encode_avail_size, - filter->stream_buffer_size()); - memcpy(filter->stream_buffer()->data(), encode_next, encode_data_len); - filter->FlushStreamBuffer(encode_data_len); - encode_next += encode_data_len; - encode_avail_size -= encode_data_len; - - while (1) { - int decode_data_len = std::min(decode_avail_size, output_buffer_size); - - code = filter->ReadData(decode_next, &decode_data_len); - decode_next += decode_data_len; - decode_avail_size -= decode_data_len; - - ASSERT_TRUE(code != Filter::FILTER_ERROR); - - if (code == Filter::FILTER_NEED_MORE_DATA || - code == Filter::FILTER_DONE) { - if (code == Filter::FILTER_DONE && get_extra_data) - code = Filter::FILTER_OK; - else - break; - } - } - } - - // Compare the decoding result with source data - int decode_total_data_len = total_output_len - decode_avail_size; - EXPECT_TRUE(decode_total_data_len == source_len); - EXPECT_EQ(memcmp(source, decode_buffer, source_len), 0); - } - - // Unsafe function to use filter to decode compressed data. - // Parameters: Source and source_len are compressed data and its size. - // Dest is the buffer for decoding results. Upon entry, *dest_len is the size - // of the dest buffer. Upon exit, *dest_len is the number of chars written - // into the buffer. - Filter::FilterStatus DecodeAllWithFilter(Filter* filter, - const char* source, - int source_len, - char* dest, - int* dest_len) { - memcpy(filter->stream_buffer()->data(), source, source_len); - filter->FlushStreamBuffer(source_len); - return filter->ReadData(dest, dest_len); - } - - const char* source_buffer() const { return source_buffer_.data(); } - int source_len() const { - return static_cast<int>(source_buffer_.size()) - kExtraDataBufferSize; - } - - std::string source_buffer_; - - scoped_ptr<bz_stream> bzip2_data_stream_; - char* bzip2_encode_buffer_; - int bzip2_encode_len_; -}; - -// Basic scenario: decoding bzip2 data with big enough buffer. -TEST_F(BZip2FilterUnitTest, DecodeBZip2) { - // Decode the compressed data with filter - std::vector<Filter::FilterType> filter_types; - filter_types.push_back(Filter::FILTER_TYPE_BZIP2); - MockFilterContext filter_context(kDefaultBufferSize); - scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); - ASSERT_TRUE(filter.get()); - memcpy(filter->stream_buffer()->data(), bzip2_encode_buffer_, - bzip2_encode_len_); - filter->FlushStreamBuffer(bzip2_encode_len_); - - char bzip2_decode_buffer[kDefaultBufferSize]; - int bzip2_decode_size = kDefaultBufferSize; - Filter::FilterStatus result = - filter->ReadData(bzip2_decode_buffer, &bzip2_decode_size); - ASSERT_EQ(Filter::FILTER_DONE, result); - - // Compare the decoding result with source data - EXPECT_TRUE(bzip2_decode_size == source_len()); - EXPECT_EQ(memcmp(source_buffer(), bzip2_decode_buffer, source_len()), 0); -} - -// Tests we can call filter repeatedly to get all the data decoded. -// To do that, we create a filter with a small buffer that can not hold all -// the input data. -TEST_F(BZip2FilterUnitTest, DecodeWithSmallInputBuffer) { - std::vector<Filter::FilterType> filter_types; - filter_types.push_back(Filter::FILTER_TYPE_BZIP2); - MockFilterContext filter_context(kSmallBufferSize); - scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); - ASSERT_TRUE(filter.get()); - DecodeAndCompareWithFilter(filter.get(), source_buffer(), source_len(), - bzip2_encode_buffer_, bzip2_encode_len_, - kDefaultBufferSize, false); -} - -// Tests we can decode when caller has small buffer to read out from filter. -TEST_F(BZip2FilterUnitTest, DecodeWithSmallOutputBuffer) { - std::vector<Filter::FilterType> filter_types; - filter_types.push_back(Filter::FILTER_TYPE_BZIP2); - MockFilterContext filter_context(kDefaultBufferSize); - scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); - ASSERT_TRUE(filter.get()); - DecodeAndCompareWithFilter(filter.get(), source_buffer(), source_len(), - bzip2_encode_buffer_, bzip2_encode_len_, - kSmallBufferSize, false); -} - -// Tests we can still decode with just 1 byte buffer in the filter. -// The purpose of this tests are two: (1) Verify filter can parse partial BZip2 -// header correctly. (2) Sometimes the filter will consume input without -// generating output. Verify filter can handle it correctly. -TEST_F(BZip2FilterUnitTest, DecodeWithOneByteInputBuffer) { - std::vector<Filter::FilterType> filter_types; - filter_types.push_back(Filter::FILTER_TYPE_BZIP2); - MockFilterContext filter_context(1); - scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); - ASSERT_TRUE(filter.get()); - DecodeAndCompareWithFilter(filter.get(), source_buffer(), source_len(), - bzip2_encode_buffer_, bzip2_encode_len_, - kDefaultBufferSize, false); -} - -// Tests we can still decode with just 1 byte buffer in the filter and just 1 -// byte buffer in the caller. -TEST_F(BZip2FilterUnitTest, DecodeWithOneByteInputAndOutputBuffer) { - std::vector<Filter::FilterType> filter_types; - filter_types.push_back(Filter::FILTER_TYPE_BZIP2); - MockFilterContext filter_context(1); - scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); - ASSERT_TRUE(filter.get()); - DecodeAndCompareWithFilter(filter.get(), source_buffer(), source_len(), - bzip2_encode_buffer_, bzip2_encode_len_, 1, false); -} - -// Decoding bzip2 stream with corrupted data. -TEST_F(BZip2FilterUnitTest, DecodeCorruptedData) { - char corrupt_data[kDefaultBufferSize]; - int corrupt_data_len = bzip2_encode_len_; - memcpy(corrupt_data, bzip2_encode_buffer_, bzip2_encode_len_); - - char corrupt_decode_buffer[kDefaultBufferSize]; - int corrupt_decode_size = kDefaultBufferSize; - - // Decode the correct data with filter - std::vector<Filter::FilterType> filter_types; - filter_types.push_back(Filter::FILTER_TYPE_BZIP2); - MockFilterContext filter_context(kDefaultBufferSize); - scoped_ptr<Filter> filter1(Filter::Factory(filter_types, filter_context)); - ASSERT_TRUE(filter1.get()); - - Filter::FilterStatus code = DecodeAllWithFilter(filter1.get(), - corrupt_data, - corrupt_data_len, - corrupt_decode_buffer, - &corrupt_decode_size); - - // Expect failures - EXPECT_TRUE(code == Filter::FILTER_DONE); - - // Decode the corrupted data with filter - scoped_ptr<Filter> filter2(Filter::Factory(filter_types, filter_context)); - ASSERT_TRUE(filter2.get()); - - int pos = corrupt_data_len / 2; - corrupt_data[pos] = !corrupt_data[pos]; - - code = DecodeAllWithFilter(filter2.get(), - corrupt_data, - corrupt_data_len, - corrupt_decode_buffer, - &corrupt_decode_size); - - // Expect failures - EXPECT_TRUE(code != Filter::FILTER_DONE); -} - -// Decoding bzip2 stream with missing data. -TEST_F(BZip2FilterUnitTest, DecodeMissingData) { - char corrupt_data[kDefaultBufferSize]; - int corrupt_data_len = bzip2_encode_len_; - memcpy(corrupt_data, bzip2_encode_buffer_, bzip2_encode_len_); - - int pos = corrupt_data_len / 2; - int len = corrupt_data_len - pos - 1; - memmove(&corrupt_data[pos], &corrupt_data[pos+1], len); - --corrupt_data_len; - - // Decode the corrupted data with filter - std::vector<Filter::FilterType> filter_types; - filter_types.push_back(Filter::FILTER_TYPE_BZIP2); - MockFilterContext filter_context(kDefaultBufferSize); - scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); - ASSERT_TRUE(filter.get()); - char corrupt_decode_buffer[kDefaultBufferSize]; - int corrupt_decode_size = kDefaultBufferSize; - - Filter::FilterStatus code = DecodeAllWithFilter(filter.get(), - corrupt_data, - corrupt_data_len, - corrupt_decode_buffer, - &corrupt_decode_size); - // Expect failures - EXPECT_TRUE(code != Filter::FILTER_DONE); -} - -// Decoding bzip2 stream with corrupted header. -TEST_F(BZip2FilterUnitTest, DecodeCorruptedHeader) { - char corrupt_data[kDefaultBufferSize]; - int corrupt_data_len = bzip2_encode_len_; - memcpy(corrupt_data, bzip2_encode_buffer_, bzip2_encode_len_); - - corrupt_data[2] = !corrupt_data[2]; - - // Decode the corrupted data with filter - std::vector<Filter::FilterType> filter_types; - filter_types.push_back(Filter::FILTER_TYPE_BZIP2); - MockFilterContext filter_context(kDefaultBufferSize); - scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); - ASSERT_TRUE(filter.get()); - char corrupt_decode_buffer[kDefaultBufferSize]; - int corrupt_decode_size = kDefaultBufferSize; - - Filter::FilterStatus code = DecodeAllWithFilter(filter.get(), - corrupt_data, - corrupt_data_len, - corrupt_decode_buffer, - &corrupt_decode_size); - - // Expect failures - EXPECT_TRUE(code == Filter::FILTER_ERROR); -} - -// Tests we can decode all compress data and get extra data which is -// appended to compress data stream by some server when it finish -// sending compress data. -TEST_F(BZip2FilterUnitTest, DecodeWithExtraDataAndSmallOutputBuffer) { - char more_data[kDefaultBufferSize + kExtraDataBufferSize]; - int more_data_len = bzip2_encode_len_ + kExtraDataBufferSize; - memcpy(more_data, bzip2_encode_buffer_, bzip2_encode_len_); - memcpy(more_data + bzip2_encode_len_, kExtraData, kExtraDataBufferSize); - - std::vector<Filter::FilterType> filter_types; - filter_types.push_back(Filter::FILTER_TYPE_BZIP2); - MockFilterContext filter_context(kDefaultBufferSize); - scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); - ASSERT_TRUE(filter.get()); - DecodeAndCompareWithFilter(filter.get(), - source_buffer(), - source_len() + kExtraDataBufferSize, - more_data, - more_data_len, - kSmallBufferSize, - true); -} - -TEST_F(BZip2FilterUnitTest, DecodeWithExtraDataAndSmallInputBuffer) { - char more_data[kDefaultBufferSize + kExtraDataBufferSize]; - int more_data_len = bzip2_encode_len_ + kExtraDataBufferSize; - memcpy(more_data, bzip2_encode_buffer_, bzip2_encode_len_); - memcpy(more_data + bzip2_encode_len_, kExtraData, kExtraDataBufferSize); - - std::vector<Filter::FilterType> filter_types; - filter_types.push_back(Filter::FILTER_TYPE_BZIP2); - MockFilterContext filter_context(kSmallBufferSize); - scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); - ASSERT_TRUE(filter.get()); - DecodeAndCompareWithFilter(filter.get(), - source_buffer(), - source_len() + kExtraDataBufferSize, - more_data, - more_data_len, - kDefaultBufferSize, - true); -} - -} // namespace diff --git a/net/base/filter.cc b/net/base/filter.cc index 74a8b11..4a7b8a6 100644 --- a/net/base/filter.cc +++ b/net/base/filter.cc @@ -7,7 +7,6 @@ #include "base/file_path.h" #include "base/string_util.h" #include "net/base/gzip_filter.h" -#include "net/base/bzip2_filter.h" #include "net/base/io_buffer.h" #include "net/base/mime_util.h" #include "net/base/sdch_filter.h" @@ -18,8 +17,6 @@ namespace { const char kDeflate[] = "deflate"; const char kGZip[] = "gzip"; const char kXGZip[] = "x-gzip"; -const char kBZip2[] = "bzip2"; -const char kXBZip2[] = "x-bzip2"; const char kSdch[] = "sdch"; // compress and x-compress are currently not supported. If we decide to support // them, we'll need the same mime type compatibility hack we have for gzip. For @@ -65,9 +62,6 @@ Filter::FilterType Filter::ConvertEncodingToType( } else if (LowerCaseEqualsASCII(filter_type, kGZip) || LowerCaseEqualsASCII(filter_type, kXGZip)) { type_id = FILTER_TYPE_GZIP; - } else if (LowerCaseEqualsASCII(filter_type, kBZip2) || - LowerCaseEqualsASCII(filter_type, kXBZip2)) { - type_id = FILTER_TYPE_BZIP2; } else if (LowerCaseEqualsASCII(filter_type, kSdch)) { type_id = FILTER_TYPE_SDCH; } else { @@ -252,15 +246,6 @@ Filter* Filter::PrependNewFilter(FilterType type_id, } break; } - case FILTER_TYPE_BZIP2: { - scoped_ptr<BZip2Filter> bzip2_filter(new BZip2Filter(filter_context)); - if (bzip2_filter->InitBuffer()) { - if (bzip2_filter->InitDecoding(false)) { - first_filter = bzip2_filter.release(); - } - } - break; - } case FILTER_TYPE_SDCH: case FILTER_TYPE_SDCH_POSSIBLE: { scoped_ptr<SdchFilter> sdch_filter(new SdchFilter(filter_context)); diff --git a/net/base/filter.h b/net/base/filter.h index cb28031..cf32d2f 100644 --- a/net/base/filter.h +++ b/net/base/filter.h @@ -128,7 +128,6 @@ class Filter { enum FilterType { FILTER_TYPE_DEFLATE, FILTER_TYPE_GZIP, - FILTER_TYPE_BZIP2, FILTER_TYPE_GZIP_HELPING_SDCH, // Gzip possible, but pass through allowed. FILTER_TYPE_SDCH, FILTER_TYPE_SDCH_POSSIBLE, // Sdch possible, but pass through allowed. diff --git a/net/base/filter_unittest.cc b/net/base/filter_unittest.cc index 55db5e7..75fee20 100644 --- a/net/base/filter_unittest.cc +++ b/net/base/filter_unittest.cc @@ -23,14 +23,6 @@ TEST(FilterTest, ContentTypeId) { Filter::ConvertEncodingToType("x-gzip")); EXPECT_EQ(Filter::FILTER_TYPE_GZIP, Filter::ConvertEncodingToType("X-GzIp")); - EXPECT_EQ(Filter::FILTER_TYPE_BZIP2, - Filter::ConvertEncodingToType("bzip2")); - EXPECT_EQ(Filter::FILTER_TYPE_BZIP2, - Filter::ConvertEncodingToType("BZiP2")); - EXPECT_EQ(Filter::FILTER_TYPE_BZIP2, - Filter::ConvertEncodingToType("x-bzip2")); - EXPECT_EQ(Filter::FILTER_TYPE_BZIP2, - Filter::ConvertEncodingToType("X-BZiP2")); EXPECT_EQ(Filter::FILTER_TYPE_SDCH, Filter::ConvertEncodingToType("sdch")); EXPECT_EQ(Filter::FILTER_TYPE_SDCH, diff --git a/net/net.gyp b/net/net.gyp index 1428177..b0672cf 100644 --- a/net/net.gyp +++ b/net/net.gyp @@ -15,7 +15,6 @@ '../base/base.gyp:base_i18n', '../build/temp_gyp/googleurl.gyp:googleurl', '../sdch/sdch.gyp:sdch', - '../third_party/bzip2/bzip2.gyp:bzip2', '../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icuuc', '../third_party/zlib/zlib.gyp:zlib', @@ -26,8 +25,6 @@ 'base/address_list.cc', 'base/address_list.h', 'base/auth.h', - 'base/bzip2_filter.cc', - 'base/bzip2_filter.h', 'base/cache_type.h', 'base/cert_database.h', 'base/cert_database_mac.cc', @@ -215,7 +212,6 @@ '../base/base.gyp:base_i18n', '../build/temp_gyp/googleurl.gyp:googleurl', '../sdch/sdch.gyp:sdch', - '../third_party/bzip2/bzip2.gyp:bzip2', '../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icuuc', '../third_party/zlib/zlib.gyp:zlib', @@ -565,12 +561,10 @@ '../base/base.gyp:base_i18n', '../testing/gtest.gyp:gtest', '../third_party/zlib/zlib.gyp:zlib', - '../third_party/bzip2/bzip2.gyp:bzip2', ], 'msvs_guid': 'E99DA267-BE90-4F45-88A1-6919DB2C7567', 'sources': [ 'base/address_list_unittest.cc', - 'base/bzip2_filter_unittest.cc', 'base/cookie_monster_unittest.cc', 'base/cookie_policy_unittest.cc', 'base/data_url_unittest.cc', diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 16af0d0..0fbe18f 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -846,62 +846,6 @@ TEST_F(URLRequestTestHTTP, ResponseHeadersTest) { EXPECT_EQ("a, b", header); } -// TODO(jar): 14801 Remove BZIP code completely. -TEST_F(URLRequestTest, DISABLED_BZip2ContentTest) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(L"net/data/filter_unittests", NULL); - ASSERT_TRUE(NULL != server.get()); - - // for localhost domain, we also should support bzip2 encoding - // first, get the original file - TestDelegate d1; - TestURLRequest req1(server->TestServerPage("realfiles/google.txt"), &d1); - req1.Start(); - MessageLoop::current()->Run(); - - const std::string& got_content = d1.data_received(); - - // second, get bzip2 content - TestDelegate d2; - TestURLRequest req2(server->TestServerPage("realbz2files/google.txt"), &d2); - req2.Start(); - MessageLoop::current()->Run(); - - const std::string& got_bz2_content = d2.data_received(); - - // compare those two results - EXPECT_EQ(got_content, got_bz2_content); -} - -// TODO(jar): 14801 Remove BZIP code completely. -TEST_F(URLRequestTest, DISABLED_BZip2ContentTest_IncrementalHeader) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(L"net/data/filter_unittests", NULL); - ASSERT_TRUE(NULL != server.get()); - - // for localhost domain, we also should support bzip2 encoding - // first, get the original file - TestDelegate d1; - TestURLRequest req1(server->TestServerPage("realfiles/google.txt"), &d1); - req1.Start(); - MessageLoop::current()->Run(); - - const std::string& got_content = d1.data_received(); - - // second, get bzip2 content. ask the testserver to send the BZ2 header in - // two chunks with a delay between them. this tests our fix for bug 867161. - TestDelegate d2; - TestURLRequest req2(server->TestServerPage( - "realbz2files/google.txt?incremental-header"), &d2); - req2.Start(); - MessageLoop::current()->Run(); - - const std::string& got_bz2_content = d2.data_received(); - - // compare those two results - EXPECT_EQ(got_content, got_bz2_content); -} - #if defined(OS_WIN) TEST_F(URLRequestTest, ResolveShortcutTest) { FilePath app_path; |