Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2133)

Unified Diff: net/cert/caching_cert_verifier.cc

Issue 1999733002: Add support for walking and modifying the CachingCertVerifier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_cache
Patch Set: Constify Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cert/caching_cert_verifier.h ('k') | net/cert/caching_cert_verifier_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..764c2ab6f02bbe0ac77c218fd420f19e78a055be 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,23 @@ void CachingCertVerifier::AddResultToCache(
start_time + base::TimeDelta::FromSeconds(kTTLSecs)));
}
+void CachingCertVerifier::VisitEntries(CacheVisitor* visitor) const {
+ DCHECK(visitor);
+
+ CacheValidityPeriod now(base::Time::Now());
+ CacheExpirationFunctor expiration_cmp;
+
+ for (CertVerificationCache::Iterator it(cache_); 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();
}
« no previous file with comments | « net/cert/caching_cert_verifier.h ('k') | net/cert/caching_cert_verifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698