| 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 13 matching lines...) Expand all Loading... |
| 24 #include "net/filter/filter.h" | 24 #include "net/filter/filter.h" |
| 25 | 25 |
| 26 #include "base/files/file_path.h" | 26 #include "base/files/file_path.h" |
| 27 #include "base/strings/string_util.h" | 27 #include "base/strings/string_util.h" |
| 28 #include "base/values.h" | 28 #include "base/values.h" |
| 29 #include "net/base/io_buffer.h" | 29 #include "net/base/io_buffer.h" |
| 30 #include "net/base/sdch_net_log_params.h" | 30 #include "net/base/sdch_net_log_params.h" |
| 31 #include "net/filter/brotli_filter.h" | 31 #include "net/filter/brotli_filter.h" |
| 32 #include "net/filter/gzip_filter.h" | 32 #include "net/filter/gzip_filter.h" |
| 33 #include "net/filter/sdch_filter.h" | 33 #include "net/filter/sdch_filter.h" |
| 34 #include "net/log/net_log_event_type.h" |
| 34 #include "net/url_request/url_request_context.h" | 35 #include "net/url_request/url_request_context.h" |
| 35 #include "url/gurl.h" | 36 #include "url/gurl.h" |
| 36 | 37 |
| 37 namespace net { | 38 namespace net { |
| 38 | 39 |
| 39 namespace { | 40 namespace { |
| 40 | 41 |
| 41 // Filter types (using canonical lower case only): | 42 // Filter types (using canonical lower case only): |
| 42 const char kBrotli[] = "br"; | 43 const char kBrotli[] = "br"; |
| 43 const char kDeflate[] = "deflate"; | 44 const char kDeflate[] = "deflate"; |
| 44 const char kGZip[] = "gzip"; | 45 const char kGZip[] = "gzip"; |
| 45 const char kXGZip[] = "x-gzip"; | 46 const char kXGZip[] = "x-gzip"; |
| 46 const char kSdch[] = "sdch"; | 47 const char kSdch[] = "sdch"; |
| 47 // compress and x-compress are currently not supported. If we decide to support | 48 // compress and x-compress are currently not supported. If we decide to support |
| 48 // them, we'll need the same mime type compatibility hack we have for gzip. For | 49 // them, we'll need the same mime type compatibility hack we have for gzip. For |
| 49 // more information, see Firefox's nsHttpChannel::ProcessNormal. | 50 // more information, see Firefox's nsHttpChannel::ProcessNormal. |
| 50 | 51 |
| 51 // Mime types: | 52 // Mime types: |
| 52 const char kTextHtml[] = "text/html"; | 53 const char kTextHtml[] = "text/html"; |
| 53 | 54 |
| 54 // Buffer size allocated when de-compressing data. | 55 // Buffer size allocated when de-compressing data. |
| 55 const int kFilterBufSize = 32 * 1024; | 56 const int kFilterBufSize = 32 * 1024; |
| 56 | 57 |
| 57 void LogSdchProblem(const FilterContext& filter_context, | 58 void LogSdchProblem(const FilterContext& filter_context, |
| 58 SdchProblemCode problem) { | 59 SdchProblemCode problem) { |
| 59 SdchManager::SdchErrorRecovery(problem); | 60 SdchManager::SdchErrorRecovery(problem); |
| 60 filter_context.GetNetLog().AddEvent( | 61 filter_context.GetNetLog().AddEvent( |
| 61 NetLog::TYPE_SDCH_DECODING_ERROR, | 62 NetLogEventType::SDCH_DECODING_ERROR, |
| 62 base::Bind(&NetLogSdchResourceProblemCallback, problem)); | 63 base::Bind(&NetLogSdchResourceProblemCallback, problem)); |
| 63 } | 64 } |
| 64 | 65 |
| 65 std::string FilterTypeAsString(Filter::FilterType type_id) { | 66 std::string FilterTypeAsString(Filter::FilterType type_id) { |
| 66 switch (type_id) { | 67 switch (type_id) { |
| 67 case Filter::FILTER_TYPE_BROTLI: | 68 case Filter::FILTER_TYPE_BROTLI: |
| 68 return "FILTER_TYPE_BROTLI"; | 69 return "FILTER_TYPE_BROTLI"; |
| 69 case Filter::FILTER_TYPE_DEFLATE: | 70 case Filter::FILTER_TYPE_DEFLATE: |
| 70 return "FILTER_TYPE_DEFLATE"; | 71 return "FILTER_TYPE_DEFLATE"; |
| 71 case Filter::FILTER_TYPE_GZIP: | 72 case Filter::FILTER_TYPE_GZIP: |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 | 443 |
| 443 void Filter::PushDataIntoNextFilter() { | 444 void Filter::PushDataIntoNextFilter() { |
| 444 IOBuffer* next_buffer = next_filter_->stream_buffer(); | 445 IOBuffer* next_buffer = next_filter_->stream_buffer(); |
| 445 int next_size = next_filter_->stream_buffer_size(); | 446 int next_size = next_filter_->stream_buffer_size(); |
| 446 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); | 447 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); |
| 447 if (FILTER_ERROR != last_status_) | 448 if (FILTER_ERROR != last_status_) |
| 448 next_filter_->FlushStreamBuffer(next_size); | 449 next_filter_->FlushStreamBuffer(next_size); |
| 449 } | 450 } |
| 450 | 451 |
| 451 } // namespace net | 452 } // namespace net |
| OLD | NEW |