| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "net/filter/filter_source_stream.h" | 5 #include "net/filter/filter_source_stream.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 const char kDeflate[] = "deflate"; | 20 const char kDeflate2[] = "deflate"; |
| 21 const char kGZip[] = "gzip"; | 21 const char kGZip[] = "gzip"; |
| 22 const char kSdch[] = "sdch"; | 22 const char kSdch2[] = "sdch"; |
| 23 const char kXGZip[] = "x-gzip"; | 23 const char kXGZip[] = "x-gzip"; |
| 24 const char kBrotli[] = "br"; | 24 const char kBrotli[] = "br"; |
| 25 | 25 |
| 26 const size_t kBufferSize = 32 * 1024; | 26 const size_t kBufferSize = 32 * 1024; |
| 27 | 27 |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 FilterSourceStream::FilterSourceStream(SourceType type, | 30 FilterSourceStream::FilterSourceStream(SourceType type, |
| 31 std::unique_ptr<SourceStream> upstream) | 31 std::unique_ptr<SourceStream> upstream) |
| 32 : SourceStream(type), | 32 : SourceStream(type), |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 return GetTypeAsString(); | 72 return GetTypeAsString(); |
| 73 return next_type_string + "," + GetTypeAsString(); | 73 return next_type_string + "," + GetTypeAsString(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 FilterSourceStream::SourceType FilterSourceStream::ParseEncodingType( | 76 FilterSourceStream::SourceType FilterSourceStream::ParseEncodingType( |
| 77 const std::string& encoding) { | 77 const std::string& encoding) { |
| 78 if (encoding.empty()) { | 78 if (encoding.empty()) { |
| 79 return TYPE_NONE; | 79 return TYPE_NONE; |
| 80 } else if (base::LowerCaseEqualsASCII(encoding, kBrotli)) { | 80 } else if (base::LowerCaseEqualsASCII(encoding, kBrotli)) { |
| 81 return TYPE_BROTLI; | 81 return TYPE_BROTLI; |
| 82 } else if (base::LowerCaseEqualsASCII(encoding, kDeflate)) { | 82 } else if (base::LowerCaseEqualsASCII(encoding, kDeflate2)) { |
| 83 return TYPE_DEFLATE; | 83 return TYPE_DEFLATE; |
| 84 } else if (base::LowerCaseEqualsASCII(encoding, kGZip) || | 84 } else if (base::LowerCaseEqualsASCII(encoding, kGZip) || |
| 85 base::LowerCaseEqualsASCII(encoding, kXGZip)) { | 85 base::LowerCaseEqualsASCII(encoding, kXGZip)) { |
| 86 return TYPE_GZIP; | 86 return TYPE_GZIP; |
| 87 } else if (base::LowerCaseEqualsASCII(encoding, kSdch)) { | 87 } else if (base::LowerCaseEqualsASCII(encoding, kSdch2)) { |
| 88 return TYPE_SDCH; | 88 return TYPE_SDCH; |
| 89 } else { | 89 } else { |
| 90 return TYPE_UNKNOWN; | 90 return TYPE_UNKNOWN; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 void FilterSourceStream::ReportContentDecodingFailed(SourceType type) { | 94 void FilterSourceStream::ReportContentDecodingFailed(SourceType type) { |
| 95 UMA_HISTOGRAM_ENUMERATION("Net.ContentDecodingFailed2", type, TYPE_MAX); | 95 UMA_HISTOGRAM_ENUMERATION("Net.ContentDecodingFailed2", type, TYPE_MAX); |
| 96 } | 96 } |
| 97 | 97 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 output_buffer_size_ = 0; | 194 output_buffer_size_ = 0; |
| 195 | 195 |
| 196 base::ResetAndReturn(&callback_).Run(rv); | 196 base::ResetAndReturn(&callback_).Run(rv); |
| 197 } | 197 } |
| 198 | 198 |
| 199 bool FilterSourceStream::NeedMoreData() const { | 199 bool FilterSourceStream::NeedMoreData() const { |
| 200 return !upstream_end_reached_; | 200 return !upstream_end_reached_; |
| 201 } | 201 } |
| 202 | 202 |
| 203 } // namespace net | 203 } // namespace net |
| OLD | NEW |