| 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 <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/containers/linked_list.h" | 15 #include "base/containers/linked_list.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 18 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
| 19 #include "base/profiler/scoped_tracker.h" | 19 #include "base/profiler/scoped_tracker.h" |
| 20 #include "base/sha1.h" | 20 #include "base/sha1.h" |
| 21 #include "base/threading/worker_pool.h" | 21 #include "base/threading/worker_pool.h" |
| 22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 23 #include "base/trace_event/trace_event.h" | 23 #include "base/trace_event/trace_event.h" |
| 24 #include "base/values.h" | 24 #include "base/values.h" |
| 25 #include "net/base/hash_value.h" | 25 #include "net/base/hash_value.h" |
| 26 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
| 27 #include "net/base/trace_constants.h" |
| 27 #include "net/cert/cert_verify_proc.h" | 28 #include "net/cert/cert_verify_proc.h" |
| 28 #include "net/cert/cert_verify_result.h" | 29 #include "net/cert/cert_verify_result.h" |
| 29 #include "net/cert/crl_set.h" | 30 #include "net/cert/crl_set.h" |
| 30 #include "net/cert/x509_certificate.h" | 31 #include "net/cert/x509_certificate.h" |
| 31 #include "net/cert/x509_certificate_net_log_param.h" | 32 #include "net/cert/x509_certificate_net_log_param.h" |
| 32 #include "net/log/net_log_capture_mode.h" | 33 #include "net/log/net_log_capture_mode.h" |
| 33 #include "net/log/net_log_event_type.h" | 34 #include "net/log/net_log_event_type.h" |
| 34 #include "net/log/net_log_source.h" | 35 #include "net/log/net_log_source.h" |
| 35 #include "net/log/net_log_source_type.h" | 36 #include "net/log/net_log_source_type.h" |
| 36 #include "net/log/net_log_with_source.h" | 37 #include "net/log/net_log_with_source.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // thread. The output parameters (error and result) must remain alive. | 183 // thread. The output parameters (error and result) must remain alive. |
| 183 void DoVerifyOnWorkerThread(const scoped_refptr<CertVerifyProc>& verify_proc, | 184 void DoVerifyOnWorkerThread(const scoped_refptr<CertVerifyProc>& verify_proc, |
| 184 const scoped_refptr<X509Certificate>& cert, | 185 const scoped_refptr<X509Certificate>& cert, |
| 185 const std::string& hostname, | 186 const std::string& hostname, |
| 186 const std::string& ocsp_response, | 187 const std::string& ocsp_response, |
| 187 int flags, | 188 int flags, |
| 188 const scoped_refptr<CRLSet>& crl_set, | 189 const scoped_refptr<CRLSet>& crl_set, |
| 189 const CertificateList& additional_trust_anchors, | 190 const CertificateList& additional_trust_anchors, |
| 190 int* error, | 191 int* error, |
| 191 CertVerifyResult* result) { | 192 CertVerifyResult* result) { |
| 192 TRACE_EVENT0("net", "DoVerifyOnWorkerThread"); | 193 TRACE_EVENT0(kNetTracingCategory, "DoVerifyOnWorkerThread"); |
| 193 *error = verify_proc->Verify(cert.get(), hostname, ocsp_response, flags, | 194 *error = verify_proc->Verify(cert.get(), hostname, ocsp_response, flags, |
| 194 crl_set.get(), additional_trust_anchors, result); | 195 crl_set.get(), additional_trust_anchors, result); |
| 195 | 196 |
| 196 #if defined(USE_NSS_CERTS) | 197 #if defined(USE_NSS_CERTS) |
| 197 // Detach the thread from NSPR. | 198 // Detach the thread from NSPR. |
| 198 // Calling NSS functions attaches the thread to NSPR, which stores | 199 // Calling NSS functions attaches the thread to NSPR, which stores |
| 199 // the NSPR thread ID in thread-specific data. | 200 // the NSPR thread ID in thread-specific data. |
| 200 // The threads in our thread pool terminate after we have called | 201 // The threads in our thread pool terminate after we have called |
| 201 // PR_Cleanup. Unless we detach them from NSPR, net_unittests gets | 202 // PR_Cleanup. Unless we detach them from NSPR, net_unittests gets |
| 202 // segfaults on shutdown when the threads' thread-specific data | 203 // segfaults on shutdown when the threads' thread-specific data |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 if (is_first_job_) { | 302 if (is_first_job_) { |
| 302 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertVerifier_First_Job_Latency", | 303 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertVerifier_First_Job_Latency", |
| 303 latency, | 304 latency, |
| 304 base::TimeDelta::FromMilliseconds(1), | 305 base::TimeDelta::FromMilliseconds(1), |
| 305 base::TimeDelta::FromMinutes(10), | 306 base::TimeDelta::FromMinutes(10), |
| 306 100); | 307 100); |
| 307 } | 308 } |
| 308 } | 309 } |
| 309 | 310 |
| 310 void OnJobCompleted(std::unique_ptr<ResultHelper> verify_result) { | 311 void OnJobCompleted(std::unique_ptr<ResultHelper> verify_result) { |
| 311 TRACE_EVENT0("net", "CertVerifierJob::OnJobCompleted"); | 312 TRACE_EVENT0(kNetTracingCategory, "CertVerifierJob::OnJobCompleted"); |
| 312 std::unique_ptr<CertVerifierJob> keep_alive = | 313 std::unique_ptr<CertVerifierJob> keep_alive = |
| 313 cert_verifier_->RemoveJob(this); | 314 cert_verifier_->RemoveJob(this); |
| 314 | 315 |
| 315 LogMetrics(*verify_result); | 316 LogMetrics(*verify_result); |
| 316 cert_verifier_ = nullptr; | 317 cert_verifier_ = nullptr; |
| 317 | 318 |
| 318 // TODO(eroman): If the cert_verifier_ is deleted from within one of the | 319 // TODO(eroman): If the cert_verifier_ is deleted from within one of the |
| 319 // callbacks, any remaining requests for that job should be cancelled. Right | 320 // callbacks, any remaining requests for that job should be cancelled. Right |
| 320 // now they will be called. | 321 // now they will be called. |
| 321 while (!requests_.empty()) { | 322 while (!requests_.empty()) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 // The JobSet is kept in sorted order so items can be found using binary | 426 // The JobSet is kept in sorted order so items can be found using binary |
| 426 // search. | 427 // search. |
| 427 auto it = std::lower_bound(inflight_.begin(), inflight_.end(), key, | 428 auto it = std::lower_bound(inflight_.begin(), inflight_.end(), key, |
| 428 JobToRequestParamsComparator()); | 429 JobToRequestParamsComparator()); |
| 429 if (it != inflight_.end() && !(key < it->first->key())) | 430 if (it != inflight_.end() && !(key < it->first->key())) |
| 430 return it->first; | 431 return it->first; |
| 431 return nullptr; | 432 return nullptr; |
| 432 } | 433 } |
| 433 | 434 |
| 434 } // namespace net | 435 } // namespace net |
| OLD | NEW |