| 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/single_request_cert_verifier.h" | 5 #include "net/base/single_request_cert_verifier.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/base/x509_certificate.h" | 10 #include "net/base/x509_certificate.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 int SingleRequestCertVerifier::Verify(X509Certificate* cert, | 28 int SingleRequestCertVerifier::Verify(X509Certificate* cert, |
| 29 const std::string& hostname, | 29 const std::string& hostname, |
| 30 int flags, | 30 int flags, |
| 31 CRLSet* crl_set, | 31 CRLSet* crl_set, |
| 32 CertVerifyResult* verify_result, | 32 CertVerifyResult* verify_result, |
| 33 const CompletionCallback& callback, | 33 const CompletionCallback& callback, |
| 34 const BoundNetLog& net_log) { | 34 const BoundNetLog& net_log) { |
| 35 // Should not be already in use. | 35 // Should not be already in use. |
| 36 DCHECK(!cur_request_ && cur_request_callback_.is_null()); | 36 DCHECK(!cur_request_ && cur_request_callback_.is_null()); |
| 37 | 37 |
| 38 // Do a synchronous verification. | |
| 39 if (callback.is_null()) | |
| 40 return cert->Verify(hostname, flags, crl_set, verify_result); | |
| 41 | |
| 42 CertVerifier::RequestHandle request = NULL; | 38 CertVerifier::RequestHandle request = NULL; |
| 43 | 39 |
| 44 // We need to be notified of completion before |callback| is called, so that | 40 // We need to be notified of completion before |callback| is called, so that |
| 45 // we can clear out |cur_request_*|. | 41 // we can clear out |cur_request_*|. |
| 46 int rv = cert_verifier_->Verify( | 42 int rv = cert_verifier_->Verify( |
| 47 cert, hostname, flags, crl_set, verify_result, | 43 cert, hostname, flags, crl_set, verify_result, |
| 48 base::Bind(&SingleRequestCertVerifier::OnVerifyCompletion, | 44 base::Bind(&SingleRequestCertVerifier::OnVerifyCompletion, |
| 49 base::Unretained(this)), | 45 base::Unretained(this)), |
| 50 &request, net_log); | 46 &request, net_log); |
| 51 | 47 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 65 | 61 |
| 66 // Clear the outstanding request information. | 62 // Clear the outstanding request information. |
| 67 cur_request_ = NULL; | 63 cur_request_ = NULL; |
| 68 cur_request_callback_.Reset(); | 64 cur_request_callback_.Reset(); |
| 69 | 65 |
| 70 // Call the user's original callback. | 66 // Call the user's original callback. |
| 71 callback.Run(result); | 67 callback.Run(result); |
| 72 } | 68 } |
| 73 | 69 |
| 74 } // namespace net | 70 } // namespace net |
| OLD | NEW |