OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/web/net/cert_verifier_block_adapter.h" | 5 #include "ios/web/net/cert_verifier_block_adapter.h" |
6 | 6 |
7 #include "base/mac/bind_objc_block.h" | 7 #include "base/mac/bind_objc_block.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "net/cert/crl_set.h" | 9 #include "net/cert/crl_set.h" |
10 #include "net/cert/x509_certificate.h" | 10 #include "net/cert/x509_certificate.h" |
11 #include "net/log/net_log.h" | 11 #include "net/log/net_log.h" |
12 | 12 |
13 namespace web { | 13 namespace web { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // Resource manager which keeps CertVerifyResult, X509Certificate, | 17 // Resource manager which keeps CertVerifyResult, X509Certificate, |
18 // CertVerifier::Request and BoundNetLog alive until verification is completed. | 18 // CertVerifier::Request and BoundNetLog alive until verification is completed. |
19 // This class is refcounted so it can be captured by a block, keeping its | 19 // This class is refcounted so it can be captured by a block, keeping its |
20 // members alive. | 20 // members alive. |
21 struct VerificationContext | 21 struct VerificationContext |
22 : public base::RefCountedThreadSafe<VerificationContext> { | 22 : public base::RefCountedThreadSafe<VerificationContext> { |
23 VerificationContext(scoped_refptr<net::X509Certificate> cert, | 23 VerificationContext(scoped_refptr<net::X509Certificate> cert, |
24 net::NetLog* net_log) | 24 net::NetLog* net_log) |
25 : request(nullptr), | 25 : request(nullptr), |
26 cert(cert.Pass()), | 26 cert(std::move(cert)), |
27 net_log(net::BoundNetLog::Make( | 27 net_log(net::BoundNetLog::Make( |
28 net_log, | 28 net_log, |
29 net::NetLog::SOURCE_IOS_WEB_VIEW_CERT_VERIFIER)) {} | 29 net::NetLog::SOURCE_IOS_WEB_VIEW_CERT_VERIFIER)) {} |
30 | 30 |
31 // Stores the current verification request. The request must outlive the | 31 // Stores the current verification request. The request must outlive the |
32 // VerificationContext and the CertVerifierBlockAdapter, so that the | 32 // VerificationContext and the CertVerifierBlockAdapter, so that the |
33 // verification request is not cancelled. CertVerifierBlockAdapter::Verify | 33 // verification request is not cancelled. CertVerifierBlockAdapter::Verify |
34 // guarantees its completion handler to be called, which will not happen if | 34 // guarantees its completion handler to be called, which will not happen if |
35 // verification request is cancelled. | 35 // verification request is cancelled. |
36 scoped_ptr<net::CertVerifier::Request> request; | 36 scoped_ptr<net::CertVerifier::Request> request; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // Completion handler will be called from |callback| when verification | 98 // Completion handler will be called from |callback| when verification |
99 // request is completed. | 99 // request is completed. |
100 return; | 100 return; |
101 } | 101 } |
102 | 102 |
103 // Verification has either failed or result was retrieved from the cache. | 103 // Verification has either failed or result was retrieved from the cache. |
104 completion_handler(context->result, error); | 104 completion_handler(context->result, error); |
105 } | 105 } |
106 | 106 |
107 } // namespace web | 107 } // namespace web |
OLD | NEW |