diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-11 19:13:08 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-11 19:13:08 +0000 |
commit | 8d53d50afb7ed6df2a39c175bfdb2485a3a25d9d (patch) | |
tree | eab27a8ece609f3bd6fad7081cbf5fd36ec0922f /net | |
parent | 762d2db5d5e1b0d7852ddb2efef982b00e897322 (diff) | |
download | chromium_src-8d53d50afb7ed6df2a39c175bfdb2485a3a25d9d.zip chromium_src-8d53d50afb7ed6df2a39c175bfdb2485a3a25d9d.tar.gz chromium_src-8d53d50afb7ed6df2a39c175bfdb2485a3a25d9d.tar.bz2 |
Clear the host cache when closing the last incognito window.
This avoids retaining navigation history relating to the incognito window.
I piggy-back off of the dns prefetcher's OffTheRecordObserver to do this. In the future I hope to have a separate host resolver for off the record mode, so this won't be necessary.
BUG=24629
Review URL: http://codereview.chromium.org/523076
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35923 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/host_cache.h | 5 | ||||
-rw-r--r-- | net/base/host_cache_unittest.cc | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/net/base/host_cache.h b/net/base/host_cache.h index 4eb5853..c13c6a0 100644 --- a/net/base/host_cache.h +++ b/net/base/host_cache.h @@ -79,6 +79,11 @@ 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; diff --git a/net/base/host_cache_unittest.cc b/net/base/host_cache_unittest.cc index 5f4e21b..141cfde 100644 --- a/net/base/host_cache_unittest.cc +++ b/net/base/host_cache_unittest.cc @@ -319,6 +319,26 @@ TEST(HostCacheTest, NoCache) { EXPECT_EQ(0U, cache.size()); } +TEST(HostCacheTest, Clear) { + HostCache cache(kMaxCacheEntries, kSuccessEntryTTL, kFailureEntryTTL); + + // Set t=0. + base::TimeTicks now; + + EXPECT_EQ(0u, cache.size()); + + // Add three entries. + cache.Set(Key("foobar1.com"), OK, AddressList(), now); + cache.Set(Key("foobar2.com"), OK, AddressList(), now); + cache.Set(Key("foobar3.com"), OK, AddressList(), now); + + EXPECT_EQ(3u, cache.size()); + + cache.clear(); + + EXPECT_EQ(0u, cache.size()); +} + // Tests the less than and equal operators for HostCache::Key work. TEST(HostCacheTest, KeyComparators) { struct { |