diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 20:17:29 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 20:17:29 +0000 |
commit | 3b24ecf7ea2060bdb394ea249c24530f18a64578 (patch) | |
tree | cc1fe2fdf8af92a2f56c07598cea52f722113d6e /net/base | |
parent | 3b10a7515086465baab07296a30ba71797b455c8 (diff) | |
download | chromium_src-3b24ecf7ea2060bdb394ea249c24530f18a64578.zip chromium_src-3b24ecf7ea2060bdb394ea249c24530f18a64578.tar.gz chromium_src-3b24ecf7ea2060bdb394ea249c24530f18a64578.tar.bz2 |
Add a visualizer for the HostCache (DNS cache) on the network internals page.
BUG=http://crbug.com/14478
Review URL: http://codereview.chromium.org/172100
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25227 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/host_cache.h | 17 | ||||
-rw-r--r-- | net/base/host_resolver.h | 5 | ||||
-rw-r--r-- | net/base/host_resolver_impl.cc | 4 | ||||
-rw-r--r-- | net/base/host_resolver_impl.h | 1 | ||||
-rw-r--r-- | net/base/mock_host_resolver.cc | 4 | ||||
-rw-r--r-- | net/base/mock_host_resolver.h | 1 |
6 files changed, 30 insertions, 2 deletions
diff --git a/net/base/host_cache.h b/net/base/host_cache.h index d5b9511..ab01c86 100644 --- a/net/base/host_cache.h +++ b/net/base/host_cache.h @@ -31,6 +31,8 @@ class HostCache { base::TimeTicks expiration; }; + typedef base::hash_map<std::string, 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); @@ -60,12 +62,23 @@ class HostCache { return entries_.size(); } + size_t max_entries() const { + return max_entries_; + } + + size_t cache_duration_ms() const { + return cache_duration_ms_; + } + + // Note that this map may contain expired entries. + const EntryMap& entries() const { + return entries_; + } + private: FRIEND_TEST(HostCacheTest, Compact); FRIEND_TEST(HostCacheTest, NoCache); - typedef base::hash_map<std::string, scoped_refptr<Entry> > EntryMap; - // Returns true if this cache entry's result is valid at time |now|. static bool CanUseEntry(const Entry* entry, const base::TimeTicks now); diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h index eecf394..e5c46a3 100644 --- a/net/base/host_resolver.h +++ b/net/base/host_resolver.h @@ -16,6 +16,7 @@ class MessageLoop; namespace net { class AddressList; +class HostCache; class LoadLog; // This class represents the task of resolving hostnames (or IP address @@ -130,6 +131,10 @@ class HostResolver : public base::RefCounted<HostResolver> { // Unregisters an observer previously added by AddObserver(). virtual void RemoveObserver(Observer* observer) = 0; + // Returns the host cache, or NULL if this implementation does not use + // a HostCache. + virtual HostCache* GetHostCache() = 0; + // TODO(eroman): temp hack for http://crbug.com/18373 virtual void Shutdown() = 0; diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc index eed116a..61f075e 100644 --- a/net/base/host_resolver_impl.cc +++ b/net/base/host_resolver_impl.cc @@ -414,6 +414,10 @@ void HostResolverImpl::RemoveObserver(Observer* observer) { observers_.erase(it); } +HostCache* HostResolverImpl::GetHostCache() { + return &cache_; +} + void HostResolverImpl::Shutdown() { shutdown_ = true; diff --git a/net/base/host_resolver_impl.h b/net/base/host_resolver_impl.h index 45c8841..74dea08 100644 --- a/net/base/host_resolver_impl.h +++ b/net/base/host_resolver_impl.h @@ -65,6 +65,7 @@ class HostResolverImpl : public HostResolver { virtual void CancelRequest(RequestHandle req); virtual void AddObserver(Observer* observer); virtual void RemoveObserver(Observer* observer); + virtual HostCache* GetHostCache(); // TODO(eroman): temp hack for http://crbug.com/15513 virtual void Shutdown(); diff --git a/net/base/mock_host_resolver.cc b/net/base/mock_host_resolver.cc index 3c09e15..addccd0f 100644 --- a/net/base/mock_host_resolver.cc +++ b/net/base/mock_host_resolver.cc @@ -66,6 +66,10 @@ void MockHostResolverBase::RemoveObserver(Observer* observer) { impl_->RemoveObserver(observer); } +HostCache* MockHostResolverBase::GetHostCache() { + return impl_->GetHostCache(); +} + void MockHostResolverBase::Shutdown() { impl_->Shutdown(); } diff --git a/net/base/mock_host_resolver.h b/net/base/mock_host_resolver.h index 548cd0a..01a2eab 100644 --- a/net/base/mock_host_resolver.h +++ b/net/base/mock_host_resolver.h @@ -49,6 +49,7 @@ class MockHostResolverBase : public HostResolver { virtual void CancelRequest(RequestHandle req); virtual void AddObserver(Observer* observer); virtual void RemoveObserver(Observer* observer); + virtual HostCache* GetHostCache(); // TODO(eroman): temp hack for http://crbug.com/18373 virtual void Shutdown(); |