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

Unified Diff: net/filter/filter.cc

Issue 423813002: Sdch view for net-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create Dictionary JSON directly in SdchManager::SdchInfoToValue Created 6 years, 4 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
Index: net/filter/filter.cc
diff --git a/net/filter/filter.cc b/net/filter/filter.cc
index d77272a809d99412ad471cc97095adf4abb43f23..d568f626c3181ab78c8ab5c758443bac50f7fbf9 100644
--- a/net/filter/filter.cc
+++ b/net/filter/filter.cc
@@ -9,11 +9,14 @@
#include "net/base/filename_util_unsafe.h"
#include "net/base/io_buffer.h"
#include "net/base/mime_util.h"
+#include "net/base/sdch_net_log_params.h"
#include "net/filter/gzip_filter.h"
#include "net/filter/sdch_filter.h"
#include "net/url_request/url_request_context.h"
#include "url/gurl.h"
+namespace net {
+
namespace {
// Filter types (using canonical lower case only):
@@ -34,9 +37,15 @@ const char kTextHtml[] = "text/html";
// Buffer size allocated when de-compressing data.
const int kFilterBufSize = 32 * 1024;
-} // namespace
+void LogSdchProblem(const FilterContext& filter_context,
+ SdchManager::ProblemCodes problem) {
+ SdchManager::SdchErrorRecovery(problem);
+ filter_context.GetNetLog().AddEvent(
+ NetLog::TYPE_SDCH_RESOURCE_ERROR,
+ base::Bind(&NetLogSdchResourceProblemCallback, problem));
+}
-namespace net {
+} // namespace
FilterContext::~FilterContext() {
}
@@ -161,6 +170,9 @@ void Filter::FixupEncodingTypes(
bool success = filter_context.GetMimeType(&mime_type);
DCHECK(success || mime_type.empty());
+ GURL url;
+ success = filter_context.GetURL(&url);
Randy Smith (Not in Mondays) 2014/08/13 17:35:46 Why the change?
baranovich 2014/08/13 19:13:48 Done.
+
if ((1 == encoding_types->size()) &&
(FILTER_TYPE_GZIP == encoding_types->front())) {
if (LowerCaseEqualsASCII(mime_type, kApplicationXGzip) ||
@@ -172,10 +184,8 @@ void Filter::FixupEncodingTypes(
// the Content-Encoding here.
encoding_types->clear();
- GURL url;
- std::string disposition;
- success = filter_context.GetURL(&url);
DCHECK(success);
+ std::string disposition;
filter_context.GetContentDisposition(&disposition);
// Don't supply a MIME type here, since that may cause disk IO.
base::FilePath::StringType extension =
@@ -210,13 +220,13 @@ void Filter::FixupEncodingTypes(
// It was not an SDCH request, so we'll just record stats.
if (1 < encoding_types->size()) {
// Multiple filters were intended to only be used for SDCH (thus far!)
- SdchManager::SdchErrorRecovery(
- SdchManager::MULTIENCODING_FOR_NON_SDCH_REQUEST);
+ LogSdchProblem(filter_context,
+ SdchManager::MULTIENCODING_FOR_NON_SDCH_REQUEST);
}
if ((1 == encoding_types->size()) &&
(FILTER_TYPE_SDCH == encoding_types->front())) {
- SdchManager::SdchErrorRecovery(
- SdchManager::SDCH_CONTENT_ENCODE_FOR_NON_SDCH_REQUEST);
+ LogSdchProblem(filter_context,
+ SdchManager::SDCH_CONTENT_ENCODE_FOR_NON_SDCH_REQUEST);
}
return;
}
@@ -236,8 +246,8 @@ void Filter::FixupEncodingTypes(
// no-op pass through filter if it doesn't get gzip headers where expected.
if (1 == encoding_types->size()) {
encoding_types->push_back(FILTER_TYPE_GZIP_HELPING_SDCH);
- SdchManager::SdchErrorRecovery(
- SdchManager::OPTIONAL_GUNZIP_ENCODING_ADDED);
+ LogSdchProblem(filter_context,
+ SdchManager::OPTIONAL_GUNZIP_ENCODING_ADDED);
}
return;
}
@@ -271,14 +281,11 @@ void Filter::FixupEncodingTypes(
// Suspicious case: Advertised dictionary, but server didn't use sdch, and
// we're HTML tagged.
if (encoding_types->empty()) {
- SdchManager::SdchErrorRecovery(
- SdchManager::ADDED_CONTENT_ENCODING);
+ LogSdchProblem(filter_context, SdchManager::ADDED_CONTENT_ENCODING);
} else if (1 == encoding_types->size()) {
- SdchManager::SdchErrorRecovery(
- SdchManager::FIXED_CONTENT_ENCODING);
+ LogSdchProblem(filter_context, SdchManager::FIXED_CONTENT_ENCODING);
} else {
- SdchManager::SdchErrorRecovery(
- SdchManager::FIXED_CONTENT_ENCODINGS);
+ LogSdchProblem(filter_context, SdchManager::FIXED_CONTENT_ENCODINGS);
}
} else {
// Remarkable case!?! We advertised an SDCH dictionary, content-encoding
@@ -290,14 +297,14 @@ void Filter::FixupEncodingTypes(
// start with "text/html" for some other reason?? We'll report this as a
// fixup to a binary file, but it probably really is text/html (some how).
if (encoding_types->empty()) {
- SdchManager::SdchErrorRecovery(
- SdchManager::BINARY_ADDED_CONTENT_ENCODING);
+ LogSdchProblem(filter_context,
+ SdchManager::BINARY_ADDED_CONTENT_ENCODING);
} else if (1 == encoding_types->size()) {
- SdchManager::SdchErrorRecovery(
- SdchManager::BINARY_FIXED_CONTENT_ENCODING);
+ LogSdchProblem(filter_context,
+ SdchManager::BINARY_FIXED_CONTENT_ENCODING);
} else {
- SdchManager::SdchErrorRecovery(
- SdchManager::BINARY_FIXED_CONTENT_ENCODINGS);
+ LogSdchProblem(filter_context,
+ SdchManager::BINARY_FIXED_CONTENT_ENCODINGS);
}
}

Powered by Google App Engine
This is Rietveld 408576698