Chromium Code Reviews| Index: net/cert/caching_cert_verifier.cc |
| diff --git a/net/cert/caching_cert_verifier.cc b/net/cert/caching_cert_verifier.cc |
| index 733d87867c350d50096bc8b4451b1c2246e378dd..08c06786547a32d0afdb42c96d8854b4e38b7e40 100644 |
| --- a/net/cert/caching_cert_verifier.cc |
| +++ b/net/cert/caching_cert_verifier.cc |
| @@ -86,6 +86,25 @@ bool CachingCertVerifier::SupportsOCSPStapling() { |
| return verifier_->SupportsOCSPStapling(); |
| } |
| +bool CachingCertVerifier::AddEntry(const RequestParams& params, |
| + int error, |
| + const CertVerifyResult& verify_result, |
| + base::Time verification_time) { |
| + // If the cache is full, don't bother. |
| + if (cache_.size() == cache_.max_entries()) |
| + return false; |
| + |
| + // If there is an existing entry, don't bother updating it. |
| + const CertVerificationCache::value_type* entry = |
| + cache_.Get(params, CacheValidityPeriod(base::Time::Now())); |
| + if (entry) |
| + return false; |
| + |
| + // Otherwise, go and add it. |
| + AddResultToCache(params, verification_time, verify_result, error); |
| + return true; |
| +} |
| + |
| CachingCertVerifier::CachedResult::CachedResult() : error(ERR_FAILED) {} |
| CachingCertVerifier::CachedResult::~CachedResult() {} |
| @@ -181,6 +200,25 @@ void CachingCertVerifier::AddResultToCache( |
| start_time + base::TimeDelta::FromSeconds(kTTLSecs))); |
| } |
| +void CachingCertVerifier::VisitEntries(CacheVisitor* visitor) { |
| + DCHECK(visitor); |
| + |
| + CacheValidityPeriod now(base::Time::Now()); |
| + CacheExpirationFunctor expiration_cmp; |
| + |
| + using Iter = CertVerificationCache::Iterator; |
| + Iter it(cache_); |
|
eroman
2016/06/16 00:25:04
optional: Move the definition of "it" into the for
|
| + for (; it.HasNext(); it.Advance()) { |
| + if (!expiration_cmp(now, it.expiration())) |
| + continue; |
| + if (!visitor->VisitEntry(it.key(), it.value().error, it.value().result, |
| + it.expiration().verification_time, |
| + it.expiration().expiration_time)) { |
| + break; |
| + } |
| + } |
| +} |
| + |
| void CachingCertVerifier::OnCACertChanged(const X509Certificate* cert) { |
| ClearCache(); |
| } |