summaryrefslogtreecommitdiffstats
path: root/net/base/host_cache.h
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-10 07:23:40 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-10 07:23:40 +0000
commit112bd4674a886777b79dcd03263088b692fb47fd (patch)
tree7cf667fa50e6e9284d3a4f1d294cf86719698ff9 /net/base/host_cache.h
parenta4121a67a6a1383048d31130305e472966b44c97 (diff)
downloadchromium_src-112bd4674a886777b79dcd03263088b692fb47fd.zip
chromium_src-112bd4674a886777b79dcd03263088b692fb47fd.tar.gz
chromium_src-112bd4674a886777b79dcd03263088b692fb47fd.tar.bz2
Cache failed DNS resolutions for 1 second.
This is a very small time to live, since we want to be able to respond quickly when formerly unresolvable names become resolvable. Even such a small time is still useful, since cache misses for unresolvable names can be extremely costly (order of several seconds). For example, in our corp PAC script, the URL's host is resolved 3 times, so: Without caching, total runtime is (2.5 seconds) * 3 --> 7.5 seconds. Whereas with caching it would be: (2.5 seconds) * 1 --> 2.5 seconds This time to live will need to be tuned as part of bug 25472. BUG=11079 Review URL: http://codereview.chromium.org/464084 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34238 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/host_cache.h')
-rw-r--r--net/base/host_cache.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/net/base/host_cache.h b/net/base/host_cache.h
index c7127b0..4eb5853 100644
--- a/net/base/host_cache.h
+++ b/net/base/host_cache.h
@@ -57,9 +57,12 @@ class HostCache {
typedef std::map<Key, scoped_refptr<Entry> > EntryMap;
- // Constructs a HostCache whose entries are valid for |cache_duration_ms|
- // milliseconds. The cache will store up to |max_entries|.
- HostCache(size_t max_entries, size_t cache_duration_ms);
+ // Constructs a HostCache that caches successful host resolves for
+ // |success_entry_ttl| time, and failed host resolves for
+ // |failure_entry_ttl|. The cache will store up to |max_entries|.
+ HostCache(size_t max_entries,
+ base::TimeDelta success_entry_ttl,
+ base::TimeDelta failure_entry_ttl);
~HostCache();
@@ -90,8 +93,12 @@ class HostCache {
return max_entries_;
}
- size_t cache_duration_ms() const {
- return cache_duration_ms_;
+ base::TimeDelta success_entry_ttl() const {
+ return success_entry_ttl_;
+ }
+
+ base::TimeDelta failure_entry_ttl() const {
+ return failure_entry_ttl_;
}
// Note that this map may contain expired entries.
@@ -113,8 +120,9 @@ class HostCache {
// Bound on total size of the cache.
size_t max_entries_;
- // Time to live for cache entries in milliseconds.
- size_t cache_duration_ms_;
+ // Time to live for cache entries.
+ base::TimeDelta success_entry_ttl_;
+ base::TimeDelta failure_entry_ttl_;
// Map from hostname (presumably in lowercase canonicalized format) to
// a resolved result entry.