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

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

Issue 1392143003: Allways call didReceiveAuthenticationChallenge: completion handler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Ryan's review comments Created 5 years, 1 month 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
« no previous file with comments | « no previous file | ios/web/net/cert_verifier_block_adapter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef IOS_WEB_NET_CERT_VERIFIER_BLOCK_ADAPTER_H_ 5 #ifndef IOS_WEB_NET_CERT_VERIFIER_BLOCK_ADAPTER_H_
6 #define IOS_WEB_NET_CERT_VERIFIER_BLOCK_ADAPTER_H_ 6 #define IOS_WEB_NET_CERT_VERIFIER_BLOCK_ADAPTER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/threading/thread_checker.h" 10 #include "base/threading/thread_checker.h"
(...skipping 12 matching lines...) Expand all
23 // created and used on the same thread where the |net::CertVerifier| was 23 // created and used on the same thread where the |net::CertVerifier| was
24 // created. 24 // created.
25 class CertVerifierBlockAdapter { 25 class CertVerifierBlockAdapter {
26 public: 26 public:
27 // Constructs adapter with given |CertVerifier| and |NetLog|, both can not be 27 // Constructs adapter with given |CertVerifier| and |NetLog|, both can not be
28 // null. CertVerifierBlockAdapter does NOT take ownership of |cert_verifier| 28 // null. CertVerifierBlockAdapter does NOT take ownership of |cert_verifier|
29 // and |net_log|. 29 // and |net_log|.
30 CertVerifierBlockAdapter(net::CertVerifier* cert_verifier, 30 CertVerifierBlockAdapter(net::CertVerifier* cert_verifier,
31 net::NetLog* net_log); 31 net::NetLog* net_log);
32 32
33 // When the verifier is destroyed, all certificate verification requests are 33 // When the verifier is destroyed, certificate verification requests are not
34 // canceled, and their completion handlers will not be called. 34 // canceled, and their completion handlers are guaranteed to be called.
35 ~CertVerifierBlockAdapter(); 35 ~CertVerifierBlockAdapter();
36 36
37 // Encapsulates verification params. |cert| and |hostname| are mandatory, the 37 // Encapsulates verification params. |cert| and |hostname| are mandatory, the
38 // other params are optional. If either of mandatory arguments is null or 38 // other params are optional. If either of mandatory arguments is null or
39 // empty then verification |CompletionHandler| will be called with 39 // empty then verification |CompletionHandler| will be called with
40 // ERR_INVALID_ARGUMENT |error|. 40 // ERR_INVALID_ARGUMENT |error|.
41 struct Params { 41 struct Params {
42 // Constructs Params from X509 cert and hostname, which are mandatory for 42 // Constructs Params from X509 cert and hostname, which are mandatory for
43 // verification. 43 // verification.
44 Params(const scoped_refptr<net::X509Certificate>& cert, 44 Params(const scoped_refptr<net::X509Certificate>& cert,
(...skipping 17 matching lines...) Expand all
62 scoped_refptr<net::CRLSet> crl_set; 62 scoped_refptr<net::CRLSet> crl_set;
63 }; 63 };
64 64
65 // Type of verification completion block. If cert is successfully validated 65 // Type of verification completion block. If cert is successfully validated
66 // |error| is OK, otherwise |error| is a net error code. 66 // |error| is OK, otherwise |error| is a net error code.
67 typedef void (^CompletionHandler)(net::CertVerifyResult result, int error); 67 typedef void (^CompletionHandler)(net::CertVerifyResult result, int error);
68 68
69 // Verifies certificate with given |params|. |completion_handler| must not be 69 // Verifies certificate with given |params|. |completion_handler| must not be
70 // null and can be called either synchronously (in the same runloop) or 70 // null and can be called either synchronously (in the same runloop) or
71 // asynchronously. 71 // asynchronously.
72 // Note: |completion_handler| is guaranteed to be called, even if the instance
73 // |Verify()| was called on is destroyed.
72 void Verify(const Params& params, CompletionHandler completion_handler); 74 void Verify(const Params& params, CompletionHandler completion_handler);
73 75
74 private: 76 private:
75 // Pending verification requests. Request must be alive until verification is
76 // completed, otherwise verification operation will be cancelled.
77 ScopedVector<net::CertVerifier::Request> pending_requests_;
78 // Underlying unowned CertVerifier. 77 // Underlying unowned CertVerifier.
79 net::CertVerifier* cert_verifier_; 78 net::CertVerifier* cert_verifier_;
80 // Unowned NetLog required by CertVerifier. 79 // Unowned NetLog required by CertVerifier.
81 net::NetLog* net_log_; 80 net::NetLog* net_log_;
82 // CertVerifierBlockAdapter should be used on the same thread where it was 81 // CertVerifierBlockAdapter should be used on the same thread where it was
83 // created. 82 // created.
84 base::ThreadChecker thread_checker_; 83 base::ThreadChecker thread_checker_;
85 }; 84 };
86 85
87 } // namespace web 86 } // namespace web
88 87
89 #endif // IOS_WEB_NET_CERT_VERIFIER_BLOCK_ADAPTER_H_ 88 #endif // IOS_WEB_NET_CERT_VERIFIER_BLOCK_ADAPTER_H_
OLDNEW
« no previous file with comments | « no previous file | ios/web/net/cert_verifier_block_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698