diff options
author | szym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-20 20:40:20 +0000 |
---|---|---|
committer | szym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-20 20:40:20 +0000 |
commit | 3e439bef5e0afdf928fafd2e8cff13c13f6b9d11 (patch) | |
tree | 3137f0d781e87cab4aaf05e190bddc173b7bcfe9 /net/proxy | |
parent | d1a526859b8488c5841720b2f6384c76e5ef3859 (diff) | |
download | chromium_src-3e439bef5e0afdf928fafd2e8cff13c13f6b9d11.zip chromium_src-3e439bef5e0afdf928fafd2e8cff13c13f6b9d11.tar.gz chromium_src-3e439bef5e0afdf928fafd2e8cff13c13f6b9d11.tar.bz2 |
Adds custom ttl argument to HostCache::Set.
BUG=25472,107880
TEST=net_unittests
Review URL: http://codereview.chromium.org/9197009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118489 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy')
-rw-r--r-- | net/proxy/proxy_resolver_js_bindings.cc | 9 | ||||
-rw-r--r-- | net/proxy/proxy_resolver_js_bindings_unittest.cc | 7 | ||||
-rw-r--r-- | net/proxy/proxy_resolver_v8.cc | 12 |
3 files changed, 15 insertions, 13 deletions
diff --git a/net/proxy/proxy_resolver_js_bindings.cc b/net/proxy/proxy_resolver_js_bindings.cc index f3f6c15..399eee41 100644 --- a/net/proxy/proxy_resolver_js_bindings.cc +++ b/net/proxy/proxy_resolver_js_bindings.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -23,6 +23,10 @@ namespace net { namespace { +// TTL for the per-request DNS cache. Applies to both successful and failed +// DNS resolutions. +const base::TimeDelta kCacheEntryTTL = base::TimeDelta::FromMinutes(5); + // Event parameters for a PAC error message (line number + message). class ErrorNetlogParams : public NetLog::EventParameters { public: @@ -263,7 +267,8 @@ class DefaultJSBindings : public ProxyResolverJSBindings { // Save the result back to the per-request DNS cache. if (host_cache) { host_cache->Set(cache_key, result, *address_list, - base::TimeTicks::Now()); + base::TimeTicks::Now(), + kCacheEntryTTL); } return result; diff --git a/net/proxy/proxy_resolver_js_bindings_unittest.cc b/net/proxy/proxy_resolver_js_bindings_unittest.cc index 6ead6ef..dc346e0 100644 --- a/net/proxy/proxy_resolver_js_bindings_unittest.cc +++ b/net/proxy/proxy_resolver_js_bindings_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -235,9 +235,8 @@ TEST(ProxyResolverJSBindingsTest, PerRequestDNSCache) { // Now setup a per-request context, and try the same experiment -- we // expect the underlying host resolver to receive only 1 request this time, // since it will service the others from the per-request DNS cache. - HostCache cache(50, - base::TimeDelta::FromMinutes(10), - base::TimeDelta::FromMinutes(10)); + const unsigned kMaxCacheEntries = 50; + HostCache cache(kMaxCacheEntries); ProxyResolverRequestContext context(NULL, &cache); bindings->set_current_request_context(&context); diff --git a/net/proxy/proxy_resolver_v8.cc b/net/proxy/proxy_resolver_v8.cc index 92beb80..114bf0f 100644 --- a/net/proxy/proxy_resolver_v8.cc +++ b/net/proxy/proxy_resolver_v8.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -742,12 +742,10 @@ int ProxyResolverV8::GetProxyForURL( // available to any of the javascript "bindings" that are subsequently invoked // from the javascript. // - // In particular, we create a HostCache that is aggressive about caching - // failed DNS resolves. - HostCache host_cache( - 50, - base::TimeDelta::FromMinutes(5), - base::TimeDelta::FromMinutes(5)); + // In particular, we create a HostCache to aggressively cache failed DNS + // resolves. + const unsigned kMaxCacheEntries = 50; + HostCache host_cache(kMaxCacheEntries); ProxyResolverRequestContext request_context(&net_log, &host_cache); |