| OLD | NEW |
| 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 #ifndef NET_CERT_MULTI_THREADED_CERT_VERIFIER_H_ | 5 #ifndef NET_CERT_MULTI_THREADED_CERT_VERIFIER_H_ |
| 6 #define NET_CERT_MULTI_THREADED_CERT_VERIFIER_H_ | 6 #define NET_CERT_MULTI_THREADED_CERT_VERIFIER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // synchronous CertVerifier implementations on worker threads. | 34 // synchronous CertVerifier implementations on worker threads. |
| 35 class NET_EXPORT_PRIVATE MultiThreadedCertVerifier | 35 class NET_EXPORT_PRIVATE MultiThreadedCertVerifier |
| 36 : public CertVerifier, | 36 : public CertVerifier, |
| 37 NON_EXPORTED_BASE(public base::NonThreadSafe), | 37 NON_EXPORTED_BASE(public base::NonThreadSafe), |
| 38 public CertDatabase::Observer { | 38 public CertDatabase::Observer { |
| 39 public: | 39 public: |
| 40 explicit MultiThreadedCertVerifier(CertVerifyProc* verify_proc); | 40 explicit MultiThreadedCertVerifier(CertVerifyProc* verify_proc); |
| 41 | 41 |
| 42 // When the verifier is destroyed, all certificate verifications requests are | 42 // When the verifier is destroyed, all certificate verifications requests are |
| 43 // canceled, and their completion callbacks will not be called. | 43 // canceled, and their completion callbacks will not be called. |
| 44 virtual ~MultiThreadedCertVerifier(); | 44 ~MultiThreadedCertVerifier() override; |
| 45 | 45 |
| 46 // Configures a source of additional certificates that should be treated as | 46 // Configures a source of additional certificates that should be treated as |
| 47 // trust anchors during verification, provided that the underlying | 47 // trust anchors during verification, provided that the underlying |
| 48 // CertVerifyProc supports additional trust beyond the default implementation. | 48 // CertVerifyProc supports additional trust beyond the default implementation. |
| 49 // The CertTrustAnchorProvider will only be accessed on the same | 49 // The CertTrustAnchorProvider will only be accessed on the same |
| 50 // thread that Verify() is called on; that is, it will not be | 50 // thread that Verify() is called on; that is, it will not be |
| 51 // accessed from worker threads. | 51 // accessed from worker threads. |
| 52 // It must outlive the MultiThreadedCertVerifier. | 52 // It must outlive the MultiThreadedCertVerifier. |
| 53 void SetCertTrustAnchorProvider( | 53 void SetCertTrustAnchorProvider( |
| 54 CertTrustAnchorProvider* trust_anchor_provider); | 54 CertTrustAnchorProvider* trust_anchor_provider); |
| 55 | 55 |
| 56 // CertVerifier implementation | 56 // CertVerifier implementation |
| 57 virtual int Verify(X509Certificate* cert, | 57 int Verify(X509Certificate* cert, |
| 58 const std::string& hostname, | 58 const std::string& hostname, |
| 59 int flags, | 59 int flags, |
| 60 CRLSet* crl_set, | 60 CRLSet* crl_set, |
| 61 CertVerifyResult* verify_result, | 61 CertVerifyResult* verify_result, |
| 62 const CompletionCallback& callback, | 62 const CompletionCallback& callback, |
| 63 CertVerifier::RequestHandle* out_req, | 63 CertVerifier::RequestHandle* out_req, |
| 64 const BoundNetLog& net_log) override; | 64 const BoundNetLog& net_log) override; |
| 65 | 65 |
| 66 virtual void CancelRequest(CertVerifier::RequestHandle req) override; | 66 void CancelRequest(CertVerifier::RequestHandle req) override; |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 friend class CertVerifierWorker; // Calls HandleResult. | 69 friend class CertVerifierWorker; // Calls HandleResult. |
| 70 friend class CertVerifierRequest; | 70 friend class CertVerifierRequest; |
| 71 friend class CertVerifierJob; | 71 friend class CertVerifierJob; |
| 72 friend class MultiThreadedCertVerifierTest; | 72 friend class MultiThreadedCertVerifierTest; |
| 73 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, CacheHit); | 73 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, CacheHit); |
| 74 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, DifferentCACerts); | 74 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, DifferentCACerts); |
| 75 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, InflightJoin); | 75 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, InflightJoin); |
| 76 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, CancelRequest); | 76 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, CancelRequest); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 CacheExpirationFunctor> CertVerifierCache; | 130 CacheExpirationFunctor> CertVerifierCache; |
| 131 | 131 |
| 132 void HandleResult(X509Certificate* cert, | 132 void HandleResult(X509Certificate* cert, |
| 133 const std::string& hostname, | 133 const std::string& hostname, |
| 134 int flags, | 134 int flags, |
| 135 const CertificateList& additional_trust_anchors, | 135 const CertificateList& additional_trust_anchors, |
| 136 int error, | 136 int error, |
| 137 const CertVerifyResult& verify_result); | 137 const CertVerifyResult& verify_result); |
| 138 | 138 |
| 139 // CertDatabase::Observer methods: | 139 // CertDatabase::Observer methods: |
| 140 virtual void OnCACertChanged(const X509Certificate* cert) override; | 140 void OnCACertChanged(const X509Certificate* cert) override; |
| 141 | 141 |
| 142 // For unit testing. | 142 // For unit testing. |
| 143 void ClearCache() { cache_.Clear(); } | 143 void ClearCache() { cache_.Clear(); } |
| 144 size_t GetCacheSize() const { return cache_.size(); } | 144 size_t GetCacheSize() const { return cache_.size(); } |
| 145 uint64 cache_hits() const { return cache_hits_; } | 145 uint64 cache_hits() const { return cache_hits_; } |
| 146 uint64 requests() const { return requests_; } | 146 uint64 requests() const { return requests_; } |
| 147 uint64 inflight_joins() const { return inflight_joins_; } | 147 uint64 inflight_joins() const { return inflight_joins_; } |
| 148 | 148 |
| 149 // cache_ maps from a request to a cached result. | 149 // cache_ maps from a request to a cached result. |
| 150 CertVerifierCache cache_; | 150 CertVerifierCache cache_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 163 scoped_refptr<CertVerifyProc> verify_proc_; | 163 scoped_refptr<CertVerifyProc> verify_proc_; |
| 164 | 164 |
| 165 CertTrustAnchorProvider* trust_anchor_provider_; | 165 CertTrustAnchorProvider* trust_anchor_provider_; |
| 166 | 166 |
| 167 DISALLOW_COPY_AND_ASSIGN(MultiThreadedCertVerifier); | 167 DISALLOW_COPY_AND_ASSIGN(MultiThreadedCertVerifier); |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 } // namespace net | 170 } // namespace net |
| 171 | 171 |
| 172 #endif // NET_CERT_MULTI_THREADED_CERT_VERIFIER_H_ | 172 #endif // NET_CERT_MULTI_THREADED_CERT_VERIFIER_H_ |
| OLD | NEW |