This source file includes following definitions.
- cur_request_
- Verify
- OnVerifyCompletion
#include "net/cert/single_request_cert_verifier.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "net/base/net_errors.h"
#include "net/cert/x509_certificate.h"
namespace net {
SingleRequestCertVerifier::SingleRequestCertVerifier(
CertVerifier* cert_verifier)
: cert_verifier_(cert_verifier),
cur_request_(NULL) {
DCHECK(cert_verifier_ != NULL);
}
SingleRequestCertVerifier::~SingleRequestCertVerifier() {
if (cur_request_) {
cert_verifier_->CancelRequest(cur_request_);
cur_request_ = NULL;
}
}
int SingleRequestCertVerifier::Verify(X509Certificate* cert,
const std::string& hostname,
int flags,
CRLSet* crl_set,
CertVerifyResult* verify_result,
const CompletionCallback& callback,
const BoundNetLog& net_log) {
DCHECK(!cur_request_ && cur_request_callback_.is_null());
CertVerifier::RequestHandle request = NULL;
int rv = cert_verifier_->Verify(
cert, hostname, flags, crl_set, verify_result,
base::Bind(&SingleRequestCertVerifier::OnVerifyCompletion,
base::Unretained(this)),
&request, net_log);
if (rv == ERR_IO_PENDING) {
cur_request_ = request;
cur_request_callback_ = callback;
}
return rv;
}
void SingleRequestCertVerifier::OnVerifyCompletion(int result) {
DCHECK(cur_request_ && !cur_request_callback_.is_null());
CompletionCallback callback = cur_request_callback_;
cur_request_ = NULL;
cur_request_callback_.Reset();
callback.Run(result);
}
}