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

Unified Diff: net/cert/mock_cert_verifier.cc

Issue 1994353002: Update CertVerifier::Verify to use RequestParams instead (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@request_params
Patch Set: Rebased Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cert/mock_cert_verifier.h ('k') | net/cert/multi_threaded_cert_verifier.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/mock_cert_verifier.cc
diff --git a/net/cert/mock_cert_verifier.cc b/net/cert/mock_cert_verifier.cc
index 6d98cc36cd3836ad33ae52e06105b115bafa2c08..f184e55ebdf5212db31a65846a1d7c866bf68063 100644
--- a/net/cert/mock_cert_verifier.cc
+++ b/net/cert/mock_cert_verifier.cc
@@ -5,6 +5,7 @@
#include "net/cert/mock_cert_verifier.h"
#include <memory>
+#include <utility>
#include "base/memory/ref_counted.h"
#include "base/strings/pattern.h"
@@ -17,16 +18,16 @@
namespace net {
struct MockCertVerifier::Rule {
- Rule(X509Certificate* cert,
- const std::string& hostname,
- const CertVerifyResult& result,
- int rv)
- : cert(cert),
- hostname(hostname),
- result(result),
- rv(rv) {
+ Rule(scoped_refptr<X509Certificate> cert_arg,
+ const std::string& hostname_arg,
+ const CertVerifyResult& result_arg,
+ int rv_arg)
+ : cert(std::move(cert_arg)),
+ hostname(hostname_arg),
+ result(result_arg),
+ rv(rv_arg) {
DCHECK(cert);
- DCHECK(result.verified_cert.get());
+ DCHECK(result.verified_cert);
}
scoped_refptr<X509Certificate> cert;
@@ -39,10 +40,7 @@ MockCertVerifier::MockCertVerifier() : default_result_(ERR_CERT_INVALID) {}
MockCertVerifier::~MockCertVerifier() {}
-int MockCertVerifier::Verify(X509Certificate* cert,
- const std::string& hostname,
- const std::string& ocsp_response,
- int flags,
+int MockCertVerifier::Verify(const RequestParams& params,
CRLSet* crl_set,
CertVerifyResult* verify_result,
const CompletionCallback& callback,
@@ -51,33 +49,32 @@ int MockCertVerifier::Verify(X509Certificate* cert,
RuleList::const_iterator it;
for (it = rules_.begin(); it != rules_.end(); ++it) {
// Check just the server cert. Intermediates will be ignored.
- if (!it->cert->Equals(cert))
+ if (!it->cert->Equals(params.certificate().get()))
continue;
- if (!base::MatchPattern(hostname, it->hostname))
+ if (!base::MatchPattern(params.hostname(), it->hostname))
continue;
*verify_result = it->result;
return it->rv;
}
// Fall through to the default.
- verify_result->verified_cert = cert;
+ verify_result->verified_cert = params.certificate();
verify_result->cert_status = MapNetErrorToCertStatus(default_result_);
return default_result_;
}
-void MockCertVerifier::AddResultForCert(X509Certificate* cert,
+void MockCertVerifier::AddResultForCert(scoped_refptr<X509Certificate> cert,
const CertVerifyResult& verify_result,
int rv) {
- AddResultForCertAndHost(cert, "*", verify_result, rv);
+ AddResultForCertAndHost(std::move(cert), "*", verify_result, rv);
}
void MockCertVerifier::AddResultForCertAndHost(
- X509Certificate* cert,
+ scoped_refptr<X509Certificate> cert,
const std::string& host_pattern,
const CertVerifyResult& verify_result,
int rv) {
- Rule rule(cert, host_pattern, verify_result, rv);
- rules_.push_back(rule);
+ rules_.push_back(Rule(std::move(cert), host_pattern, verify_result, rv));
}
} // namespace net
« no previous file with comments | « net/cert/mock_cert_verifier.h ('k') | net/cert/multi_threaded_cert_verifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698