summaryrefslogtreecommitdiffstats
path: root/net/base/sdch_manager.cc
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-30 23:06:01 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-30 23:06:01 +0000
commit5b90b5d3473f3f846618092e79d4c5fcff7d3969 (patch)
tree2d8c6e9118f8062399e6a89103e212d78479938e /net/base/sdch_manager.cc
parent6165e2ab4af4c217e21c0ec167b7eced8fca491c (diff)
downloadchromium_src-5b90b5d3473f3f846618092e79d4c5fcff7d3969.zip
chromium_src-5b90b5d3473f3f846618092e79d4c5fcff7d3969.tar.gz
chromium_src-5b90b5d3473f3f846618092e79d4c5fcff7d3969.tar.bz2
Hand craft an A/B test of SDCH compression
After we're sure we can do SDCH compression to a given URL, toss a 50-50 coin each time we have a chance to advertise SDCH, and either completely avoid advertisement, or advertise (including the dictionary). Histogram both compression download times, as well as the download times for the "completely avoid" case. http://crbug.com/11236 bug=11236 r=wtc,openvcdiff Review URL: http://codereview.chromium.org/100004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15010 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/sdch_manager.cc')
-rw-r--r--net/base/sdch_manager.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc
index c6bf950..1ea9e89 100644
--- a/net/base/sdch_manager.cc
+++ b/net/base/sdch_manager.cc
@@ -85,6 +85,7 @@ SdchManager::~SdchManager() {
void SdchManager::BlacklistDomain(const GURL& url) {
if (!global_ )
return;
+ global_->SetAllowLatencyExperiment(url, false);
std::string domain(StringToLowerASCII(url.host()));
int count = global_->blacklisted_domains_[domain];
@@ -104,6 +105,7 @@ void SdchManager::BlacklistDomain(const GURL& url) {
void SdchManager::BlacklistDomainForever(const GURL& url) {
if (!global_ )
return;
+ global_->SetAllowLatencyExperiment(url, false);
std::string domain(StringToLowerASCII(url.host()));
global_->exponential_blacklist_count[domain] = INT_MAX;
@@ -331,8 +333,8 @@ void SdchManager::GenerateHash(const std::string& dictionary_text,
UrlSafeBase64Encode(first_48_bits, client_hash);
UrlSafeBase64Encode(second_48_bits, server_hash);
- DCHECK(server_hash->length() == 8);
- DCHECK(client_hash->length() == 8);
+ DCHECK_EQ(server_hash->length(), 8u);
+ DCHECK_EQ(client_hash->length(), 8u);
}
// static
@@ -507,3 +509,23 @@ bool SdchManager::Dictionary::DomainMatch(const GURL& gurl,
// TODO(jar): This is not precisely a domain match definition.
return gurl.DomainIs(restriction.data(), restriction.size());
}
+
+//------------------------------------------------------------------------------
+// Methods for supporting latency experiments.
+
+bool SdchManager::AllowLatencyExperiment(const GURL& url) const {
+ return allow_latency_experiment_.end() !=
+ allow_latency_experiment_.find(url.host());
+}
+
+void SdchManager::SetAllowLatencyExperiment(const GURL& url, bool enable) {
+ if (enable) {
+ allow_latency_experiment_.insert(url.host());
+ return;
+ }
+ ExperimentSet::iterator it = allow_latency_experiment_.find(url.host());
+ if (allow_latency_experiment_.end() == it)
+ return; // It was already erased, or never allowed.
+ SdchErrorRecovery(LATENCY_TEST_DISALLOWED);
+ allow_latency_experiment_.erase(it);
+}