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

Side by Side Diff: net/cert/multi_threaded_cert_verifier.cc

Issue 1892033002: Cert - protobufs to serialize and deserialize CertVerifierCache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/cert/multi_threaded_cert_verifier.h" 5 #include "net/cert/multi_threaded_cert_verifier.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 hash_values.push_back(ocsp_hash); 496 hash_values.push_back(ocsp_hash);
497 hash_values.push_back(cert_fingerprint_arg); 497 hash_values.push_back(cert_fingerprint_arg);
498 hash_values.push_back(ca_fingerprint_arg); 498 hash_values.push_back(ca_fingerprint_arg);
499 for (size_t i = 0; i < additional_trust_anchors.size(); ++i) 499 for (size_t i = 0; i < additional_trust_anchors.size(); ++i)
500 hash_values.push_back(additional_trust_anchors[i]->fingerprint()); 500 hash_values.push_back(additional_trust_anchors[i]->fingerprint());
501 } 501 }
502 502
503 MultiThreadedCertVerifier::RequestParams::RequestParams( 503 MultiThreadedCertVerifier::RequestParams::RequestParams(
504 const RequestParams& other) = default; 504 const RequestParams& other) = default;
505 505
506 MultiThreadedCertVerifier::RequestParams::RequestParams() {}
507
506 MultiThreadedCertVerifier::RequestParams::~RequestParams() {} 508 MultiThreadedCertVerifier::RequestParams::~RequestParams() {}
507 509
508 bool MultiThreadedCertVerifier::RequestParams::operator<( 510 bool MultiThreadedCertVerifier::RequestParams::operator<(
509 const RequestParams& other) const { 511 const RequestParams& other) const {
510 // |flags| is compared before |cert_fingerprint|, |ca_fingerprint|, 512 // |flags| is compared before |cert_fingerprint|, |ca_fingerprint|,
511 // |hostname|, and |ocsp_response|, under assumption that integer comparisons 513 // |hostname|, and |ocsp_response|, under assumption that integer comparisons
512 // are faster than memory and string comparisons. 514 // are faster than memory and string comparisons.
513 if (flags != other.flags) 515 if (flags != other.flags)
514 return flags < other.flags; 516 return flags < other.flags;
515 if (hostname != other.hostname) 517 if (hostname != other.hostname)
516 return hostname < other.hostname; 518 return hostname < other.hostname;
517 return std::lexicographical_compare( 519 return std::lexicographical_compare(
518 hash_values.begin(), hash_values.end(), other.hash_values.begin(), 520 hash_values.begin(), hash_values.end(), other.hash_values.begin(),
519 other.hash_values.end(), SHA1HashValueLessThan()); 521 other.hash_values.end(), SHA1HashValueLessThan());
520 } 522 }
521 523
522 bool MultiThreadedCertVerifier::JobComparator::operator()( 524 bool MultiThreadedCertVerifier::JobComparator::operator()(
523 const CertVerifierJob* job1, 525 const CertVerifierJob* job1,
524 const CertVerifierJob* job2) const { 526 const CertVerifierJob* job2) const {
525 return job1->key() < job2->key(); 527 return job1->key() < job2->key();
526 } 528 }
527 529
530 MultiThreadedCertVerifier::CertVerifierCacheIterator::CertVerifierCacheIterator(
531 const MultiThreadedCertVerifier& verifier)
532 : iterator_(verifier.cache_) {}
533
534 MultiThreadedCertVerifier::CertVerifierCacheIterator::
535 ~CertVerifierCacheIterator() {}
536
528 void MultiThreadedCertVerifier::SaveResultToCache(const RequestParams& key, 537 void MultiThreadedCertVerifier::SaveResultToCache(const RequestParams& key,
529 const CachedResult& result) { 538 const CachedResult& result) {
530 DCHECK(CalledOnValidThread()); 539 DCHECK(CalledOnValidThread());
531 540
532 // When caching, this uses the time that validation started as the 541 // When caching, this uses the time that validation started as the
533 // beginning of the validity, rather than the time that it ended (aka 542 // beginning of the validity, rather than the time that it ended (aka
534 // base::Time::Now()), to account for the fact that during validation, 543 // base::Time::Now()), to account for the fact that during validation,
535 // the clock may have changed. 544 // the clock may have changed.
536 // 545 //
537 // If the clock has changed significantly, then this result will ideally 546 // If the clock has changed significantly, then this result will ideally
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 // The JobSet is kept in sorted order so items can be found using binary 596 // The JobSet is kept in sorted order so items can be found using binary
588 // search. 597 // search.
589 auto it = std::lower_bound(inflight_.begin(), inflight_.end(), key, 598 auto it = std::lower_bound(inflight_.begin(), inflight_.end(), key,
590 JobToRequestParamsComparator()); 599 JobToRequestParamsComparator());
591 if (it != inflight_.end() && !(key < (*it)->key())) 600 if (it != inflight_.end() && !(key < (*it)->key()))
592 return *it; 601 return *it;
593 return nullptr; 602 return nullptr;
594 } 603 }
595 604
596 } // namespace net 605 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698