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

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: Added a unittest; Updated comments; Created 5 years, 2 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 #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 guaranteed to be called.
Ryan Sleevi 2015/10/28 18:32:27 Should this be "completion handlers are guaranteed
Eugene But (OOO till 7-30) 2015/10/29 15:43:38 Done.
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 16 matching lines...) Expand all
61 // checks over the network. 61 // checks over the network.
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. |completion_handler| is guaranteed to be called even if
72 // object of this class is destroyed.
Ryan Sleevi 2015/10/28 18:32:27 nit: This does not read naturally ("if object of t
Eugene But (OOO till 7-30) 2015/10/29 15:43:38 Done.
72 void Verify(const Params& params, CompletionHandler completion_handler); 73 void Verify(const Params& params, CompletionHandler completion_handler);
73 74
74 private: 75 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. 76 // Underlying unowned CertVerifier.
79 net::CertVerifier* cert_verifier_; 77 net::CertVerifier* cert_verifier_;
80 // Unowned NetLog required by CertVerifier. 78 // Unowned NetLog required by CertVerifier.
81 net::NetLog* net_log_; 79 net::NetLog* net_log_;
82 // CertVerifierBlockAdapter should be used on the same thread where it was 80 // CertVerifierBlockAdapter should be used on the same thread where it was
83 // created. 81 // created.
84 base::ThreadChecker thread_checker_; 82 base::ThreadChecker thread_checker_;
85 }; 83 };
86 84
87 } // namespace web 85 } // namespace web
88 86
89 #endif // IOS_WEB_NET_CERT_VERIFIER_BLOCK_ADAPTER_H_ 87 #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') | ios/web/net/cert_verifier_block_adapter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698