| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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/cert_verifier.h" | 5 #include "net/base/cert_verifier.h" |
| 6 | 6 |
| 7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
| 8 #include <private/pprthred.h> // PR_DetatchThread | 8 #include <private/pprthred.h> // PR_DetatchThread |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 : cert_(cert), | 28 : cert_(cert), |
| 29 hostname_(hostname), | 29 hostname_(hostname), |
| 30 flags_(flags), | 30 flags_(flags), |
| 31 verifier_(verifier), | 31 verifier_(verifier), |
| 32 verify_result_(verify_result), | 32 verify_result_(verify_result), |
| 33 callback_(callback), | 33 callback_(callback), |
| 34 origin_loop_(MessageLoop::current()), | 34 origin_loop_(MessageLoop::current()), |
| 35 error_(OK) { | 35 error_(OK) { |
| 36 } | 36 } |
| 37 | 37 |
| 38 ~Request() {} | |
| 39 | |
| 40 void DoVerify() { | 38 void DoVerify() { |
| 41 // Running on the worker thread | 39 // Running on the worker thread |
| 42 error_ = cert_->Verify(hostname_, flags_, &result_); | 40 error_ = cert_->Verify(hostname_, flags_, &result_); |
| 43 #if defined(OS_LINUX) | 41 #if defined(OS_LINUX) |
| 44 // Detach the thread from NSPR. | 42 // Detach the thread from NSPR. |
| 45 // Calling NSS functions attaches the thread to NSPR, which stores | 43 // Calling NSS functions attaches the thread to NSPR, which stores |
| 46 // the NSPR thread ID in thread-specific data. | 44 // the NSPR thread ID in thread-specific data. |
| 47 // The threads in our thread pool terminate after we have called | 45 // The threads in our thread pool terminate after we have called |
| 48 // PR_Cleanup. Unless we detach them from NSPR, net_unittests gets | 46 // PR_Cleanup. Unless we detach them from NSPR, net_unittests gets |
| 49 // segfaults on shutdown when the threads' thread-specific data | 47 // segfaults on shutdown when the threads' thread-specific data |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 83 } |
| 86 | 84 |
| 87 void Cancel() { | 85 void Cancel() { |
| 88 verifier_ = NULL; | 86 verifier_ = NULL; |
| 89 | 87 |
| 90 AutoLock locked(origin_loop_lock_); | 88 AutoLock locked(origin_loop_lock_); |
| 91 origin_loop_ = NULL; | 89 origin_loop_ = NULL; |
| 92 } | 90 } |
| 93 | 91 |
| 94 private: | 92 private: |
| 93 friend class base::RefCountedThreadSafe<CertVerifier::Request>; |
| 94 |
| 95 ~Request() {} |
| 96 |
| 95 // Set on the origin thread, read on the worker thread. | 97 // Set on the origin thread, read on the worker thread. |
| 96 scoped_refptr<X509Certificate> cert_; | 98 scoped_refptr<X509Certificate> cert_; |
| 97 std::string hostname_; | 99 std::string hostname_; |
| 98 // bitwise OR'd of X509Certificate::VerifyFlags. | 100 // bitwise OR'd of X509Certificate::VerifyFlags. |
| 99 int flags_; | 101 int flags_; |
| 100 | 102 |
| 101 // Only used on the origin thread (where Verify was called). | 103 // Only used on the origin thread (where Verify was called). |
| 102 CertVerifier* verifier_; | 104 CertVerifier* verifier_; |
| 103 CertVerifyResult* verify_result_; | 105 CertVerifyResult* verify_result_; |
| 104 CompletionCallback* callback_; | 106 CompletionCallback* callback_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 NewRunnableMethod(request_.get(), &Request::DoVerify), true)) { | 146 NewRunnableMethod(request_.get(), &Request::DoVerify), true)) { |
| 145 NOTREACHED(); | 147 NOTREACHED(); |
| 146 request_ = NULL; | 148 request_ = NULL; |
| 147 return ERR_FAILED; | 149 return ERR_FAILED; |
| 148 } | 150 } |
| 149 | 151 |
| 150 return ERR_IO_PENDING; | 152 return ERR_IO_PENDING; |
| 151 } | 153 } |
| 152 | 154 |
| 153 } // namespace net | 155 } // namespace net |
| OLD | NEW |