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

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

Issue 6674042: Make URLRequestHttpJob the only URLRequestJob concerned with FilterContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Responded to comments from willchan Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/filter.cc » ('j') | net/base/filter.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 virtual ~Filter(); 131 virtual ~Filter();
132 132
133 // Creates a Filter object. 133 // Creates a Filter object.
134 // Parameters: Filter_types specifies the type of filter created; 134 // Parameters: Filter_types specifies the type of filter created;
135 // filter_context allows filters to acquire additional details needed for 135 // filter_context allows filters to acquire additional details needed for
136 // construction and operation, such as a specification of requisite input 136 // construction and operation, such as a specification of requisite input
137 // buffer size. 137 // buffer size.
138 // If success, the function returns the pointer to the Filter object created. 138 // If success, the function returns the pointer to the Filter object created.
139 // If failed or a filter is not needed, the function returns NULL. 139 // If failed or a filter is not needed, the function returns NULL.
140 // 140 //
141 // Note: filter_types is an array of filter names (content encoding types as 141 // Note: filter_types is an array of filter types (content encoding types as
142 // provided in an HTTP header), which will be chained together serially to do 142 // provided in an HTTP header), which will be chained together serially to do
143 // successive filtering of data. The names in the vector are ordered based on 143 // successive filtering of data. The types in the vector are ordered based on
144 // encoding order, and the filters are chained to operate in the reverse 144 // encoding order, and the filters are chained to operate in the reverse
145 // (decoding) order. For example, types[0] = "sdch", types[1] = "gzip" will 145 // (decoding) order. For example, types[0] = FILTER_TYPE_SDCH,
146 // cause data to first be gunizip filtered, and the resulting output from that 146 // types[1] = FILTER_TYPE_GZIP will cause data to first be gunzip filtered,
147 // filter will be sdch decoded. 147 // and the resulting output from that filter will be sdch decoded.
148 static Filter* Factory(const std::vector<FilterType>& filter_types, 148 static Filter* Factory(const std::vector<FilterType>& filter_types,
149 const FilterContext& filter_context); 149 const FilterContext& filter_context);
150 150
151 // A simpler version of Factory() which creates a single, unchained
152 // Filter of type FILTER_TYPE_GZIP, or NULL if the filter could not be
153 // initialized.
154 static Filter* GZipFactory();
155
151 // External call to obtain data from this filter chain. If ther is no 156 // External call to obtain data from this filter chain. If ther is no
152 // next_filter_, then it obtains data from this specific filter. 157 // next_filter_, then it obtains data from this specific filter.
153 FilterStatus ReadData(char* dest_buffer, int* dest_len); 158 FilterStatus ReadData(char* dest_buffer, int* dest_len);
154 159
155 // Returns a pointer to the stream_buffer_. 160 // Returns a pointer to the stream_buffer_.
156 net::IOBuffer* stream_buffer() const { return stream_buffer_.get(); } 161 net::IOBuffer* stream_buffer() const { return stream_buffer_.get(); }
157 162
158 // Returns the maximum size of stream_buffer_ in number of chars. 163 // Returns the maximum size of stream_buffer_ in number of chars.
159 int stream_buffer_size() const { return stream_buffer_size_; } 164 int stream_buffer_size() const { return stream_buffer_size_; }
160 165
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // A factory helper for creating filters for within a chain of potentially 239 // A factory helper for creating filters for within a chain of potentially
235 // multiple encodings. If a chain of filters is created, then this may be 240 // multiple encodings. If a chain of filters is created, then this may be
236 // called multiple times during the filter creation process. In most simple 241 // called multiple times during the filter creation process. In most simple
237 // cases, this is only called once. Returns NULL and cleans up (deleting 242 // cases, this is only called once. Returns NULL and cleans up (deleting
238 // filter_list) if a new filter can't be constructed. 243 // filter_list) if a new filter can't be constructed.
239 static Filter* PrependNewFilter(FilterType type_id, 244 static Filter* PrependNewFilter(FilterType type_id,
240 const FilterContext& filter_context, 245 const FilterContext& filter_context,
241 int buffer_size, 246 int buffer_size,
242 Filter* filter_list); 247 Filter* filter_list);
243 248
249 // Helper methods for PrependNewFilter. If initialization is successful,
250 // they return a fully initialized Filter. Otherwise, return NULL.
251 static Filter* InitGZipFilter(FilterType type_id, int buffer_size);
252 static Filter* InitSdchFilter(FilterType type_id,
253 const FilterContext& filter_context,
254 int buffer_size);
255
244 // Helper function to empty our output into the next filter's input. 256 // Helper function to empty our output into the next filter's input.
245 void PushDataIntoNextFilter(); 257 void PushDataIntoNextFilter();
246 258
247 // Constructs a filter with an internal buffer of the given size. 259 // Constructs a filter with an internal buffer of the given size.
248 // Only meant to be called by unit tests that need to control the buffer size. 260 // Only meant to be called by unit tests that need to control the buffer size.
249 static Filter* FactoryForTests(const std::vector<FilterType>& filter_types, 261 static Filter* FactoryForTests(const std::vector<FilterType>& filter_types,
250 const FilterContext& filter_context, 262 const FilterContext& filter_context,
251 int buffer_size); 263 int buffer_size);
252 264
253 // An optional filter to process output from this filter. 265 // An optional filter to process output from this filter.
254 scoped_ptr<Filter> next_filter_; 266 scoped_ptr<Filter> next_filter_;
255 // Remember what status or local filter last returned so we can better handle 267 // Remember what status or local filter last returned so we can better handle
256 // chained filters. 268 // chained filters.
257 FilterStatus last_status_; 269 FilterStatus last_status_;
258 270
259 DISALLOW_COPY_AND_ASSIGN(Filter); 271 DISALLOW_COPY_AND_ASSIGN(Filter);
260 }; 272 };
261 273
262 } // namespace net 274 } // namespace net
263 275
264 #endif // NET_BASE_FILTER_H__ 276 #endif // NET_BASE_FILTER_H__
OLDNEW
« no previous file with comments | « no previous file | net/base/filter.cc » ('j') | net/base/filter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698