summaryrefslogtreecommitdiffstats
path: root/net/base/filter.h
diff options
context:
space:
mode:
authorjar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-27 17:39:28 +0000
committerjar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-27 17:39:28 +0000
commit423041b0a7182411149472ae1e7fd87317173097 (patch)
tree494092141aa32f87e6bf02159579ae590d0a3fbf /net/base/filter.h
parentc05ef7e4fe5aaadb4193217209a11440bd4d2c27 (diff)
downloadchromium_src-423041b0a7182411149472ae1e7fd87317173097.zip
chromium_src-423041b0a7182411149472ae1e7fd87317173097.tar.gz
chromium_src-423041b0a7182411149472ae1e7fd87317173097.tar.bz2
Clean up filter and content encoding handling
Centralize translation functions (text of "Content-Encoding" to enum) in filter.cc Centralize error recovery (for damaged content encoding headers) in filter.cc Error recovery includes a loss of SDCH encoding headers, plus handling of Apache server bug with gzip files are tagged as also being gzip encoded. Centralize and add a pile of unit tests to this filter code. r=openvcdiff,huanr Review URL: http://codereview.chromium.org/8018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4004 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/filter.h')
-rw-r--r--net/base/filter.h45
1 files changed, 27 insertions, 18 deletions
diff --git a/net/base/filter.h b/net/base/filter.h
index ab61732..98a531c 100644
--- a/net/base/filter.h
+++ b/net/base/filter.h
@@ -55,6 +55,17 @@ class Filter {
FILTER_ERROR
};
+ // Specifies type of filters that can be created.
+ enum FilterType {
+ FILTER_TYPE_DEFLATE,
+ FILTER_TYPE_GZIP,
+ FILTER_TYPE_BZIP2,
+ FILTER_TYPE_GZIP_HELPING_SDCH,
+ FILTER_TYPE_SDCH,
+ FILTER_TYPE_UNSUPPORTED,
+ };
+
+
virtual ~Filter();
// Creates a Filter object.
@@ -71,8 +82,7 @@ class Filter {
// (decoding) order. For example, types[0] = "sdch", types[1] = "gzip" will
// cause data to first be gunizip filtered, and the resulting output from that
// filter will be sdch decoded.
- static Filter* Factory(const std::vector<std::string>& filter_types,
- const std::string& mime_type,
+ static Filter* Factory(const std::vector<FilterType>& filter_types,
int buffer_size);
// External call to obtain data from this filter chain. If ther is no
@@ -107,20 +117,24 @@ class Filter {
void SetURL(const GURL& url);
const GURL& url() const { return url_; }
- void SetMimeType(std::string& mime_type);
+ void SetMimeType(const std::string& mime_type);
const std::string& mime_type() const { return mime_type_; }
+ // Translate the text of a filter name (from Content-Encoding header) into a
+ // FilterType.
+ static FilterType ConvertEncodingToType(const std::string& filter_type);
+
+ // Given a array of encoding_types, try to do some error recovery adjustment
+ // to the list. This includes handling known bugs in the Apache server (where
+ // redundant gzip encoding is specified), as well as issues regarding SDCH
+ // encoding, where various proxies and anti-virus products modify or strip the
+ // encodings. These fixups require context, which includes whether this
+ // response was made to an SDCH request (i.e., an available dictionary was
+ // advertised in the GET), as well as the mime type of the content.
+ static void FixupEncodingTypes(bool is_sdch_response,
+ const std::string& mime_type,
+ std::vector<FilterType>* encoding_types);
protected:
- // Specifies type of filters that can be created.
- enum FilterType {
- FILTER_TYPE_DEFLATE,
- FILTER_TYPE_GZIP,
- FILTER_TYPE_BZIP2,
- FILTER_TYPE_GZIP_HELPING_SDCH,
- FILTER_TYPE_SDCH, // open-vcdiff compression relative to a dictionary.
- FILTER_TYPE_UNSUPPORTED
- };
-
Filter();
FRIEND_TEST(SdchFilterTest, ContentTypeId);
@@ -144,11 +158,6 @@ class Filter {
// Buffer_size is the maximum size of stream_buffer_ in number of chars.
bool InitBuffer(int buffer_size);
- // Translate the text of a filter name (from Content-Encoding header) into a
- // FilterType, in the context of a mime type.
- static FilterType ConvertEncodingToType(const std::string& filter_type,
- const std::string& mime_type);
-
// A factory helper for creating filters for within a chain of potentially
// multiple encodings. If a chain of filters is created, then this may be
// called multiple times during the filter creation process. In most simple