diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-09 18:07:27 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-09 18:07:27 +0000 |
commit | 9e7bb508cad27e505644d856c132f742d5742cdc (patch) | |
tree | 3aae06610cc9babf29540a078d698dad217bf708 /net | |
parent | 5af2c5d8f4dac890633084af4dd545fc488906ce (diff) | |
download | chromium_src-9e7bb508cad27e505644d856c132f742d5742cdc.zip chromium_src-9e7bb508cad27e505644d856c132f742d5742cdc.tar.gz chromium_src-9e7bb508cad27e505644d856c132f742d5742cdc.tar.bz2 |
Mark HostCache as NonThreadSafe.
BUG=None
TEST=net_unittests, and ran chrome with net_internals DNS.
Review URL: http://codereview.chromium.org/2721005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49285 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/host_cache.cc | 33 | ||||
-rw-r--r-- | net/base/host_cache.h | 40 |
2 files changed, 48 insertions, 25 deletions
diff --git a/net/base/host_cache.cc b/net/base/host_cache.cc index 791ecca..8debede 100644 --- a/net/base/host_cache.cc +++ b/net/base/host_cache.cc @@ -35,6 +35,7 @@ HostCache::~HostCache() { const HostCache::Entry* HostCache::Lookup(const Key& key, base::TimeTicks now) const { + DCHECK(CalledOnValidThread()); if (caching_is_disabled()) return NULL; @@ -53,6 +54,7 @@ HostCache::Entry* HostCache::Set(const Key& key, int error, const AddressList addrlist, base::TimeTicks now) { + DCHECK(CalledOnValidThread()); if (caching_is_disabled()) return NULL; @@ -79,6 +81,37 @@ HostCache::Entry* HostCache::Set(const Key& key, } } +void HostCache::clear() { + DCHECK(CalledOnValidThread()); + entries_.clear(); +} + +size_t HostCache::size() const { + DCHECK(CalledOnValidThread()); + return entries_.size(); +} + +size_t HostCache::max_entries() const { + DCHECK(CalledOnValidThread()); + return max_entries_; +} + +base::TimeDelta HostCache::success_entry_ttl() const { + DCHECK(CalledOnValidThread()); + return success_entry_ttl_; +} + +base::TimeDelta HostCache::failure_entry_ttl() const { + DCHECK(CalledOnValidThread()); + return failure_entry_ttl_; +} + +// Note that this map may contain expired entries. +const HostCache::EntryMap& HostCache::entries() const { + DCHECK(CalledOnValidThread()); + return entries_; +} + // static bool HostCache::CanUseEntry(const Entry* entry, const base::TimeTicks now) { return entry->expiration > now; diff --git a/net/base/host_cache.h b/net/base/host_cache.h index 94022e4..59e4315 100644 --- a/net/base/host_cache.h +++ b/net/base/host_cache.h @@ -8,6 +8,7 @@ #include <map> #include <string> +#include "base/non_thread_safe.h" #include "base/ref_counted.h" #include "base/time.h" #include "net/base/address_family.h" @@ -17,7 +18,7 @@ namespace net { // Cache used by HostResolver to map hostnames to their resolved result. -class HostCache { +class HostCache : public NonThreadSafe { public: // Stores the latest address list that was looked up for a hostname. struct Entry : public base::RefCounted<Entry> { @@ -92,37 +93,21 @@ class HostCache { const AddressList addrlist, base::TimeTicks now); - // Empties the cache. - void clear() { - entries_.clear(); - } - - // Returns true if this HostCache can contain no entries. - bool caching_is_disabled() const { - return max_entries_ == 0; - } + // Empties the cache + void clear(); // Returns the number of entries in the cache. - size_t size() const { - return entries_.size(); - } + size_t size() const; - size_t max_entries() const { - return max_entries_; - } + // Following are used by net_internals UI. + size_t max_entries() const; - base::TimeDelta success_entry_ttl() const { - return success_entry_ttl_; - } + base::TimeDelta success_entry_ttl() const; - base::TimeDelta failure_entry_ttl() const { - return failure_entry_ttl_; - } + base::TimeDelta failure_entry_ttl() const; // Note that this map may contain expired entries. - const EntryMap& entries() const { - return entries_; - } + const EntryMap& entries() const; private: FRIEND_TEST(HostCacheTest, Compact); @@ -135,6 +120,11 @@ class HostCache { // matching |pinned_entry| will NOT be pruned. void Compact(base::TimeTicks now, const Entry* pinned_entry); + // Returns true if this HostCache can contain no entries. + bool caching_is_disabled() const { + return max_entries_ == 0; + } + // Bound on total size of the cache. size_t max_entries_; |