From 53a3c8fec3cccf37f81e808e4b17188d9c53cd71 Mon Sep 17 00:00:00 2001 From: "jar@chromium.org" Date: Fri, 5 Jun 2009 01:34:35 +0000 Subject: Prevent SDCH from re-trying to download a dicitionary Some dicitoaries provided by an SDCH server may be larger than allowed by Chromium (which holds the dictionary memory-resident). This CL prevents Chromium from endlessly re-trying such dicitonary loads, BUG=7722 r=huanr Review URL: http://codereview.chromium.org/119198 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17699 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/net/sdch_dictionary_fetcher.cc | 6 ++++++ chrome/browser/net/sdch_dictionary_fetcher.h | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) (limited to 'chrome/browser/net') diff --git a/chrome/browser/net/sdch_dictionary_fetcher.cc b/chrome/browser/net/sdch_dictionary_fetcher.cc index b063748..08ed763 100644 --- a/chrome/browser/net/sdch_dictionary_fetcher.cc +++ b/chrome/browser/net/sdch_dictionary_fetcher.cc @@ -16,6 +16,12 @@ void SdchDictionaryFetcher::Schedule(const GURL& dictionary_url) { SdchManager::DICTIONARY_ALREADY_SCHEDULED_TO_DOWNLOAD); return; } + if (attempted_load_.find(dictionary_url) != attempted_load_.end()) { + SdchManager::SdchErrorRecovery( + SdchManager::DICTIONARY_ALREADY_TRIED_TO_DOWNLOAD); + return; + } + attempted_load_.insert(dictionary_url); fetch_queue_.push(dictionary_url); ScheduleDelayedRun(); } diff --git a/chrome/browser/net/sdch_dictionary_fetcher.h b/chrome/browser/net/sdch_dictionary_fetcher.h index e9e092c..12c022a 100644 --- a/chrome/browser/net/sdch_dictionary_fetcher.h +++ b/chrome/browser/net/sdch_dictionary_fetcher.h @@ -10,6 +10,7 @@ #define CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_ #include +#include #include #include "base/compiler_specific.h" @@ -70,6 +71,22 @@ class SdchDictionaryFetcher : public URLFetcher::Delegate, ScopedRunnableMethodFactory method_factory_; bool task_is_pending_; + // Althought the SDCH spec does not preclude a server from using a single URL + // to load several distinct dictionaries (by telling a client to load a + // dictionary from an URL several times), current implementations seem to have + // that 1-1 relationship (i.e., each URL points at a single dictionary, and + // the dictionary content does not change over time, and hence is not worth + // trying to load more than once). In addition, some dictionaries prove + // unloadable only after downloading them (because they are too large? ...or + // malformed?). As a protective element, Chromium will *only* load a + // dictionary at most once from a given URL (so that it doesn't waste + // bandwidth trying repeatedly). + // The following set lists all the dictionary URLs that we've tried to load, + // so that we won't try to load from an URL more than once. + // TODO(jar): Try to augment the SDCH proposal to include this restiction. + std::set attempted_load_; + + DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); }; -- cgit v1.1