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

Unified Diff: net/url_request/url_request_http_job.cc

Issue 423813002: Sdch view for net-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix component linkage Created 6 years, 1 month 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/url_request/sdch_dictionary_fetcher_unittest.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_http_job.cc
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 4261b9227fe2e903f187f0575c8bb263ae82d81e..33a508849f4a7b8a35b9468de762cbb3d804d3ad 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -24,6 +24,7 @@
#include "net/base/net_util.h"
#include "net/base/network_delegate.h"
#include "net/base/sdch_manager.h"
+#include "net/base/sdch_net_log_params.h"
#include "net/cert/cert_status_flags.h"
#include "net/cookies/cookie_store.h"
#include "net/http/http_content_disposition.h"
@@ -70,6 +71,7 @@ class URLRequestHttpJob::HttpFilterContext : public FilterContext {
int GetResponseCode() const override;
const URLRequestContext* GetURLRequestContext() const override;
void RecordPacketStats(StatisticSelector statistic) const override;
+ const BoundNetLog& GetNetLog() const override;
// Method to allow us to reset filter context for a response that should have
// been SDCH encoded when there is an update due to an explicit HTTP header.
@@ -78,6 +80,10 @@ class URLRequestHttpJob::HttpFilterContext : public FilterContext {
private:
URLRequestHttpJob* job_;
+ // URLRequestHttpJob may be detached from URLRequest, but we still need to
+ // return something.
+ BoundNetLog dummy_log_;
+
DISALLOW_COPY_AND_ASSIGN(HttpFilterContext);
};
@@ -147,6 +153,10 @@ void URLRequestHttpJob::HttpFilterContext::RecordPacketStats(
job_->RecordPacketStats(statistic);
}
+const BoundNetLog& URLRequestHttpJob::HttpFilterContext::GetNetLog() const {
+ return job_->request() ? job_->request()->net_log() : dummy_log_;
+}
+
// TODO(darin): make sure the port blocking code is not lost
// static
URLRequestJob* URLRequestHttpJob::Factory(URLRequest* request,
@@ -321,21 +331,42 @@ void URLRequestHttpJob::NotifyHeadersComplete() {
ProcessPublicKeyPinsHeader();
SdchManager* sdch_manager(request()->context()->sdch_manager());
- if (sdch_manager && sdch_manager->IsInSupportedDomain(request_->url())) {
- const std::string name = "Get-Dictionary";
- std::string url_text;
- void* iter = NULL;
- // TODO(jar): We need to not fetch dictionaries the first time they are
- // seen, but rather wait until we can justify their usefulness.
- // For now, we will only fetch the first dictionary, which will at least
- // require multiple suggestions before we get additional ones for this site.
- // Eventually we should wait until a dictionary is requested several times
- // before we even download it (so that we don't waste memory or bandwidth).
- if (GetResponseHeaders()->EnumerateHeader(&iter, name, &url_text)) {
- // Resolve suggested URL relative to request url.
- GURL sdch_dictionary_url = request_->url().Resolve(url_text);
- if (sdch_dictionary_url.is_valid()) {
- sdch_manager->OnGetDictionary(request_->url(), sdch_dictionary_url);
+ if (sdch_manager) {
+ SdchProblemCode rv = sdch_manager->IsInSupportedDomain(request()->url());
+ if (rv != SDCH_OK) {
+ // If SDCH is just disabled, it is not a real error.
+ if (rv != SDCH_DISABLED && rv != SDCH_SECURE_SCHEME_NOT_SUPPORTED) {
+ SdchManager::SdchErrorRecovery(rv);
+ request()->net_log().AddEvent(
+ NetLog::TYPE_SDCH_DECODING_ERROR,
+ base::Bind(&NetLogSdchResourceProblemCallback, rv));
+ }
+ } else {
+ const std::string name = "Get-Dictionary";
+ std::string url_text;
+ void* iter = NULL;
+ // TODO(jar): We need to not fetch dictionaries the first time they are
+ // seen, but rather wait until we can justify their usefulness.
+ // For now, we will only fetch the first dictionary, which will at least
+ // require multiple suggestions before we get additional ones for this
+ // site. Eventually we should wait until a dictionary is requested
+ // several times
+ // before we even download it (so that we don't waste memory or
+ // bandwidth).
+ if (GetResponseHeaders()->EnumerateHeader(&iter, name, &url_text)) {
+ // Resolve suggested URL relative to request url.
+ GURL sdch_dictionary_url = request_->url().Resolve(url_text);
+ if (sdch_dictionary_url.is_valid()) {
+ rv = sdch_manager->OnGetDictionary(request_->url(),
+ sdch_dictionary_url);
+ if (rv != SDCH_OK) {
+ SdchManager::SdchErrorRecovery(rv);
+ request_->net_log().AddEvent(
+ NetLog::TYPE_SDCH_DICTIONARY_ERROR,
+ base::Bind(&NetLogSdchDictionaryFetchProblemCallback, rv,
+ sdch_dictionary_url, false));
+ }
+ }
}
}
}
@@ -483,13 +514,24 @@ void URLRequestHttpJob::AddExtraHeaders() {
// simple_data_source.
if (!request_info_.extra_headers.HasHeader(
HttpRequestHeaders::kAcceptEncoding)) {
- bool advertise_sdch = sdch_manager &&
- // We don't support SDCH responses to POST as there is a possibility
- // of having SDCH encoded responses returned (e.g. by the cache)
- // which we cannot decode, and in those situations, we will need
- // to retransmit the request without SDCH, which is illegal for a POST.
- request()->method() != "POST" &&
- sdch_manager->IsInSupportedDomain(request_->url());
+ // We don't support SDCH responses to POST as there is a possibility
+ // of having SDCH encoded responses returned (e.g. by the cache)
+ // which we cannot decode, and in those situations, we will need
+ // to retransmit the request without SDCH, which is illegal for a POST.
+ bool advertise_sdch = sdch_manager != NULL && request()->method() != "POST";
+ if (advertise_sdch) {
+ SdchProblemCode rv = sdch_manager->IsInSupportedDomain(request()->url());
+ if (rv != SDCH_OK) {
+ advertise_sdch = false;
+ // If SDCH is just disabled, it is not a real error.
+ if (rv != SDCH_DISABLED && rv != SDCH_SECURE_SCHEME_NOT_SUPPORTED) {
+ SdchManager::SdchErrorRecovery(rv);
+ request()->net_log().AddEvent(
+ NetLog::TYPE_SDCH_DECODING_ERROR,
+ base::Bind(&NetLogSdchResourceProblemCallback, rv));
+ }
+ }
+ }
std::string avail_dictionaries;
if (advertise_sdch) {
sdch_manager->GetAvailDictionaryList(request_->url(),
« no previous file with comments | « net/url_request/sdch_dictionary_fetcher_unittest.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698