OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 NET_CERT_MOCK_CERT_VERIFIER_H_ | 5 #ifndef NET_CERT_MOCK_CERT_VERIFIER_H_ |
6 #define NET_CERT_MOCK_CERT_VERIFIER_H_ | 6 #define NET_CERT_MOCK_CERT_VERIFIER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 21 matching lines...) Loading... |
32 const CompletionCallback& callback, | 32 const CompletionCallback& callback, |
33 std::unique_ptr<Request>* out_req, | 33 std::unique_ptr<Request>* out_req, |
34 const NetLogWithSource& net_log) override; | 34 const NetLogWithSource& net_log) override; |
35 | 35 |
36 // Sets the default return value for Verify() for certificates/hosts that do | 36 // Sets the default return value for Verify() for certificates/hosts that do |
37 // not have explicit results added via the AddResult*() methods. | 37 // not have explicit results added via the AddResult*() methods. |
38 void set_default_result(int default_result) { | 38 void set_default_result(int default_result) { |
39 default_result_ = default_result; | 39 default_result_ = default_result; |
40 } | 40 } |
41 | 41 |
| 42 // Controls invocation of the callback. If true, Verify() returns |
| 43 // ERR_IO_PENDING and the callback is invoked with the actual result. |
| 44 void set_async(bool async) { async_ = async; } |
| 45 |
42 // Adds a rule that will cause any call to Verify() for |cert| to return rv, | 46 // Adds a rule that will cause any call to Verify() for |cert| to return rv, |
43 // copying |verify_result| into the verified result. | 47 // copying |verify_result| into the verified result. |
44 // Note: Only the primary certificate of |cert| is checked. Any intermediate | 48 // Note: Only the primary certificate of |cert| is checked. Any intermediate |
45 // certificates will be ignored. | 49 // certificates will be ignored. |
46 void AddResultForCert(scoped_refptr<X509Certificate> cert, | 50 void AddResultForCert(scoped_refptr<X509Certificate> cert, |
47 const CertVerifyResult& verify_result, | 51 const CertVerifyResult& verify_result, |
48 int rv); | 52 int rv); |
49 | 53 |
50 // Same as AddResultForCert(), but further restricts it to only return for | 54 // Same as AddResultForCert(), but further restricts it to only return for |
51 // hostnames that match |host_pattern|. | 55 // hostnames that match |host_pattern|. |
52 void AddResultForCertAndHost(scoped_refptr<X509Certificate> cert, | 56 void AddResultForCertAndHost(scoped_refptr<X509Certificate> cert, |
53 const std::string& host_pattern, | 57 const std::string& host_pattern, |
54 const CertVerifyResult& verify_result, | 58 const CertVerifyResult& verify_result, |
55 int rv); | 59 int rv); |
56 | 60 |
57 private: | 61 private: |
58 struct Rule; | 62 struct Rule; |
59 typedef std::list<Rule> RuleList; | 63 typedef std::list<Rule> RuleList; |
60 | 64 |
61 int default_result_; | 65 int default_result_; |
| 66 bool async_; |
62 RuleList rules_; | 67 RuleList rules_; |
63 }; | 68 }; |
64 | 69 |
65 } // namespace net | 70 } // namespace net |
66 | 71 |
67 #endif // NET_CERT_MOCK_CERT_VERIFIER_H_ | 72 #endif // NET_CERT_MOCK_CERT_VERIFIER_H_ |
OLD | NEW |