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 // The basic usage of the Filter interface is described in the comment at | 5 // The basic usage of the Filter interface is described in the comment at |
6 // the beginning of filter.h. If Filter::Factory is passed a vector of | 6 // the beginning of filter.h. If Filter::Factory is passed a vector of |
7 // size greater than 1, that interface is implemented by a series of filters | 7 // size greater than 1, that interface is implemented by a series of filters |
8 // connected in a chain. In such a case the first filter | 8 // connected in a chain. In such a case the first filter |
9 // in the chain proxies calls to ReadData() so that its return values | 9 // in the chain proxies calls to ReadData() so that its return values |
10 // apply to the entire chain. | 10 // apply to the entire chain. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 next_stream_data_ = stream_buffer()->data(); | 176 next_stream_data_ = stream_buffer()->data(); |
177 stream_data_len_ = stream_data_len; | 177 stream_data_len_ = stream_data_len; |
178 last_status_ = FILTER_OK; | 178 last_status_ = FILTER_OK; |
179 return true; | 179 return true; |
180 } | 180 } |
181 | 181 |
182 // static | 182 // static |
183 Filter::FilterType Filter::ConvertEncodingToType( | 183 Filter::FilterType Filter::ConvertEncodingToType( |
184 const std::string& filter_type) { | 184 const std::string& filter_type) { |
185 FilterType type_id; | 185 FilterType type_id; |
186 if (LowerCaseEqualsASCII(filter_type, kDeflate)) { | 186 if (base::LowerCaseEqualsASCII(filter_type, kDeflate)) { |
187 type_id = FILTER_TYPE_DEFLATE; | 187 type_id = FILTER_TYPE_DEFLATE; |
188 } else if (LowerCaseEqualsASCII(filter_type, kGZip) || | 188 } else if (base::LowerCaseEqualsASCII(filter_type, kGZip) || |
189 LowerCaseEqualsASCII(filter_type, kXGZip)) { | 189 base::LowerCaseEqualsASCII(filter_type, kXGZip)) { |
190 type_id = FILTER_TYPE_GZIP; | 190 type_id = FILTER_TYPE_GZIP; |
191 } else if (LowerCaseEqualsASCII(filter_type, kSdch)) { | 191 } else if (base::LowerCaseEqualsASCII(filter_type, kSdch)) { |
192 type_id = FILTER_TYPE_SDCH; | 192 type_id = FILTER_TYPE_SDCH; |
193 } else { | 193 } else { |
194 // Note we also consider "identity" and "uncompressed" UNSUPPORTED as | 194 // Note we also consider "identity" and "uncompressed" UNSUPPORTED as |
195 // filter should be disabled in such cases. | 195 // filter should be disabled in such cases. |
196 type_id = FILTER_TYPE_UNSUPPORTED; | 196 type_id = FILTER_TYPE_UNSUPPORTED; |
197 } | 197 } |
198 return type_id; | 198 return type_id; |
199 } | 199 } |
200 | 200 |
201 // static | 201 // static |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 // no change in actual content). The last observed corruption it to actually | 259 // no change in actual content). The last observed corruption it to actually |
260 // change the content, such as by re-gzipping it, and that may happen along | 260 // change the content, such as by re-gzipping it, and that may happen along |
261 // with corruption of the stated content encoding (wow!). | 261 // with corruption of the stated content encoding (wow!). |
262 | 262 |
263 // The one unresolved failure mode comes when we advertise a dictionary, and | 263 // The one unresolved failure mode comes when we advertise a dictionary, and |
264 // the server tries to *send* a gzipped file (not gzip encode content), and | 264 // the server tries to *send* a gzipped file (not gzip encode content), and |
265 // then we could do a gzip decode :-(. Since SDCH is only (currently) | 265 // then we could do a gzip decode :-(. Since SDCH is only (currently) |
266 // supported server side on paths that only send HTML content, this mode has | 266 // supported server side on paths that only send HTML content, this mode has |
267 // never surfaced in the wild (and is unlikely to). | 267 // never surfaced in the wild (and is unlikely to). |
268 // We will gather a lot of stats as we perform the fixups | 268 // We will gather a lot of stats as we perform the fixups |
269 if (StartsWithASCII(mime_type, kTextHtml, false)) { | 269 if (base::StartsWithASCII(mime_type, kTextHtml, false)) { |
270 // Suspicious case: Advertised dictionary, but server didn't use sdch, and | 270 // Suspicious case: Advertised dictionary, but server didn't use sdch, and |
271 // we're HTML tagged. | 271 // we're HTML tagged. |
272 if (encoding_types->empty()) { | 272 if (encoding_types->empty()) { |
273 LogSdchProblem(filter_context, SDCH_ADDED_CONTENT_ENCODING); | 273 LogSdchProblem(filter_context, SDCH_ADDED_CONTENT_ENCODING); |
274 } else if (1 == encoding_types->size()) { | 274 } else if (1 == encoding_types->size()) { |
275 LogSdchProblem(filter_context, SDCH_FIXED_CONTENT_ENCODING); | 275 LogSdchProblem(filter_context, SDCH_FIXED_CONTENT_ENCODING); |
276 } else { | 276 } else { |
277 LogSdchProblem(filter_context, SDCH_FIXED_CONTENT_ENCODINGS); | 277 LogSdchProblem(filter_context, SDCH_FIXED_CONTENT_ENCODINGS); |
278 } | 278 } |
279 } else { | 279 } else { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 | 403 |
404 void Filter::PushDataIntoNextFilter() { | 404 void Filter::PushDataIntoNextFilter() { |
405 IOBuffer* next_buffer = next_filter_->stream_buffer(); | 405 IOBuffer* next_buffer = next_filter_->stream_buffer(); |
406 int next_size = next_filter_->stream_buffer_size(); | 406 int next_size = next_filter_->stream_buffer_size(); |
407 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); | 407 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); |
408 if (FILTER_ERROR != last_status_) | 408 if (FILTER_ERROR != last_status_) |
409 next_filter_->FlushStreamBuffer(next_size); | 409 next_filter_->FlushStreamBuffer(next_size); |
410 } | 410 } |
411 | 411 |
412 } // namespace net | 412 } // namespace net |
OLD | NEW |