summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 01:34:35 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 01:34:35 +0000
commit53a3c8fec3cccf37f81e808e4b17188d9c53cd71 (patch)
tree61a35fb73eae35a4419580239fa467388567a01f /chrome/browser/net
parentaf86029b6974eeecb13f1703f5b59f5152810549 (diff)
downloadchromium_src-53a3c8fec3cccf37f81e808e4b17188d9c53cd71.zip
chromium_src-53a3c8fec3cccf37f81e808e4b17188d9c53cd71.tar.gz
chromium_src-53a3c8fec3cccf37f81e808e4b17188d9c53cd71.tar.bz2
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
Diffstat (limited to 'chrome/browser/net')
-rw-r--r--chrome/browser/net/sdch_dictionary_fetcher.cc6
-rw-r--r--chrome/browser/net/sdch_dictionary_fetcher.h17
2 files changed, 23 insertions, 0 deletions
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 <queue>
+#include <set>
#include <string>
#include "base/compiler_specific.h"
@@ -70,6 +71,22 @@ class SdchDictionaryFetcher : public URLFetcher::Delegate,
ScopedRunnableMethodFactory<SdchDictionaryFetcher> 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<GURL> attempted_load_;
+
+
DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher);
};