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_BASE_MULTI_THREADED_CERT_VERIFIER_H_ | 5 #ifndef NET_BASE_MULTI_THREADED_CERT_VERIFIER_H_ |
6 #define NET_BASE_MULTI_THREADED_CERT_VERIFIER_H_ | 6 #define NET_BASE_MULTI_THREADED_CERT_VERIFIER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 friend class MultiThreadedCertVerifierTest; | 59 friend class MultiThreadedCertVerifierTest; |
60 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, CacheHit); | 60 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, CacheHit); |
61 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, DifferentCACerts); | 61 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, DifferentCACerts); |
62 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, InflightJoin); | 62 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, InflightJoin); |
63 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, CancelRequest); | 63 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, CancelRequest); |
64 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, | 64 FRIEND_TEST_ALL_PREFIXES(MultiThreadedCertVerifierTest, |
65 RequestParamsComparators); | 65 RequestParamsComparators); |
66 | 66 |
67 // Input parameters of a certificate verification request. | 67 // Input parameters of a certificate verification request. |
68 struct RequestParams { | 68 struct RequestParams { |
69 RequestParams(const SHA1HashValue& cert_fingerprint_arg, | 69 RequestParams(const SHA1Fingerprint& cert_fingerprint_arg, |
70 const SHA1HashValue& ca_fingerprint_arg, | 70 const SHA1Fingerprint& ca_fingerprint_arg, |
71 const std::string& hostname_arg, | 71 const std::string& hostname_arg, |
72 int flags_arg) | 72 int flags_arg) |
73 : cert_fingerprint(cert_fingerprint_arg), | 73 : cert_fingerprint(cert_fingerprint_arg), |
74 ca_fingerprint(ca_fingerprint_arg), | 74 ca_fingerprint(ca_fingerprint_arg), |
75 hostname(hostname_arg), | 75 hostname(hostname_arg), |
76 flags(flags_arg) {} | 76 flags(flags_arg) {} |
77 | 77 |
78 bool operator<(const RequestParams& other) const { | 78 bool operator<(const RequestParams& other) const { |
79 // |flags| is compared before |cert_fingerprint|, |ca_fingerprint|, and | 79 // |flags| is compared before |cert_fingerprint|, |ca_fingerprint|, and |
80 // |hostname| under assumption that integer comparisons are faster than | 80 // |hostname| under assumption that integer comparisons are faster than |
81 // memory and string comparisons. | 81 // memory and string comparisons. |
82 if (flags != other.flags) | 82 if (flags != other.flags) |
83 return flags < other.flags; | 83 return flags < other.flags; |
84 int rv = memcmp(cert_fingerprint.data, other.cert_fingerprint.data, | 84 int rv = memcmp(cert_fingerprint.data, other.cert_fingerprint.data, |
85 sizeof(cert_fingerprint.data)); | 85 sizeof(cert_fingerprint.data)); |
86 if (rv != 0) | 86 if (rv != 0) |
87 return rv < 0; | 87 return rv < 0; |
88 rv = memcmp(ca_fingerprint.data, other.ca_fingerprint.data, | 88 rv = memcmp(ca_fingerprint.data, other.ca_fingerprint.data, |
89 sizeof(ca_fingerprint.data)); | 89 sizeof(ca_fingerprint.data)); |
90 if (rv != 0) | 90 if (rv != 0) |
91 return rv < 0; | 91 return rv < 0; |
92 return hostname < other.hostname; | 92 return hostname < other.hostname; |
93 } | 93 } |
94 | 94 |
95 SHA1HashValue cert_fingerprint; | 95 SHA1Fingerprint cert_fingerprint; |
96 SHA1HashValue ca_fingerprint; | 96 SHA1Fingerprint ca_fingerprint; |
97 std::string hostname; | 97 std::string hostname; |
98 int flags; | 98 int flags; |
99 }; | 99 }; |
100 | 100 |
101 // CachedResult contains the result of a certificate verification. | 101 // CachedResult contains the result of a certificate verification. |
102 struct CachedResult { | 102 struct CachedResult { |
103 CachedResult(); | 103 CachedResult(); |
104 ~CachedResult(); | 104 ~CachedResult(); |
105 | 105 |
106 int error; // The return value of CertVerifier::Verify. | 106 int error; // The return value of CertVerifier::Verify. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 uint64 inflight_joins_; | 161 uint64 inflight_joins_; |
162 | 162 |
163 scoped_refptr<CertVerifyProc> verify_proc_; | 163 scoped_refptr<CertVerifyProc> verify_proc_; |
164 | 164 |
165 DISALLOW_COPY_AND_ASSIGN(MultiThreadedCertVerifier); | 165 DISALLOW_COPY_AND_ASSIGN(MultiThreadedCertVerifier); |
166 }; | 166 }; |
167 | 167 |
168 } // namespace net | 168 } // namespace net |
169 | 169 |
170 #endif // NET_BASE_MULTI_THREADED_CERT_VERIFIER_H_ | 170 #endif // NET_BASE_MULTI_THREADED_CERT_VERIFIER_H_ |
OLD | NEW |