Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: ios/web/net/cert_verifier_block_adapter.cc

Issue 1861593005: Convert //ios from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/mac/bind_objc_block.h" 9 #include "base/mac/bind_objc_block.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 17 matching lines...) Expand all
28 cert(std::move(cert)), 28 cert(std::move(cert)),
29 net_log(net::BoundNetLog::Make( 29 net_log(net::BoundNetLog::Make(
30 net_log, 30 net_log,
31 net::NetLog::SOURCE_IOS_WEB_VIEW_CERT_VERIFIER)) {} 31 net::NetLog::SOURCE_IOS_WEB_VIEW_CERT_VERIFIER)) {}
32 32
33 // Stores the current verification request. The request must outlive the 33 // Stores the current verification request. The request must outlive the
34 // VerificationContext and the CertVerifierBlockAdapter, so that the 34 // VerificationContext and the CertVerifierBlockAdapter, so that the
35 // verification request is not cancelled. CertVerifierBlockAdapter::Verify 35 // verification request is not cancelled. CertVerifierBlockAdapter::Verify
36 // guarantees its completion handler to be called, which will not happen if 36 // guarantees its completion handler to be called, which will not happen if
37 // verification request is cancelled. 37 // verification request is cancelled.
38 scoped_ptr<net::CertVerifier::Request> request; 38 std::unique_ptr<net::CertVerifier::Request> request;
39 // The result of certificate verification. 39 // The result of certificate verification.
40 net::CertVerifyResult result; 40 net::CertVerifyResult result;
41 // Certificate being verified. 41 // Certificate being verified.
42 scoped_refptr<net::X509Certificate> cert; 42 scoped_refptr<net::X509Certificate> cert;
43 // BoundNetLog required by CertVerifier. 43 // BoundNetLog required by CertVerifier.
44 net::BoundNetLog net_log; 44 net::BoundNetLog net_log;
45 45
46 private: 46 private:
47 friend class base::RefCountedThreadSafe<VerificationContext>; 47 friend class base::RefCountedThreadSafe<VerificationContext>;
48 VerificationContext() = delete; 48 VerificationContext() = delete;
(...skipping 28 matching lines...) Expand all
77 if (!params.cert || params.hostname.empty()) { 77 if (!params.cert || params.hostname.empty()) {
78 completion_handler(net::CertVerifyResult(), net::ERR_INVALID_ARGUMENT); 78 completion_handler(net::CertVerifyResult(), net::ERR_INVALID_ARGUMENT);
79 return; 79 return;
80 } 80 }
81 81
82 scoped_refptr<VerificationContext> context( 82 scoped_refptr<VerificationContext> context(
83 new VerificationContext(params.cert, net_log_)); 83 new VerificationContext(params.cert, net_log_));
84 net::CompletionCallback callback = base::BindBlock(^(int error) { 84 net::CompletionCallback callback = base::BindBlock(^(int error) {
85 completion_handler(context->result, error); 85 completion_handler(context->result, error);
86 }); 86 });
87 scoped_ptr<net::CertVerifier::Request> request; 87 std::unique_ptr<net::CertVerifier::Request> request;
88 int error = cert_verifier_->Verify(params.cert.get(), params.hostname, 88 int error = cert_verifier_->Verify(params.cert.get(), params.hostname,
89 params.ocsp_response, params.flags, 89 params.ocsp_response, params.flags,
90 params.crl_set.get(), &(context->result), 90 params.crl_set.get(), &(context->result),
91 callback, &request, context->net_log); 91 callback, &request, context->net_log);
92 if (error == net::ERR_IO_PENDING) { 92 if (error == net::ERR_IO_PENDING) {
93 // Keep the |net::CertVerifier::Request| alive until verification completes. 93 // Keep the |net::CertVerifier::Request| alive until verification completes.
94 // Because |context| is kept alive by |callback| (through base::BindBlock), 94 // Because |context| is kept alive by |callback| (through base::BindBlock),
95 // this means that the cert verification request cannot be cancelled. 95 // this means that the cert verification request cannot be cancelled.
96 // However, it guarantees that |callback| - and thus |completion_handler| - 96 // However, it guarantees that |callback| - and thus |completion_handler| -
97 // will always be called, which is a necessary part of the API contract of 97 // will always be called, which is a necessary part of the API contract of
98 // |CertVerifierBlockAdapter::Verify()|. 98 // |CertVerifierBlockAdapter::Verify()|.
99 context->request = std::move(request); 99 context->request = std::move(request);
100 // Completion handler will be called from |callback| when verification 100 // Completion handler will be called from |callback| when verification
101 // request is completed. 101 // request is completed.
102 return; 102 return;
103 } 103 }
104 104
105 // Verification has either failed or result was retrieved from the cache. 105 // Verification has either failed or result was retrieved from the cache.
106 completion_handler(context->result, error); 106 completion_handler(context->result, error);
107 } 107 }
108 108
109 } // namespace web 109 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/net/cert_verifier_block_adapter.h ('k') | ios/web/net/cert_verifier_block_adapter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698