Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: net/filter/filter.h

Issue 1431723002: Add brotli content-encoding filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebaseline Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 FILTER_NEED_MORE_DATA, 146 FILTER_NEED_MORE_DATA,
147 // Read filtered data successfully, and filter reaches the end of the data 147 // Read filtered data successfully, and filter reaches the end of the data
148 // stream. 148 // stream.
149 FILTER_DONE, 149 FILTER_DONE,
150 // There is an error during filtering. 150 // There is an error during filtering.
151 FILTER_ERROR 151 FILTER_ERROR
152 }; 152 };
153 153
154 // Specifies type of filters that can be created. 154 // Specifies type of filters that can be created.
155 enum FilterType { 155 enum FilterType {
156 FILTER_TYPE_BROTLI,
156 FILTER_TYPE_DEFLATE, 157 FILTER_TYPE_DEFLATE,
157 FILTER_TYPE_GZIP, 158 FILTER_TYPE_GZIP,
158 FILTER_TYPE_GZIP_HELPING_SDCH, // Gzip possible, but pass through allowed. 159 FILTER_TYPE_GZIP_HELPING_SDCH, // Gzip possible, but pass through allowed.
159 FILTER_TYPE_SDCH, 160 FILTER_TYPE_SDCH,
160 FILTER_TYPE_SDCH_POSSIBLE, // Sdch possible, but pass through allowed. 161 FILTER_TYPE_SDCH_POSSIBLE, // Sdch possible, but pass through allowed.
161 FILTER_TYPE_UNSUPPORTED, 162 FILTER_TYPE_UNSUPPORTED,
162 }; 163 };
163 164
164 virtual ~Filter(); 165 virtual ~Filter();
165 166
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // encodings. These fixups require context, which includes whether this 227 // encodings. These fixups require context, which includes whether this
227 // response was made to an SDCH request (i.e., an available dictionary was 228 // response was made to an SDCH request (i.e., an available dictionary was
228 // advertised in the GET), as well as the mime type of the content. 229 // advertised in the GET), as well as the mime type of the content.
229 static void FixupEncodingTypes(const FilterContext& filter_context, 230 static void FixupEncodingTypes(const FilterContext& filter_context,
230 std::vector<FilterType>* encoding_types); 231 std::vector<FilterType>* encoding_types);
231 232
232 // Returns a string describing the FilterTypes implemented by this filter. 233 // Returns a string describing the FilterTypes implemented by this filter.
233 std::string OrderedFilterList() const; 234 std::string OrderedFilterList() const;
234 235
235 protected: 236 protected:
237 friend class BrotliUnitTest;
236 friend class GZipUnitTest; 238 friend class GZipUnitTest;
237 friend class SdchFilterChainingTest; 239 friend class SdchFilterChainingTest;
238 FRIEND_TEST_ALL_PREFIXES(FilterTest, ThreeFilterChain); 240 FRIEND_TEST_ALL_PREFIXES(FilterTest, ThreeFilterChain);
239 241
240 explicit Filter(FilterType type_id); 242 explicit Filter(FilterType type_id);
241 243
242 // Filters the data stored in stream_buffer_ and writes the output into the 244 // Filters the data stored in stream_buffer_ and writes the output into the
243 // dest_buffer passed in. 245 // dest_buffer passed in.
244 // 246 //
245 // Upon entry, *dest_len is the total size (in number of chars) of the 247 // Upon entry, *dest_len is the total size (in number of chars) of the
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // called multiple times during the filter creation process. In most simple 280 // called multiple times during the filter creation process. In most simple
279 // cases, this is only called once. Returns NULL and cleans up (deleting 281 // cases, this is only called once. Returns NULL and cleans up (deleting
280 // filter_list) if a new filter can't be constructed. 282 // filter_list) if a new filter can't be constructed.
281 static Filter* PrependNewFilter(FilterType type_id, 283 static Filter* PrependNewFilter(FilterType type_id,
282 const FilterContext& filter_context, 284 const FilterContext& filter_context,
283 int buffer_size, 285 int buffer_size,
284 Filter* filter_list); 286 Filter* filter_list);
285 287
286 // Helper methods for PrependNewFilter. If initialization is successful, 288 // Helper methods for PrependNewFilter. If initialization is successful,
287 // they return a fully initialized Filter. Otherwise, return NULL. 289 // they return a fully initialized Filter. Otherwise, return NULL.
290 static Filter* InitBrotliFilter(FilterType type_id, int buffer_size);
288 static Filter* InitGZipFilter(FilterType type_id, int buffer_size); 291 static Filter* InitGZipFilter(FilterType type_id, int buffer_size);
289 static Filter* InitSdchFilter(FilterType type_id, 292 static Filter* InitSdchFilter(FilterType type_id,
290 const FilterContext& filter_context, 293 const FilterContext& filter_context,
291 int buffer_size); 294 int buffer_size);
292 295
293 // Helper function to empty our output into the next filter's input. 296 // Helper function to empty our output into the next filter's input.
294 void PushDataIntoNextFilter(); 297 void PushDataIntoNextFilter();
295 298
296 // Constructs a filter with an internal buffer of the given size. 299 // Constructs a filter with an internal buffer of the given size.
297 // Only meant to be called by unit tests that need to control the buffer size. 300 // Only meant to be called by unit tests that need to control the buffer size.
(...skipping 10 matching lines...) Expand all
308 311
309 // The filter type this filter was constructed from. 312 // The filter type this filter was constructed from.
310 FilterType type_id_; 313 FilterType type_id_;
311 314
312 DISALLOW_COPY_AND_ASSIGN(Filter); 315 DISALLOW_COPY_AND_ASSIGN(Filter);
313 }; 316 };
314 317
315 } // namespace net 318 } // namespace net
316 319
317 #endif // NET_FILTER_FILTER_H__ 320 #endif // NET_FILTER_FILTER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698