summaryrefslogtreecommitdiffstats
path: root/net/base/cert_verifier.cc
diff options
context:
space:
mode:
authorwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-23 06:46:35 +0000
committerwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-23 06:46:35 +0000
commit29dd9be9e0669dcb42835828ac4e7e7ae981816a (patch)
tree5dc2f103e625860777d7b0c139fdad5eb30e0264 /net/base/cert_verifier.cc
parent630d986401e1ea3125bf7cc61f3b03e89efcd29b (diff)
downloadchromium_src-29dd9be9e0669dcb42835828ac4e7e7ae981816a.zip
chromium_src-29dd9be9e0669dcb42835828ac4e7e7ae981816a.tar.gz
chromium_src-29dd9be9e0669dcb42835828ac4e7e7ae981816a.tar.bz2
Add the CertVerifier::set_max_cache_entries() method.
This allows the CertVerifierTest.FullCache test to use a small cache size and finish faster. R=rvargas@chromium.org BUG=88135 TEST=net_unittests --gtest_filter=CertVerifierTest.FullCache should not take a long time to finish. Review URL: http://codereview.chromium.org/7671036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97825 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/cert_verifier.cc')
-rw-r--r--net/base/cert_verifier.cc20
1 files changed, 11 insertions, 9 deletions
diff --git a/net/base/cert_verifier.cc b/net/base/cert_verifier.cc
index 9282162..db630dd 100644
--- a/net/base/cert_verifier.cc
+++ b/net/base/cert_verifier.cc
@@ -59,13 +59,13 @@ namespace net {
// On a cache hit, CertVerifier::Verify() returns synchronously without
// posting a task to a worker thread.
-// The number of CachedCertVerifyResult objects that we'll cache.
-static const unsigned kMaxCacheEntries = 256;
+namespace {
-// The number of seconds for which we'll cache a cache entry.
-static const unsigned kTTLSecs = 1800; // 30 minutes.
+// The default value of max_cache_entries_.
+const unsigned kMaxCacheEntries = 256;
-namespace {
+// The number of seconds for which we'll cache a cache entry.
+const unsigned kTTLSecs = 1800; // 30 minutes.
class DefaultTimeService : public CertVerifier::TimeService {
public:
@@ -283,6 +283,7 @@ class CertVerifierJob {
CertVerifier::CertVerifier()
: time_service_(new DefaultTimeService),
+ max_cache_entries_(kMaxCacheEntries),
requests_(0),
cache_hits_(0),
inflight_joins_(0) {
@@ -291,6 +292,7 @@ CertVerifier::CertVerifier()
CertVerifier::CertVerifier(TimeService* time_service)
: time_service_(time_service),
+ max_cache_entries_(kMaxCacheEntries),
requests_(0),
cache_hits_(0),
inflight_joins_(0) {
@@ -403,9 +405,9 @@ void CertVerifier::HandleResult(X509Certificate* cert,
const RequestParams key = {cert->fingerprint(), hostname, flags};
- DCHECK_GE(kMaxCacheEntries, 1u);
- DCHECK_LE(cache_.size(), kMaxCacheEntries);
- if (cache_.size() == kMaxCacheEntries) {
+ DCHECK_GE(max_cache_entries_, 1u);
+ DCHECK_LE(cache_.size(), max_cache_entries_);
+ if (cache_.size() == max_cache_entries_) {
// Need to remove an element of the cache.
std::map<RequestParams, CachedCertVerifyResult>::iterator i, cur;
for (i = cache_.begin(); i != cache_.end(); ) {
@@ -414,7 +416,7 @@ void CertVerifier::HandleResult(X509Certificate* cert,
cache_.erase(cur);
}
}
- if (cache_.size() == kMaxCacheEntries) {
+ if (cache_.size() == max_cache_entries_) {
// If we didn't clear out any expired entries, we just remove the first
// element. Crummy but simple.
cache_.erase(cache_.begin());