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

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

Issue 100004: Hand craft an A/B test of SDCH compression... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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_unittest.h » ('j') | no next file with comments »
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 30 matching lines...) Expand all
41 41
42 //------------------------------------------------------------------------------ 42 //------------------------------------------------------------------------------
43 // Define an interface class that allows access to contextual information 43 // Define an interface class that allows access to contextual information
44 // supplied by the owner of this filter. In the case where there are a chain of 44 // supplied by the owner of this filter. In the case where there are a chain of
45 // filters, there is only one owner of all the chained filters, and that context 45 // filters, there is only one owner of all the chained filters, and that context
46 // is passed to the constructor of all those filters. To be clear, the context 46 // is passed to the constructor of all those filters. To be clear, the context
47 // does NOT reflect the position in a chain, or the fact that there are prior 47 // does NOT reflect the position in a chain, or the fact that there are prior
48 // or later filters in a chain. 48 // or later filters in a chain.
49 class FilterContext { 49 class FilterContext {
50 public: 50 public:
51 // Enum to control what histograms are emitted near end-of-life of this
52 // instance.
53 enum StatisticSelector {
54 SDCH_DECODE,
55 SDCH_PASSTHROUGH,
56 SDCH_EXPERIMENT_DECODE,
57 SDCH_EXPERIMENT_HOLDBACK,
58 };
59
51 virtual ~FilterContext() {} 60 virtual ~FilterContext() {}
52 61
53 // What mime type was specified in the header for this data? 62 // What mime type was specified in the header for this data?
54 // Only makes senses for some types of contexts, and returns false 63 // Only makes senses for some types of contexts, and returns false
55 // when not applicable. 64 // when not applicable.
56 virtual bool GetMimeType(std::string* mime_type) const = 0; 65 virtual bool GetMimeType(std::string* mime_type) const = 0;
57 66
58 // What URL was used to access this data? 67 // What URL was used to access this data?
59 // Return false if gurl is not present. 68 // Return false if gurl is not present.
60 virtual bool GetURL(GURL* gurl) const = 0; 69 virtual bool GetURL(GURL* gurl) const = 0;
(...skipping 17 matching lines...) Expand all
78 // What response code was received with the associated network transaction? 87 // What response code was received with the associated network transaction?
79 // For example: 200 is ok. 4xx are error codes. etc. 88 // For example: 200 is ok. 4xx are error codes. etc.
80 virtual int GetResponseCode() const = 0; 89 virtual int GetResponseCode() const = 0;
81 90
82 // What is the desirable input buffer size for these filters? 91 // What is the desirable input buffer size for these filters?
83 // This value is currently supplied by the context, and is constant for all 92 // This value is currently supplied by the context, and is constant for all
84 // filters, even when they are part of a chain of filters. (i.e., we currently 93 // filters, even when they are part of a chain of filters. (i.e., we currently
85 // don't change the input buffer sizes for a linked chain of filters, and the 94 // don't change the input buffer sizes for a linked chain of filters, and the
86 // buffer size for input to all filters in a chain is this one constant). 95 // buffer size for input to all filters in a chain is this one constant).
87 virtual int GetInputStreamBufferSize() const = 0; 96 virtual int GetInputStreamBufferSize() const = 0;
97
98 // The following method forces the context to emit a specific set of
99 // statistics as selected by the argument.
100 virtual void RecordPacketStats(StatisticSelector statistic) const = 0;
88 }; 101 };
89 102
90 //------------------------------------------------------------------------------ 103 //------------------------------------------------------------------------------
91 class Filter { 104 class Filter {
92 public: 105 public:
93 // Return values of function ReadFilteredData. 106 // Return values of function ReadFilteredData.
94 enum FilterStatus { 107 enum FilterStatus {
95 // Read filtered data successfully 108 // Read filtered data successfully
96 FILTER_OK, 109 FILTER_OK,
97 // Read filtered data successfully, and the data in the buffer has been 110 // Read filtered data successfully, and the data in the buffer has been
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 185
173 // Given a array of encoding_types, try to do some error recovery adjustment 186 // Given a array of encoding_types, try to do some error recovery adjustment
174 // to the list. This includes handling known bugs in the Apache server (where 187 // to the list. This includes handling known bugs in the Apache server (where
175 // redundant gzip encoding is specified), as well as issues regarding SDCH 188 // redundant gzip encoding is specified), as well as issues regarding SDCH
176 // encoding, where various proxies and anti-virus products modify or strip the 189 // encoding, where various proxies and anti-virus products modify or strip the
177 // encodings. These fixups require context, which includes whether this 190 // encodings. These fixups require context, which includes whether this
178 // response was made to an SDCH request (i.e., an available dictionary was 191 // response was made to an SDCH request (i.e., an available dictionary was
179 // advertised in the GET), as well as the mime type of the content. 192 // advertised in the GET), as well as the mime type of the content.
180 static void FixupEncodingTypes(const FilterContext& filter_context, 193 static void FixupEncodingTypes(const FilterContext& filter_context,
181 std::vector<FilterType>* encoding_types); 194 std::vector<FilterType>* encoding_types);
195
182 protected: 196 protected:
183 explicit Filter(const FilterContext& filter_context); 197 explicit Filter(const FilterContext& filter_context);
184 198
185 FRIEND_TEST(SdchFilterTest, ContentTypeId); 199 FRIEND_TEST(SdchFilterTest, ContentTypeId);
186 // Filters the data stored in stream_buffer_ and writes the output into the 200 // Filters the data stored in stream_buffer_ and writes the output into the
187 // dest_buffer passed in. 201 // dest_buffer passed in.
188 // 202 //
189 // Upon entry, *dest_len is the total size (in number of chars) of the 203 // Upon entry, *dest_len is the total size (in number of chars) of the
190 // destination buffer. Upon exit, *dest_len is the actual number of chars 204 // destination buffer. Upon exit, *dest_len is the actual number of chars
191 // written into the destination buffer. 205 // written into the destination buffer.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 255
242 // Context data from the owner of this filter. Some filters need additional 256 // Context data from the owner of this filter. Some filters need additional
243 // context information (mime type, etc.) to properly function, and they access 257 // context information (mime type, etc.) to properly function, and they access
244 // this data via this reference member. 258 // this data via this reference member.
245 const FilterContext& filter_context_; 259 const FilterContext& filter_context_;
246 260
247 DISALLOW_COPY_AND_ASSIGN(Filter); 261 DISALLOW_COPY_AND_ASSIGN(Filter);
248 }; 262 };
249 263
250 #endif // NET_BASE_FILTER_H__ 264 #endif // NET_BASE_FILTER_H__
OLDNEW
« no previous file with comments | « no previous file | net/base/filter_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698