diff options
author | jar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-02 01:32:34 +0000 |
---|---|---|
committer | jar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-02 01:32:34 +0000 |
commit | 140a1bc66cbf515dfb10347ee10b39d42dbe1ee0 (patch) | |
tree | adfc4252be520d1db852d8f429cc3361d078554c | |
parent | c949118827afb549daa94fe3171b5e415bb32ea9 (diff) | |
download | chromium_src-140a1bc66cbf515dfb10347ee10b39d42dbe1ee0.zip chromium_src-140a1bc66cbf515dfb10347ee10b39d42dbe1ee0.tar.gz chromium_src-140a1bc66cbf515dfb10347ee10b39d42dbe1ee0.tar.bz2 |
Add instrumentation to and tighten SDCH implementation
r=huanr,kmixter,openvcdiff
Review URL: http://codereview.chromium.org/12699
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6193 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/net/sdch_dictionary_fetcher.cc | 8 | ||||
-rw-r--r-- | net/base/sdch_manager.cc | 10 | ||||
-rw-r--r-- | net/base/sdch_manager.h | 5 |
3 files changed, 20 insertions, 3 deletions
diff --git a/chrome/browser/net/sdch_dictionary_fetcher.cc b/chrome/browser/net/sdch_dictionary_fetcher.cc index 3a36ff7..5208f37 100644 --- a/chrome/browser/net/sdch_dictionary_fetcher.cc +++ b/chrome/browser/net/sdch_dictionary_fetcher.cc @@ -6,6 +6,14 @@ #include "chrome/browser/profile.h" void SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) { + // Avoid pushing duplicate copy onto queue. We may fetch this url again later + // and get a different dictionary, but there is no reason to have it in the + // queue twice at one time. + if (!fetch_queue_.empty() && fetch_queue_.back() == dictionary_url) { + SdchManager::SdchErrorRecovery( + SdchManager::DICTIONARY_ALREADY_SCHEDULED_TO_DOWNLOAD); + return; + } fetch_queue_.push(dictionary_url); ScheduleDelayedRun(); } diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc index 6c5bf92..8b71a04 100644 --- a/net/base/sdch_manager.cc +++ b/net/base/sdch_manager.cc @@ -64,10 +64,10 @@ SdchManager::~SdchManager() { bool SdchManager::BlacklistDomain(const GURL& url) { if (!global_ ) return false; - std::string domain(url.host()); UMA_HISTOGRAM_MEDIUM_TIMES(L"Sdch.UptimeBeforeBlacklisting_M", Time::Now() - FieldTrialList::application_start_time()); - global_->blacklisted_domains_.insert(url.host()); + std::string domain(StringToLowerASCII(url.host())); + global_->blacklisted_domains_.insert(domain); return true; } @@ -88,7 +88,11 @@ const bool SdchManager::IsInSupportedDomain(const GURL& url) const { return true; std::string domain = StringToLowerASCII(url.host()); - return blacklisted_domains_.end() == blacklisted_domains_.find(domain); + bool was_blacklisted(blacklisted_domains_.end() == + blacklisted_domains_.find(domain)); + if (was_blacklisted) + SdchErrorRecovery(DOMAIN_BLACKLIST_INCLUDES_TARGET); + return was_blacklisted; } bool SdchManager::CanFetchDictionary(const GURL& referring_url, diff --git a/net/base/sdch_manager.h b/net/base/sdch_manager.h index 92e5b47..15d0bbf 100644 --- a/net/base/sdch_manager.h +++ b/net/base/sdch_manager.h @@ -97,6 +97,7 @@ class SdchManager { DICTIONARY_SELECTED_FROM_NON_HTTP = 33, DICTIONARY_IS_TOO_LARGE= 34, DICTIONARY_COUNT_EXCEEDED = 35, + DICTIONARY_ALREADY_SCHEDULED_TO_DOWNLOAD = 36, // Failsafe hack. ATTEMPT_TO_DECODE_NON_HTTP_DATA = 40, @@ -106,6 +107,10 @@ class SdchManager { MULTIENCODING_FOR_NON_SDCH_REQUEST = 50, SDCH_CONTENT_ENCODE_FOR_NON_SDCH_REQUEST = 51, + // Dictionary manager issues. + DOMAIN_BLACKLIST_INCLUDES_TARGET = 60, + + MAX_PROBLEM_CODE // Used to bound histogram. }; |