summaryrefslogtreecommitdiffstats
path: root/net/base/filter.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/filter.cc')
-rw-r--r--net/base/filter.cc80
1 files changed, 3 insertions, 77 deletions
diff --git a/net/base/filter.cc b/net/base/filter.cc
index c435f9b..80264fd 100644
--- a/net/base/filter.cc
+++ b/net/base/filter.cc
@@ -7,7 +7,6 @@
#include "base/string_util.h"
#include "net/base/gzip_filter.h"
#include "net/base/bzip2_filter.h"
-#include "net/base/sdch_filter.h"
namespace {
@@ -17,7 +16,6 @@ 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
// more information, see Firefox's nsHttpChannel::ProcessNormal.
@@ -35,34 +33,12 @@ const char kApplicationCompress[] = "application/compress";
} // namespace
-Filter* Filter::Factory(const std::vector<std::string>& filter_types,
+Filter* Filter::Factory(const std::string& filter_type,
const std::string& mime_type,
int buffer_size) {
- if (filter_types.empty() || buffer_size < 0)
+ if (filter_type.empty() || buffer_size < 0)
return NULL;
- std::string safe_mime_type = (filter_types.size() > 1) ? "" : mime_type;
- Filter* filter_list = NULL; // Linked list of filters.
- for (size_t i = 0; i < filter_types.size(); ++i) {
- Filter* first_filter;
- first_filter = SingleFilter(filter_types[i], safe_mime_type, buffer_size);
- if (!first_filter) {
- // Cleanup and exit, since we can't construct this filter list.
- if (filter_list)
- delete filter_list;
- filter_list = NULL;
- break;
- }
- first_filter->next_filter_.reset(filter_list);
- filter_list = first_filter;
- }
- return filter_list;
-}
-
-// static
-Filter* Filter::SingleFilter(const std::string& filter_type,
- const std::string& mime_type,
- int buffer_size) {
FilterType type_id;
if (LowerCaseEqualsASCII(filter_type, kDeflate)) {
type_id = FILTER_TYPE_DEFLATE;
@@ -82,8 +58,6 @@ Filter* Filter::SingleFilter(const std::string& filter_type,
} 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 {
// Note we also consider "identity" and "uncompressed" UNSUPPORTED as
// filter should be disabled in such cases.
@@ -110,15 +84,6 @@ Filter* Filter::SingleFilter(const std::string& filter_type,
}
break;
}
- case FILTER_TYPE_SDCH: {
- scoped_ptr<SdchFilter> sdch_filter(new SdchFilter());
- if (sdch_filter->InitBuffer(buffer_size)) {
- if (sdch_filter->InitDecoding()) {
- return sdch_filter.release();
- }
- }
- break;
- }
default: {
break;
}
@@ -131,9 +96,7 @@ Filter::Filter()
: stream_buffer_(NULL),
stream_buffer_size_(0),
next_stream_data_(NULL),
- stream_data_len_(0),
- next_filter_(NULL),
- last_status_(FILTER_OK) {
+ stream_data_len_(0) {
}
Filter::~Filter() {}
@@ -180,38 +143,6 @@ Filter::FilterStatus Filter::ReadFilteredData(char* dest_buffer,
return Filter::FILTER_ERROR;
}
-Filter::FilterStatus Filter::ReadData(char* dest_buffer, int* dest_len) {
- if (last_status_ == FILTER_ERROR)
- return last_status_;
- if (!next_filter_.get())
- return last_status_ = ReadFilteredData(dest_buffer, dest_len);
- if (last_status_ == FILTER_NEED_MORE_DATA && !stream_data_len())
- return next_filter_->ReadData(dest_buffer, dest_len);
- if (next_filter_->last_status() == FILTER_NEED_MORE_DATA) {
- // Push data into next filter's input.
- char* next_buffer = next_filter_->stream_buffer();
- int next_size = next_filter_->stream_buffer_size();
- last_status_ = ReadFilteredData(next_buffer, &next_size);
- next_filter_->FlushStreamBuffer(next_size);
- switch (last_status_) {
- case FILTER_ERROR:
- return last_status_;
-
- case FILTER_NEED_MORE_DATA:
- return next_filter_->ReadData(dest_buffer, dest_len);
-
- case FILTER_OK:
- case FILTER_DONE:
- break;
- }
- }
- FilterStatus status = next_filter_->ReadData(dest_buffer, dest_len);
- // We could loop to fill next_filter_ if it needs data, but we have to be
- // careful about output buffer. Simpler is to just wait until we are called
- // again, and return FILTER_OK.
- return (status == FILTER_ERROR) ? FILTER_ERROR : FILTER_OK;
-}
-
bool Filter::FlushStreamBuffer(int stream_data_len) {
if (stream_data_len <= 0 || stream_data_len > stream_buffer_size_)
return false;
@@ -225,8 +156,3 @@ bool Filter::FlushStreamBuffer(int stream_data_len) {
return true;
}
-void Filter::SetURL(const GURL& url) {
- url_ = url;
- if (next_filter_.get())
- next_filter_->SetURL(url);
-}