Chromium Code Reviews| Index: net/cert/mock_cert_verifier.cc |
| diff --git a/net/cert/mock_cert_verifier.cc b/net/cert/mock_cert_verifier.cc |
| index 9cbbafd3cfe91e331348d3247d7457c055d28934..e8bdc915afd165ebcb93c6bd8b84a2f017fc0d10 100644 |
| --- a/net/cert/mock_cert_verifier.cc |
| +++ b/net/cert/mock_cert_verifier.cc |
| @@ -36,7 +36,8 @@ struct MockCertVerifier::Rule { |
| int rv; |
| }; |
| -MockCertVerifier::MockCertVerifier() : default_result_(ERR_CERT_INVALID) {} |
| +MockCertVerifier::MockCertVerifier() |
| + : default_result_(ERR_CERT_INVALID), async_(false) {} |
| MockCertVerifier::~MockCertVerifier() {} |
| @@ -46,6 +47,7 @@ int MockCertVerifier::Verify(const RequestParams& params, |
| const CompletionCallback& callback, |
| std::unique_ptr<Request>* out_req, |
| const NetLogWithSource& net_log) { |
| + int result; |
| RuleList::const_iterator it; |
| for (it = rules_.begin(); it != rules_.end(); ++it) { |
| // Check just the server cert. Intermediates will be ignored. |
| @@ -54,13 +56,20 @@ int MockCertVerifier::Verify(const RequestParams& params, |
| if (!base::MatchPattern(params.hostname(), it->hostname)) |
| continue; |
| *verify_result = it->result; |
| - return it->rv; |
| + result = it->rv; |
| + } |
| + if (it == rules_.end()) { |
| + // Fall through to the default. |
| + verify_result->verified_cert = params.certificate(); |
| + verify_result->cert_status = MapNetErrorToCertStatus(default_result_); |
| + result = default_result_; |
| } |
| - // Fall through to the default. |
| - verify_result->verified_cert = params.certificate(); |
| - verify_result->cert_status = MapNetErrorToCertStatus(default_result_); |
| - return default_result_; |
| + if (async_) { |
| + callback.Run(result); |
|
Ryan Sleevi
2017/04/12 21:53:17
BUG: This isn't consistent with how Chrome's async
martinkr
2017/04/24 23:54:26
Ah crap, I meant to look up how to properly do thi
Ryan Sleevi
2017/04/25 18:07:09
Yup! SG :)
|
| + return ERR_IO_PENDING; |
| + } |
| + return result; |
| } |
| void MockCertVerifier::AddResultForCert(scoped_refptr<X509Certificate> cert, |