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

Unified Diff: net/filter/sdch_filter.cc

Issue 298063006: Make SdchManager per-profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed bugs found through smoke testing and incorporated comments. Created 6 years, 6 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/sdch_filter.cc
diff --git a/net/filter/sdch_filter.cc b/net/filter/sdch_filter.cc
index 55d9b4c6bd984c4934df7472e17c3b1b2ecc2faf..5590821841b460badf80b0b991f21677abf273ff 100644
--- a/net/filter/sdch_filter.cc
+++ b/net/filter/sdch_filter.cc
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "net/base/sdch_manager.h"
+#include "net/url_request/url_request_context.h"
#include "sdch/open-vcdiff/src/google/vcdecoder.h"
@@ -23,6 +24,7 @@ SdchFilter::SdchFilter(const FilterContext& filter_context)
dictionary_hash_(),
dictionary_hash_is_plausible_(false),
dictionary_(NULL),
+ url_request_context_(filter_context.GetURLRequestContext()),
dest_buffer_excess_(),
dest_buffer_excess_index_(0),
source_bytes_(0),
@@ -32,6 +34,7 @@ SdchFilter::SdchFilter(const FilterContext& filter_context)
DCHECK(success);
success = filter_context.GetURL(&url_);
DCHECK(success);
+ DCHECK(url_request_context_->sdch_manager());
}
SdchFilter::~SdchFilter() {
@@ -51,7 +54,8 @@ SdchFilter::~SdchFilter() {
// Make it possible for the user to hit reload, and get non-sdch content.
// Note this will "wear off" quickly enough, and is just meant to assure
// in some rare case that the user is not stuck.
- SdchManager::BlacklistDomain(url_);
+ url_request_context_->sdch_manager()->BlacklistDomain(
+ url_);
UMA_HISTOGRAM_COUNTS("Sdch3.PartialBytesIn",
static_cast<int>(filter_context_.GetByteReadCount()));
UMA_HISTOGRAM_COUNTS("Sdch3.PartialVcdiffIn", source_bytes_);
@@ -88,7 +92,8 @@ SdchFilter::~SdchFilter() {
filter_context_.RecordPacketStats(FilterContext::SDCH_DECODE);
// Allow latency experiments to proceed.
- SdchManager::Global()->SetAllowLatencyExperiment(url_, true);
+ url_request_context_->sdch_manager()->SetAllowLatencyExperiment(
+ url_, true);
return;
}
case PASS_THROUGH: {
@@ -213,7 +218,7 @@ Filter::FilterStatus SdchFilter::ReadFilteredData(char* dest_buffer,
SdchManager::SdchErrorRecovery(SdchManager::PASSING_THROUGH_NON_SDCH);
decoding_status_ = PASS_THROUGH;
// ... but further back-off on advertising SDCH support.
- SdchManager::BlacklistDomain(url_);
+ url_request_context_->sdch_manager()->BlacklistDomain(url_);
}
if (decoding_status_ == PASS_THROUGH) {
@@ -223,7 +228,7 @@ Filter::FilterStatus SdchFilter::ReadFilteredData(char* dest_buffer,
if (std::string::npos == mime_type_.find("text/html")) {
// Since we can't do a meta-refresh (along with an exponential
// backoff), we'll just make sure this NEVER happens again.
- SdchManager::BlacklistDomainForever(url_);
+ url_request_context_->sdch_manager()->BlacklistDomainForever(url_);
if (filter_context_.IsCachedContent())
SdchManager::SdchErrorRecovery(
SdchManager::CACHED_META_REFRESH_UNSUPPORTED);
@@ -242,7 +247,7 @@ Filter::FilterStatus SdchFilter::ReadFilteredData(char* dest_buffer,
} else {
// Since it wasn't in the cache, we definately need at least some
// period of blacklisting to get the correct content.
- SdchManager::BlacklistDomain(url_);
+ url_request_context_->sdch_manager()->BlacklistDomain(url_);
SdchManager::SdchErrorRecovery(SdchManager::META_REFRESH_RECOVERY);
}
decoding_status_ = META_REFRESH_RECOVERY;
@@ -335,12 +340,14 @@ Filter::FilterStatus SdchFilter::InitializeDictionary() {
dictionary_hash_is_plausible_ = true; // Assume plausible, but check.
SdchManager::Dictionary* dictionary = NULL;
- if ('\0' == dictionary_hash_[kServerIdLength - 1])
- SdchManager::Global()->GetVcdiffDictionary(std::string(dictionary_hash_, 0,
- kServerIdLength - 1),
- url_, &dictionary);
- else
+ if ('\0' == dictionary_hash_[kServerIdLength - 1]) {
+ SdchManager* manager(url_request_context_->sdch_manager());
+ manager->GetVcdiffDictionary(
+ std::string(dictionary_hash_, 0, kServerIdLength - 1),
+ url_, &dictionary);
+ } else {
dictionary_hash_is_plausible_ = false;
+ }
if (!dictionary) {
DCHECK(dictionary_hash_.size() == kServerIdLength);

Powered by Google App Engine
This is Rietveld 408576698