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

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, 7 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
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..9ecebf00c9fd076c10bfdf0e22694e983ab287a4 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,13 @@
namespace net {
struct MockCertVerifier::Rule {
- Rule(X509Certificate* cert,
+ Rule(scoped_refptr<X509Certificate> cert,
const std::string& hostname,
const CertVerifyResult& result,
int rv)
- : cert(cert),
- hostname(hostname),
- result(result),
- rv(rv) {
+ : cert(std::move(cert)), hostname(hostname), result(result), rv(rv) {
DCHECK(cert);
- DCHECK(result.verified_cert.get());
+ DCHECK(result.verified_cert);
}
scoped_refptr<X509Certificate> cert;
@@ -39,10 +37,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 CertVerifier::RequestParams& params,
CRLSet* crl_set,
CertVerifyResult* verify_result,
const CompletionCallback& callback,
@@ -51,33 +46,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

Powered by Google App Engine
This is Rietveld 408576698