| Index: net/cert/multi_threaded_cert_verifier.cc
|
| diff --git a/net/cert/multi_threaded_cert_verifier.cc b/net/cert/multi_threaded_cert_verifier.cc
|
| index 2d650253ddaebabafe7f47c04436253a3212cfc1..50e96bb904d046f001e465413dfa362f0c003f7c 100644
|
| --- a/net/cert/multi_threaded_cert_verifier.cc
|
| +++ b/net/cert/multi_threaded_cert_verifier.cc
|
| @@ -119,6 +119,13 @@ std::unique_ptr<base::Value> CertVerifyResultCallback(
|
|
|
| MultiThreadedCertVerifier::CachedResult::CachedResult() : error(ERR_FAILED) {}
|
|
|
| +MultiThreadedCertVerifier::CachedResult::CachedResult(
|
| + int error_arg,
|
| + CertVerifyResult result_arg)
|
| + : error(error_arg) {
|
| + result.CopyFrom(result_arg);
|
| +}
|
| +
|
| MultiThreadedCertVerifier::CachedResult::~CachedResult() {}
|
|
|
| MultiThreadedCertVerifier::CacheValidityPeriod::CacheValidityPeriod(
|
| @@ -483,6 +490,45 @@ bool MultiThreadedCertVerifier::SupportsOCSPStapling() {
|
| return verify_proc_->SupportsOCSPStapling();
|
| }
|
|
|
| +bool MultiThreadedCertVerifier::AddCertResult(
|
| + std::string& hostname,
|
| + int flags,
|
| + std::vector<SHA1HashValue>& hash_values,
|
| + base::Time start_time,
|
| + int error,
|
| + const CertVerifyResult& result,
|
| + base::Time verification_time,
|
| + base::Time expiration_time) {
|
| + // If cache is already full, then don't replace the current entries.
|
| + if (cache_.size() >= kMaxCacheEntries) {
|
| + DVLOG(1) << "Cache is full";
|
| + return false;
|
| + }
|
| + base::Time now = base::Time::Now();
|
| + if (expiration_time < now) {
|
| + DVLOG(1) << "Cache entry expired for: " << hostname;
|
| + return false;
|
| + }
|
| + if (verification_time > expiration_time || verification_time > now) {
|
| + DVLOG(1) << "Invalid verification_time for " << hostname;
|
| + return false;
|
| + }
|
| +
|
| + // Don't overwrite existing entry.
|
| + RequestParams key(hostname, flags, hash_values, start_time);
|
| + CacheValidityPeriod expiration(now);
|
| + if (cache_.Get(key, expiration)) {
|
| + DVLOG(1) << "Already exists in the cache for " << key.hostname;
|
| + return false;
|
| + }
|
| +
|
| + // Add a new entry.
|
| + CachedResult value(error, result);
|
| + cache_.Put(key, value, CacheValidityPeriod(verification_time),
|
| + CacheValidityPeriod(verification_time, expiration_time));
|
| + return true;
|
| +}
|
| +
|
| MultiThreadedCertVerifier::RequestParams::RequestParams(
|
| const SHA1HashValue& cert_fingerprint_arg,
|
| const SHA1HashValue& ca_fingerprint_arg,
|
| @@ -506,6 +552,17 @@ MultiThreadedCertVerifier::RequestParams::RequestParams(
|
| MultiThreadedCertVerifier::RequestParams::RequestParams(
|
| const RequestParams& other) = default;
|
|
|
| +MultiThreadedCertVerifier::RequestParams::RequestParams(
|
| + std::string& hostname_arg,
|
| + int flags_arg,
|
| + std::vector<SHA1HashValue>& hash_values_arg,
|
| + base::Time start_time_arg) {
|
| + hostname = hostname_arg;
|
| + flags = flags_arg;
|
| + hash_values.swap(hash_values_arg);
|
| + start_time = start_time_arg;
|
| +}
|
| +
|
| MultiThreadedCertVerifier::RequestParams::~RequestParams() {}
|
|
|
| bool MultiThreadedCertVerifier::RequestParams::operator<(
|
| @@ -596,4 +653,10 @@ CertVerifierJob* MultiThreadedCertVerifier::FindJob(const RequestParams& key) {
|
| return nullptr;
|
| }
|
|
|
| +CertVerifierCacheIterator::CertVerifierCacheIterator(
|
| + const MultiThreadedCertVerifier& verifier)
|
| + : iterator_(verifier.cache_) {}
|
| +
|
| +CertVerifierCacheIterator::~CertVerifierCacheIterator() {}
|
| +
|
| } // namespace net
|
|
|