| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Filter performs filtering on data streams. Sample usage: | 5 // Filter performs filtering on data streams. Sample usage: |
| 6 // | 6 // |
| 7 // IStream* pre_filter_source; | 7 // IStream* pre_filter_source; |
| 8 // ... | 8 // ... |
| 9 // Filter* filter = Filter::Factory(filter_type, size); | 9 // Filter* filter = Filter::Factory(filter_type, size); |
| 10 // int pre_filter_data_len = filter->stream_buffer_size(); | 10 // int pre_filter_data_len = filter->stream_buffer_size(); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // Given a array of encoding_types, try to do some error recovery adjustment | 218 // Given a array of encoding_types, try to do some error recovery adjustment |
| 219 // to the list. This includes handling known bugs in the Apache server (where | 219 // to the list. This includes handling known bugs in the Apache server (where |
| 220 // redundant gzip encoding is specified), as well as issues regarding SDCH | 220 // redundant gzip encoding is specified), as well as issues regarding SDCH |
| 221 // encoding, where various proxies and anti-virus products modify or strip the | 221 // encoding, where various proxies and anti-virus products modify or strip the |
| 222 // encodings. These fixups require context, which includes whether this | 222 // encodings. These fixups require context, which includes whether this |
| 223 // response was made to an SDCH request (i.e., an available dictionary was | 223 // response was made to an SDCH request (i.e., an available dictionary was |
| 224 // advertised in the GET), as well as the mime type of the content. | 224 // advertised in the GET), as well as the mime type of the content. |
| 225 static void FixupEncodingTypes(const FilterContext& filter_context, | 225 static void FixupEncodingTypes(const FilterContext& filter_context, |
| 226 std::vector<FilterType>* encoding_types); | 226 std::vector<FilterType>* encoding_types); |
| 227 | 227 |
| 228 // Returns a string describing the FilterTypes implemented by this filter. |
| 229 std::string OrderedFilterList() const; |
| 230 |
| 228 protected: | 231 protected: |
| 229 friend class GZipUnitTest; | 232 friend class GZipUnitTest; |
| 230 friend class SdchFilterChainingTest; | 233 friend class SdchFilterChainingTest; |
| 231 FRIEND_TEST_ALL_PREFIXES(FilterTest, ThreeFilterChain); | 234 FRIEND_TEST_ALL_PREFIXES(FilterTest, ThreeFilterChain); |
| 232 | 235 |
| 233 Filter(); | 236 explicit Filter(FilterType type_id); |
| 234 | 237 |
| 235 // Filters the data stored in stream_buffer_ and writes the output into the | 238 // Filters the data stored in stream_buffer_ and writes the output into the |
| 236 // dest_buffer passed in. | 239 // dest_buffer passed in. |
| 237 // | 240 // |
| 238 // Upon entry, *dest_len is the total size (in number of chars) of the | 241 // Upon entry, *dest_len is the total size (in number of chars) of the |
| 239 // destination buffer. Upon exit, *dest_len is the actual number of chars | 242 // destination buffer. Upon exit, *dest_len is the actual number of chars |
| 240 // written into the destination buffer. | 243 // written into the destination buffer. |
| 241 // | 244 // |
| 242 // This function will fail if there is no pre-filter data in the | 245 // This function will fail if there is no pre-filter data in the |
| 243 // stream_buffer_. On the other hand, *dest_len can be 0 upon successful | 246 // stream_buffer_. On the other hand, *dest_len can be 0 upon successful |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 void PushDataIntoNextFilter(); | 290 void PushDataIntoNextFilter(); |
| 288 | 291 |
| 289 // Constructs a filter with an internal buffer of the given size. | 292 // Constructs a filter with an internal buffer of the given size. |
| 290 // Only meant to be called by unit tests that need to control the buffer size. | 293 // Only meant to be called by unit tests that need to control the buffer size. |
| 291 static Filter* FactoryForTests(const std::vector<FilterType>& filter_types, | 294 static Filter* FactoryForTests(const std::vector<FilterType>& filter_types, |
| 292 const FilterContext& filter_context, | 295 const FilterContext& filter_context, |
| 293 int buffer_size); | 296 int buffer_size); |
| 294 | 297 |
| 295 // An optional filter to process output from this filter. | 298 // An optional filter to process output from this filter. |
| 296 scoped_ptr<Filter> next_filter_; | 299 scoped_ptr<Filter> next_filter_; |
| 300 |
| 297 // Remember what status or local filter last returned so we can better handle | 301 // Remember what status or local filter last returned so we can better handle |
| 298 // chained filters. | 302 // chained filters. |
| 299 FilterStatus last_status_; | 303 FilterStatus last_status_; |
| 300 | 304 |
| 305 // The filter type this filter was constructed from. |
| 306 FilterType type_id_; |
| 307 |
| 301 DISALLOW_COPY_AND_ASSIGN(Filter); | 308 DISALLOW_COPY_AND_ASSIGN(Filter); |
| 302 }; | 309 }; |
| 303 | 310 |
| 304 } // namespace net | 311 } // namespace net |
| 305 | 312 |
| 306 #endif // NET_FILTER_FILTER_H__ | 313 #endif // NET_FILTER_FILTER_H__ |
| OLD | NEW |