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

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

Issue 6516025: Remove GetInputStreamBufferSize() method from FilterContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed lint Created 9 years, 10 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/sdch_filter_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 25 matching lines...) Expand all
36 #include "base/basictypes.h" 36 #include "base/basictypes.h"
37 #include "base/gtest_prod_util.h" 37 #include "base/gtest_prod_util.h"
38 #include "base/ref_counted.h" 38 #include "base/ref_counted.h"
39 #include "base/scoped_ptr.h" 39 #include "base/scoped_ptr.h"
40 #include "base/time.h" 40 #include "base/time.h"
41 41
42 class GURL; 42 class GURL;
43 43
44 namespace net { 44 namespace net {
45 class IOBuffer; 45 class IOBuffer;
46 class SdchFilterChainingTest;
46 } 47 }
47 48
48 //------------------------------------------------------------------------------ 49 //------------------------------------------------------------------------------
49 // Define an interface class that allows access to contextual information 50 // Define an interface class that allows access to contextual information
50 // supplied by the owner of this filter. In the case where there are a chain of 51 // supplied by the owner of this filter. In the case where there are a chain of
51 // filters, there is only one owner of all the chained filters, and that context 52 // filters, there is only one owner of all the chained filters, and that context
52 // is passed to the constructor of all those filters. To be clear, the context 53 // is passed to the constructor of all those filters. To be clear, the context
53 // does NOT reflect the position in a chain, or the fact that there are prior 54 // does NOT reflect the position in a chain, or the fact that there are prior
54 // or later filters in a chain. 55 // or later filters in a chain.
55 class FilterContext { 56 class FilterContext {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 virtual bool IsSdchResponse() const = 0; 88 virtual bool IsSdchResponse() const = 0;
88 89
89 // How many bytes were read from the net or cache so far (and potentially 90 // How many bytes were read from the net or cache so far (and potentially
90 // pushed into a filter for processing)? 91 // pushed into a filter for processing)?
91 virtual int64 GetByteReadCount() const = 0; 92 virtual int64 GetByteReadCount() const = 0;
92 93
93 // What response code was received with the associated network transaction? 94 // What response code was received with the associated network transaction?
94 // For example: 200 is ok. 4xx are error codes. etc. 95 // For example: 200 is ok. 4xx are error codes. etc.
95 virtual int GetResponseCode() const = 0; 96 virtual int GetResponseCode() const = 0;
96 97
97 // What is the desirable input buffer size for these filters?
98 // This value is currently supplied by the context, and is constant for all
99 // filters, even when they are part of a chain of filters. (i.e., we currently
100 // don't change the input buffer sizes for a linked chain of filters, and the
101 // buffer size for input to all filters in a chain is this one constant).
102 virtual int GetInputStreamBufferSize() const = 0;
103
104 // The following method forces the context to emit a specific set of 98 // The following method forces the context to emit a specific set of
105 // statistics as selected by the argument. 99 // statistics as selected by the argument.
106 virtual void RecordPacketStats(StatisticSelector statistic) const = 0; 100 virtual void RecordPacketStats(StatisticSelector statistic) const = 0;
107 }; 101 };
108 102
109 //------------------------------------------------------------------------------ 103 //------------------------------------------------------------------------------
110 class Filter { 104 class Filter {
111 public: 105 public:
112 // Return values of function ReadFilteredData. 106 // Return values of function ReadFilteredData.
113 enum FilterStatus { 107 enum FilterStatus {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // to the list. This includes handling known bugs in the Apache server (where 186 // to the list. This includes handling known bugs in the Apache server (where
193 // redundant gzip encoding is specified), as well as issues regarding SDCH 187 // redundant gzip encoding is specified), as well as issues regarding SDCH
194 // encoding, where various proxies and anti-virus products modify or strip the 188 // encoding, where various proxies and anti-virus products modify or strip the
195 // encodings. These fixups require context, which includes whether this 189 // encodings. These fixups require context, which includes whether this
196 // response was made to an SDCH request (i.e., an available dictionary was 190 // response was made to an SDCH request (i.e., an available dictionary was
197 // advertised in the GET), as well as the mime type of the content. 191 // advertised in the GET), as well as the mime type of the content.
198 static void FixupEncodingTypes(const FilterContext& filter_context, 192 static void FixupEncodingTypes(const FilterContext& filter_context,
199 std::vector<FilterType>* encoding_types); 193 std::vector<FilterType>* encoding_types);
200 194
201 protected: 195 protected:
202 FRIEND_TEST_ALL_PREFIXES(SdchFilterTest, ContentTypeId); 196 FRIEND_TEST_ALL_PREFIXES(GZipUnitTest, DecodeWithSmallBuffer);
197 FRIEND_TEST_ALL_PREFIXES(GZipUnitTest, DecodeWithOneByteBuffer);
198 FRIEND_TEST_ALL_PREFIXES(GZipUnitTest,
199 DecodeWithOneByteInputAndOutputBuffer);
200 friend class net::SdchFilterChainingTest;
203 201
204 explicit Filter(const FilterContext& filter_context); 202 explicit Filter(const FilterContext& filter_context);
205 203
206 // Filters the data stored in stream_buffer_ and writes the output into the 204 // Filters the data stored in stream_buffer_ and writes the output into the
207 // dest_buffer passed in. 205 // dest_buffer passed in.
208 // 206 //
209 // Upon entry, *dest_len is the total size (in number of chars) of the 207 // Upon entry, *dest_len is the total size (in number of chars) of the
210 // destination buffer. Upon exit, *dest_len is the actual number of chars 208 // destination buffer. Upon exit, *dest_len is the actual number of chars
211 // written into the destination buffer. 209 // written into the destination buffer.
212 // 210 //
(...skipping 25 matching lines...) Expand all
238 private: 236 private:
239 // A factory helper for creating filters for within a chain of potentially 237 // A factory helper for creating filters for within a chain of potentially
240 // multiple encodings. If a chain of filters is created, then this may be 238 // multiple encodings. If a chain of filters is created, then this may be
241 // called multiple times during the filter creation process. In most simple 239 // called multiple times during the filter creation process. In most simple
242 // cases, this is only called once. Returns NULL and cleans up (deleting 240 // cases, this is only called once. Returns NULL and cleans up (deleting
243 // filter_list) if a new filter can't be constructed. 241 // filter_list) if a new filter can't be constructed.
244 static Filter* PrependNewFilter(FilterType type_id, 242 static Filter* PrependNewFilter(FilterType type_id,
245 const FilterContext& filter_context, 243 const FilterContext& filter_context,
246 Filter* filter_list); 244 Filter* filter_list);
247 245
248 // Allocates and initializes stream_buffer_ based on filter_context_.
249 // Establishes a buffer large enough to handle the amount specified in
250 // filter_context_.GetInputStreamBufferSize().
251 bool InitBuffer();
252
253 // Helper function to empty our output into the next filter's input. 246 // Helper function to empty our output into the next filter's input.
254 void PushDataIntoNextFilter(); 247 void PushDataIntoNextFilter();
255 248
249 // Resets the filter's internal buffer to the given size. Should only
250 // be called in unit tests, and only immediately after filter construction.
251 void ResetInputBufferForTest(int size);
252
256 // An optional filter to process output from this filter. 253 // An optional filter to process output from this filter.
257 scoped_ptr<Filter> next_filter_; 254 scoped_ptr<Filter> next_filter_;
258 // Remember what status or local filter last returned so we can better handle 255 // Remember what status or local filter last returned so we can better handle
259 // chained filters. 256 // chained filters.
260 FilterStatus last_status_; 257 FilterStatus last_status_;
261 258
262 // Context data from the owner of this filter. Some filters need additional 259 // Context data from the owner of this filter. Some filters need additional
263 // context information (mime type, etc.) to properly function, and they access 260 // context information (mime type, etc.) to properly function, and they access
264 // this data via this reference member. 261 // this data via this reference member.
265 const FilterContext& filter_context_; 262 const FilterContext& filter_context_;
266 263
267 DISALLOW_COPY_AND_ASSIGN(Filter); 264 DISALLOW_COPY_AND_ASSIGN(Filter);
268 }; 265 };
269 266
270 #endif // NET_BASE_FILTER_H__ 267 #endif // NET_BASE_FILTER_H__
OLDNEW
« no previous file with comments | « no previous file | net/base/filter.cc » ('j') | net/base/sdch_filter_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698