Chromium Code Reviews| 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" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 flags_(flags), | 145 flags_(flags), |
| 146 crl_set_(crl_set), | 146 crl_set_(crl_set), |
| 147 origin_loop_(MessageLoop::current()), | 147 origin_loop_(MessageLoop::current()), |
| 148 cert_verifier_(cert_verifier), | 148 cert_verifier_(cert_verifier), |
| 149 canceled_(false), | 149 canceled_(false), |
| 150 error_(ERR_FAILED) { | 150 error_(ERR_FAILED) { |
| 151 } | 151 } |
| 152 | 152 |
| 153 // Returns the certificate being verified. May only be called /before/ | 153 // Returns the certificate being verified. May only be called /before/ |
| 154 // Start() is called. | 154 // Start() is called. |
| 155 X509Certificate* certificate() const { return cert_; } | 155 scoped_refptr<const X509Certificate> certificate() const { return cert_; } |
| 156 | 156 |
| 157 bool Start() { | 157 bool Start() { |
| 158 DCHECK_EQ(MessageLoop::current(), origin_loop_); | 158 DCHECK_EQ(MessageLoop::current(), origin_loop_); |
| 159 | 159 |
| 160 return base::WorkerPool::PostTask( | 160 return base::WorkerPool::PostTask( |
| 161 FROM_HERE, base::Bind(&CertVerifierWorker::Run, base::Unretained(this)), | 161 FROM_HERE, base::Bind(&CertVerifierWorker::Run, base::Unretained(this)), |
| 162 true /* task is slow */); | 162 true /* task is slow */); |
| 163 } | 163 } |
| 164 | 164 |
| 165 // Cancel is called from the origin loop when the MultiThreadedCertVerifier is | 165 // Cancel is called from the origin loop when the MultiThreadedCertVerifier is |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 // lives only on the CertVerifier's origin message loop. | 258 // lives only on the CertVerifier's origin message loop. |
| 259 class CertVerifierJob { | 259 class CertVerifierJob { |
| 260 public: | 260 public: |
| 261 CertVerifierJob(CertVerifierWorker* worker, | 261 CertVerifierJob(CertVerifierWorker* worker, |
| 262 const BoundNetLog& net_log) | 262 const BoundNetLog& net_log) |
| 263 : start_time_(base::TimeTicks::Now()), | 263 : start_time_(base::TimeTicks::Now()), |
| 264 worker_(worker), | 264 worker_(worker), |
| 265 net_log_(net_log) { | 265 net_log_(net_log) { |
| 266 net_log_.BeginEvent( | 266 net_log_.BeginEvent( |
| 267 NetLog::TYPE_CERT_VERIFIER_JOB, | 267 NetLog::TYPE_CERT_VERIFIER_JOB, |
| 268 base::Bind(&NetLogX509CertificateCallback, | 268 CreateNetLogX509CertificateCallback(worker_->certificate())); |
| 269 base::Unretained(worker_->certificate()))); | |
|
Ryan Sleevi
2012/06/12 20:22:09
This was safe as-is. Start() has not yet been call
| |
| 270 } | 269 } |
| 271 | 270 |
| 272 ~CertVerifierJob() { | 271 ~CertVerifierJob() { |
| 273 if (worker_) { | 272 if (worker_) { |
| 274 net_log_.AddEvent(NetLog::TYPE_CANCELLED, NULL); | 273 net_log_.AddEvent(NetLog::TYPE_CANCELLED, NULL); |
| 275 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_JOB, NULL); | 274 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_JOB, NULL); |
| 276 worker_->Cancel(); | 275 worker_->Cancel(); |
| 277 DeleteAllCanceled(); | 276 DeleteAllCanceled(); |
| 278 } | 277 } |
| 279 } | 278 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 DCHECK(CalledOnValidThread()); | 447 DCHECK(CalledOnValidThread()); |
| 449 | 448 |
| 450 ClearCache(); | 449 ClearCache(); |
| 451 } | 450 } |
| 452 | 451 |
| 453 void MultiThreadedCertVerifier::SetCertVerifyProc(CertVerifyProc* verify_proc) { | 452 void MultiThreadedCertVerifier::SetCertVerifyProc(CertVerifyProc* verify_proc) { |
| 454 verify_proc_ = verify_proc; | 453 verify_proc_ = verify_proc; |
| 455 } | 454 } |
| 456 | 455 |
| 457 } // namespace net | 456 } // namespace net |
| OLD | NEW |