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

Unified Diff: net/filter/filter_source_stream.cc

Issue 2753453003: Reject unadvertised encodings (Closed)
Patch Set: Fix histo value comments Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/filter/filter_source_stream.h ('k') | net/filter/source_stream_type_list.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/filter/filter_source_stream.cc
diff --git a/net/filter/filter_source_stream.cc b/net/filter/filter_source_stream.cc
index 603bd703c8e7311744fc74e0ae868a383d0cb518..688d6927055527a93411913a7a7a299f129bedb4 100644
--- a/net/filter/filter_source_stream.cc
+++ b/net/filter/filter_source_stream.cc
@@ -17,6 +17,12 @@ namespace net {
namespace {
+const char kDeflate[] = "deflate";
+const char kGZip[] = "gzip";
+const char kSdch[] = "sdch";
+const char kXGZip[] = "x-gzip";
+const char kBrotli[] = "br";
+
const size_t kBufferSize = 32 * 1024;
} // namespace
@@ -67,6 +73,28 @@ std::string FilterSourceStream::Description() const {
return next_type_string + "," + GetTypeAsString();
}
+FilterSourceStream::SourceType FilterSourceStream::ParseEncodingType(
+ const std::string& encoding) {
+ if (encoding.empty()) {
+ return TYPE_NONE;
+ } else if (base::LowerCaseEqualsASCII(encoding, kBrotli)) {
+ return TYPE_BROTLI;
+ } else if (base::LowerCaseEqualsASCII(encoding, kDeflate)) {
+ return TYPE_DEFLATE;
+ } else if (base::LowerCaseEqualsASCII(encoding, kGZip) ||
+ base::LowerCaseEqualsASCII(encoding, kXGZip)) {
+ return TYPE_GZIP;
+ } else if (base::LowerCaseEqualsASCII(encoding, kSdch)) {
+ return TYPE_SDCH;
+ } else {
+ return TYPE_UNKNOWN;
+ }
+}
+
+void FilterSourceStream::ReportContentDecodingFailed(SourceType type) {
+ UMA_HISTOGRAM_ENUMERATION("Net.ContentDecodingFailed2", type, TYPE_MAX);
+}
+
int FilterSourceStream::DoLoop(int result) {
DCHECK_NE(STATE_NONE, next_state_);
@@ -136,8 +164,7 @@ int FilterSourceStream::DoFilterData() {
consumed_bytes == drainable_input_buffer_->BytesRemaining());
if (bytes_output == ERR_CONTENT_DECODING_FAILED) {
- UMA_HISTOGRAM_ENUMERATION("Net.ContentDecodingFailed2.FilterType", type(),
- TYPE_MAX);
+ ReportContentDecodingFailed(type());
}
// FilterData() is not allowed to return ERR_IO_PENDING.
DCHECK_NE(ERR_IO_PENDING, bytes_output);
« no previous file with comments | « net/filter/filter_source_stream.h ('k') | net/filter/source_stream_type_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698