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/base/multi_threaded_cert_verifier.h" | 5 #include "net/base/multi_threaded_cert_verifier.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "base/threading/worker_pool.h" | 17 #include "base/threading/worker_pool.h" |
18 #include "net/base/cert_verify_proc.h" | 18 #include "net/base/cert_verify_proc.h" |
19 #include "net/base/crl_set.h" | 19 #include "net/base/crl_set.h" |
20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
21 #include "net/base/net_log.h" | 21 #include "net/base/net_log.h" |
22 #include "net/base/x509_certificate.h" | 22 #include "net/base/x509_certificate.h" |
23 #include "net/base/x509_certificate_net_log_param.h" | 23 #include "net/base/x509_certificate_net_log_param.h" |
24 | 24 |
25 #if defined(USE_NSS) | 25 #if defined(USE_NSS) || defined(OS_IOS) |
26 #include <private/pprthred.h> // PR_DetachThread | 26 #include <private/pprthred.h> // PR_DetachThread |
27 #endif | 27 #endif |
28 | 28 |
29 namespace net { | 29 namespace net { |
30 | 30 |
31 //////////////////////////////////////////////////////////////////////////// | 31 //////////////////////////////////////////////////////////////////////////// |
32 | 32 |
33 // Life of a request: | 33 // Life of a request: |
34 // | 34 // |
35 // MultiThreadedCertVerifier CertVerifierJob CertVerifierWorker Request | 35 // MultiThreadedCertVerifier CertVerifierJob CertVerifierWorker Request |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 DCHECK_EQ(MessageLoop::current(), origin_loop_); | 217 DCHECK_EQ(MessageLoop::current(), origin_loop_); |
218 base::AutoLock locked(lock_); | 218 base::AutoLock locked(lock_); |
219 canceled_ = true; | 219 canceled_ = true; |
220 } | 220 } |
221 | 221 |
222 private: | 222 private: |
223 void Run() { | 223 void Run() { |
224 // Runs on a worker thread. | 224 // Runs on a worker thread. |
225 error_ = verify_proc_->Verify(cert_, hostname_, flags_, crl_set_, | 225 error_ = verify_proc_->Verify(cert_, hostname_, flags_, crl_set_, |
226 &verify_result_); | 226 &verify_result_); |
227 #if defined(USE_NSS) | 227 #if defined(USE_NSS) || defined(OS_IOS) |
228 // Detach the thread from NSPR. | 228 // Detach the thread from NSPR. |
229 // Calling NSS functions attaches the thread to NSPR, which stores | 229 // Calling NSS functions attaches the thread to NSPR, which stores |
230 // the NSPR thread ID in thread-specific data. | 230 // the NSPR thread ID in thread-specific data. |
231 // The threads in our thread pool terminate after we have called | 231 // The threads in our thread pool terminate after we have called |
232 // PR_Cleanup. Unless we detach them from NSPR, net_unittests gets | 232 // PR_Cleanup. Unless we detach them from NSPR, net_unittests gets |
233 // segfaults on shutdown when the threads' thread-specific data | 233 // segfaults on shutdown when the threads' thread-specific data |
234 // destructors run. | 234 // destructors run. |
235 PR_DetachThread(); | 235 PR_DetachThread(); |
236 #endif | 236 #endif |
237 Finish(); | 237 Finish(); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 } | 505 } |
506 | 506 |
507 void MultiThreadedCertVerifier::OnCertTrustChanged( | 507 void MultiThreadedCertVerifier::OnCertTrustChanged( |
508 const X509Certificate* cert) { | 508 const X509Certificate* cert) { |
509 DCHECK(CalledOnValidThread()); | 509 DCHECK(CalledOnValidThread()); |
510 | 510 |
511 ClearCache(); | 511 ClearCache(); |
512 } | 512 } |
513 | 513 |
514 } // namespace net | 514 } // namespace net |
OLD | NEW |