roll skia to 4276
[chromium-blink-merge.git] / net / base / single_request_cert_verifier.h
blob6ae8bb6deb618644bc8f178b4439e7a0d24b6147
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
3 // found in the LICENSE file.
5 #ifndef NET_BASE_SINGLE_REQUEST_CERT_VERIFIER_H_
6 #define NET_BASE_SINGLE_REQUEST_CERT_VERIFIER_H_
7 #pragma once
9 #include "net/base/cert_verifier.h"
11 namespace net {
13 // This class represents the task of verifying a certificate. It wraps
14 // CertVerifier to verify only a single certificate at a time and cancels this
15 // request when going out of scope.
16 class SingleRequestCertVerifier {
17 public:
18 // |cert_verifier| must remain valid for the lifetime of |this|.
19 explicit SingleRequestCertVerifier(CertVerifier* cert_verifier);
21 // If a completion callback is pending when the verifier is destroyed, the
22 // certificate verification is canceled, and the completion callback will
23 // not be called.
24 ~SingleRequestCertVerifier();
26 // Verifies the given certificate, filling out the |verify_result| object
27 // upon success. See CertVerifier::Verify() for details.
28 int Verify(X509Certificate* cert,
29 const std::string& hostname,
30 int flags,
31 CRLSet* crl_set,
32 CertVerifyResult* verify_result,
33 const CompletionCallback& callback,
34 const BoundNetLog& net_log);
36 private:
37 // Callback for when the request to |cert_verifier_| completes, so we
38 // dispatch to the user's callback.
39 void OnVerifyCompletion(int result);
41 // The actual certificate verifier that will handle the request.
42 CertVerifier* const cert_verifier_;
44 // The current request (if any).
45 CertVerifier::RequestHandle cur_request_;
46 CompletionCallback cur_request_callback_;
48 DISALLOW_COPY_AND_ASSIGN(SingleRequestCertVerifier);
51 } // namespace net
53 #endif // NET_BASE_SINGLE_REQUEST_CERT_VERIFIER_H_