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 #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 11 matching lines...) Expand all Loading... |
22 #include "base/values.h" | 22 #include "base/values.h" |
23 #include "net/base/hash_value.h" | 23 #include "net/base/hash_value.h" |
24 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
25 #include "net/cert/cert_trust_anchor_provider.h" | 25 #include "net/cert/cert_trust_anchor_provider.h" |
26 #include "net/cert/cert_verify_proc.h" | 26 #include "net/cert/cert_verify_proc.h" |
27 #include "net/cert/crl_set.h" | 27 #include "net/cert/crl_set.h" |
28 #include "net/cert/x509_certificate.h" | 28 #include "net/cert/x509_certificate.h" |
29 #include "net/cert/x509_certificate_net_log_param.h" | 29 #include "net/cert/x509_certificate_net_log_param.h" |
30 #include "net/log/net_log.h" | 30 #include "net/log/net_log.h" |
31 | 31 |
32 #if defined(USE_NSS_CERTS) || defined(OS_IOS) | 32 #if defined(USE_NSS_VERIFIER) |
33 #include <private/pprthred.h> // PR_DetachThread | 33 #include <private/pprthred.h> // PR_DetachThread |
34 #endif | 34 #endif |
35 | 35 |
36 namespace net { | 36 namespace net { |
37 | 37 |
38 //////////////////////////////////////////////////////////////////////////// | 38 //////////////////////////////////////////////////////////////////////////// |
39 // | 39 // |
40 // MultiThreadedCertVerifier is a thread-unsafe object which lives, dies, and is | 40 // MultiThreadedCertVerifier is a thread-unsafe object which lives, dies, and is |
41 // operated on a single thread, henceforth referred to as the "origin" thread. | 41 // operated on a single thread, henceforth referred to as the "origin" thread. |
42 // | 42 // |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 const std::string& hostname, | 230 const std::string& hostname, |
231 const std::string& ocsp_response, | 231 const std::string& ocsp_response, |
232 int flags, | 232 int flags, |
233 const scoped_refptr<CRLSet>& crl_set, | 233 const scoped_refptr<CRLSet>& crl_set, |
234 const CertificateList& additional_trust_anchors, | 234 const CertificateList& additional_trust_anchors, |
235 int* error, | 235 int* error, |
236 CertVerifyResult* result) { | 236 CertVerifyResult* result) { |
237 *error = verify_proc->Verify(cert.get(), hostname, ocsp_response, flags, | 237 *error = verify_proc->Verify(cert.get(), hostname, ocsp_response, flags, |
238 crl_set.get(), additional_trust_anchors, result); | 238 crl_set.get(), additional_trust_anchors, result); |
239 | 239 |
240 #if defined(USE_NSS_CERTS) || defined(OS_IOS) | 240 #if defined(USE_NSS_VERIFIER) |
241 // Detach the thread from NSPR. | 241 // Detach the thread from NSPR. |
242 // Calling NSS functions attaches the thread to NSPR, which stores | 242 // Calling NSS functions attaches the thread to NSPR, which stores |
243 // the NSPR thread ID in thread-specific data. | 243 // the NSPR thread ID in thread-specific data. |
244 // The threads in our thread pool terminate after we have called | 244 // The threads in our thread pool terminate after we have called |
245 // PR_Cleanup. Unless we detach them from NSPR, net_unittests gets | 245 // PR_Cleanup. Unless we detach them from NSPR, net_unittests gets |
246 // segfaults on shutdown when the threads' thread-specific data | 246 // segfaults on shutdown when the threads' thread-specific data |
247 // destructors run. | 247 // destructors run. |
248 PR_DetachThread(); | 248 PR_DetachThread(); |
249 #endif | 249 #endif |
250 } | 250 } |
251 | 251 |
252 // CertVerifierJob lives only on the verifier's origin message loop. | 252 // CertVerifierJob lives only on the verifier's origin message loop. |
253 class CertVerifierJob { | 253 class CertVerifierJob { |
254 public: | 254 public: |
255 CertVerifierJob(const MultiThreadedCertVerifier::RequestParams& key, | 255 CertVerifierJob(const MultiThreadedCertVerifier::RequestParams& key, |
256 NetLog* net_log, | 256 NetLog* net_log, |
257 X509Certificate* cert, | 257 X509Certificate* cert, |
258 MultiThreadedCertVerifier* cert_verifier) | 258 MultiThreadedCertVerifier* cert_verifier) |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 // The JobSet is kept in sorted order so items can be found using binary | 584 // The JobSet is kept in sorted order so items can be found using binary |
585 // search. | 585 // search. |
586 auto it = std::lower_bound(inflight_.begin(), inflight_.end(), key, | 586 auto it = std::lower_bound(inflight_.begin(), inflight_.end(), key, |
587 JobToRequestParamsComparator()); | 587 JobToRequestParamsComparator()); |
588 if (it != inflight_.end() && !(key < (*it)->key())) | 588 if (it != inflight_.end() && !(key < (*it)->key())) |
589 return *it; | 589 return *it; |
590 return nullptr; | 590 return nullptr; |
591 } | 591 } |
592 | 592 |
593 } // namespace net | 593 } // namespace net |
594 | |
OLD | NEW |