| 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..7bd40843a345c142a04447ef5c9d6e01f47ee83a 100644
|
| --- a/net/url_request/url_request_http_job.cc
|
| +++ b/net/url_request/url_request_http_job.cc
|
| @@ -65,16 +65,12 @@ class URLRequestHttpJob::HttpFilterContext : public FilterContext {
|
| base::Time GetRequestTime() const override;
|
| bool IsCachedContent() const override;
|
| bool IsDownload() const override;
|
| - bool SdchResponseExpected() const override;
|
| + SdchManager::DictionarySet* SdchDictionariesAdvertised() const override;
|
| int64 GetByteReadCount() const override;
|
| int GetResponseCode() const override;
|
| const URLRequestContext* GetURLRequestContext() const override;
|
| void RecordPacketStats(StatisticSelector statistic) 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.
|
| - void ResetSdchResponseToFalse();
|
| -
|
| private:
|
| URLRequestHttpJob* job_;
|
|
|
| @@ -120,13 +116,9 @@ bool URLRequestHttpJob::HttpFilterContext::IsDownload() const {
|
| return (job_->request_info_.load_flags & LOAD_IS_DOWNLOAD) != 0;
|
| }
|
|
|
| -void URLRequestHttpJob::HttpFilterContext::ResetSdchResponseToFalse() {
|
| - DCHECK(job_->sdch_dictionary_advertised_);
|
| - job_->sdch_dictionary_advertised_ = false;
|
| -}
|
| -
|
| -bool URLRequestHttpJob::HttpFilterContext::SdchResponseExpected() const {
|
| - return job_->sdch_dictionary_advertised_;
|
| +SdchManager::DictionarySet*
|
| +URLRequestHttpJob::HttpFilterContext::SdchDictionariesAdvertised() const {
|
| + return job_->dictionaries_advertised_.get();
|
| }
|
|
|
| int64 URLRequestHttpJob::HttpFilterContext::GetByteReadCount() const {
|
| @@ -190,7 +182,6 @@ URLRequestHttpJob::URLRequestHttpJob(
|
| base::Unretained(this))),
|
| read_in_progress_(false),
|
| throttling_entry_(NULL),
|
| - sdch_dictionary_advertised_(false),
|
| sdch_test_activated_(false),
|
| sdch_test_control_(false),
|
| is_cached_content_(false),
|
| @@ -320,6 +311,7 @@ void URLRequestHttpJob::NotifyHeadersComplete() {
|
| ProcessStrictTransportSecurityHeader();
|
| ProcessPublicKeyPinsHeader();
|
|
|
| + // Handle the server notification of a new SDCH dictionary.
|
| SdchManager* sdch_manager(request()->context()->sdch_manager());
|
| if (sdch_manager && sdch_manager->IsInSupportedDomain(request_->url())) {
|
| const std::string name = "Get-Dictionary";
|
| @@ -340,6 +332,24 @@ void URLRequestHttpJob::NotifyHeadersComplete() {
|
| }
|
| }
|
|
|
| + // Handle the server signalling no SDCH encoding.
|
| + if (dictionaries_advertised_.get()) {
|
| + // We are wary of proxies that discard or damage SDCH encoding. If a server
|
| + // explicitly states that this is not SDCH content, then we can correct our
|
| + // assumption that this is an SDCH response, and avoid the need to recover
|
| + // as though the content is corrupted (when we discover it is not SDCH
|
| + // encoded).
|
| + std::string sdch_response_status;
|
| + void* iter = NULL;
|
| + while (GetResponseHeaders()->EnumerateHeader(&iter, "X-Sdch-Encode",
|
| + &sdch_response_status)) {
|
| + if (sdch_response_status == "0") {
|
| + dictionaries_advertised_.reset();
|
| + break;
|
| + }
|
| + }
|
| + }
|
| +
|
| // The HTTP transaction may be restarted several times for the purposes
|
| // of sending authorization information. Each time it restarts, we get
|
| // notified of the headers completion so that we can update the cookie store.
|
| @@ -490,27 +500,27 @@ void URLRequestHttpJob::AddExtraHeaders() {
|
| // to retransmit the request without SDCH, which is illegal for a POST.
|
| request()->method() != "POST" &&
|
| sdch_manager->IsInSupportedDomain(request_->url());
|
| - std::string avail_dictionaries;
|
| if (advertise_sdch) {
|
| - sdch_manager->GetAvailDictionaryList(request_->url(),
|
| - &avail_dictionaries);
|
| -
|
| - // The AllowLatencyExperiment() is only true if we've successfully done a
|
| - // full SDCH compression recently in this browser session for this host.
|
| - // Note that for this path, there might be no applicable dictionaries,
|
| - // and hence we can't participate in the experiment.
|
| - if (!avail_dictionaries.empty() &&
|
| - sdch_manager->AllowLatencyExperiment(request_->url())) {
|
| - // We are participating in the test (or control), and hence we'll
|
| - // eventually record statistics via either SDCH_EXPERIMENT_DECODE or
|
| - // SDCH_EXPERIMENT_HOLDBACK, and we'll need some packet timing data.
|
| - packet_timing_enabled_ = true;
|
| - if (base::RandDouble() < .01) {
|
| - sdch_test_control_ = true; // 1% probability.
|
| - advertise_sdch = false;
|
| - } else {
|
| - sdch_test_activated_ = true;
|
| - }
|
| + dictionaries_advertised_ =
|
| + sdch_manager->GetDictionarySet(request_->url());
|
| + }
|
| +
|
| + // The AllowLatencyExperiment() is only true if we've successfully done a
|
| + // full SDCH compression recently in this browser session for this host.
|
| + // Note that for this path, there might be no applicable dictionaries,
|
| + // and hence we can't participate in the experiment.
|
| + if (dictionaries_advertised_.get() &&
|
| + sdch_manager->AllowLatencyExperiment(request_->url())) {
|
| + // We are participating in the test (or control), and hence we'll
|
| + // eventually record statistics via either SDCH_EXPERIMENT_DECODE or
|
| + // SDCH_EXPERIMENT_HOLDBACK, and we'll need some packet timing data.
|
| + packet_timing_enabled_ = true;
|
| + if (base::RandDouble() < .01) {
|
| + sdch_test_control_ = true; // 1% probability.
|
| + dictionaries_advertised_.reset();
|
| + advertise_sdch = false;
|
| + } else {
|
| + sdch_test_activated_ = true;
|
| }
|
| }
|
|
|
| @@ -527,11 +537,14 @@ void URLRequestHttpJob::AddExtraHeaders() {
|
| // Include SDCH in acceptable list.
|
| request_info_.extra_headers.SetHeader(
|
| HttpRequestHeaders::kAcceptEncoding, "gzip, deflate, sdch");
|
| - if (!avail_dictionaries.empty()) {
|
| + if (dictionaries_advertised_.get()) {
|
| + std::string avail_dictionaries;
|
| + dictionaries_advertised_->GetDictionaryClientHashList(
|
| + &avail_dictionaries);
|
| +
|
| request_info_.extra_headers.SetHeader(
|
| kAvailDictionaryHeader,
|
| avail_dictionaries);
|
| - sdch_dictionary_advertised_ = true;
|
| // Since we're tagging this transaction as advertising a dictionary,
|
| // we'll definitely employ an SDCH filter (or tentative sdch filter)
|
| // when we get a response. When done, we'll record histograms via
|
| @@ -1030,23 +1043,6 @@ Filter* URLRequestHttpJob::SetupFilter() const {
|
| encoding_types.push_back(Filter::ConvertEncodingToType(encoding_type));
|
| }
|
|
|
| - if (filter_context_->SdchResponseExpected()) {
|
| - // We are wary of proxies that discard or damage SDCH encoding. If a server
|
| - // explicitly states that this is not SDCH content, then we can correct our
|
| - // assumption that this is an SDCH response, and avoid the need to recover
|
| - // as though the content is corrupted (when we discover it is not SDCH
|
| - // encoded).
|
| - std::string sdch_response_status;
|
| - iter = NULL;
|
| - while (headers->EnumerateHeader(&iter, "X-Sdch-Encode",
|
| - &sdch_response_status)) {
|
| - if (sdch_response_status == "0") {
|
| - filter_context_->ResetSdchResponseToFalse();
|
| - break;
|
| - }
|
| - }
|
| - }
|
| -
|
| // Even if encoding types are empty, there is a chance that we need to add
|
| // some decoding, as some proxies strip encoding completely. In such cases,
|
| // we may need to add (for example) SDCH filtering (when the context suggests
|
|
|