Commit f044c1b9 authored by Ryan Hamilton's avatar Ryan Hamilton Committed by Commit Bot

Use a std::unique_ptr<ProofVerifyContext> instead of a raw pointer in the...

Use a std::unique_ptr<ProofVerifyContext> instead of a raw pointer in the QuicCryptoClientStream constructor.

Merge internal change: 203836768

Change-Id: I80e3cefd998af739fd4baa0a6df79034da407613
Reviewed-on: https://chromium-review.googlesource.com/1147492Reviewed-by: default avatarZhongyi Shi <zhongyi@chromium.org>
Commit-Queue: Ryan Hamilton <rch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577348}
parent 71c6fdf9
......@@ -109,9 +109,9 @@ std::unique_ptr<quic::ProofVerifier> ProofVerifierForTesting() {
std::make_unique<net::DefaultCTPolicyEnforcer>(), "quic-root.pem");
}
quic::ProofVerifyContext* ProofVerifyContextForTesting() {
return new net::ProofVerifyContextChromium(/*cert_verify_flags=*/0,
net::NetLogWithSource());
std::unique_ptr<quic::ProofVerifyContext> ProofVerifyContextForTesting() {
return std::make_unique<net::ProofVerifyContextChromium>(
/*cert_verify_flags=*/0, net::NetLogWithSource());
}
} // namespace crypto_test_utils
......
......@@ -21,7 +21,7 @@ class DefaultCryptoStreamFactory : public QuicCryptoClientStreamFactory {
std::unique_ptr<quic::ProofVerifyContext> proof_verify_context,
quic::QuicCryptoClientConfig* crypto_config) override {
return new quic::QuicCryptoClientStream(server_id, session,
proof_verify_context.release(),
std::move(proof_verify_context),
crypto_config, session);
}
};
......
......@@ -77,7 +77,7 @@ QuicCryptoClientHandshaker::QuicCryptoClientHandshaker(
const QuicServerId& server_id,
QuicCryptoClientStream* stream,
QuicSession* session,
ProofVerifyContext* verify_context,
std::unique_ptr<ProofVerifyContext> verify_context,
QuicCryptoClientConfig* crypto_config,
QuicCryptoClientStream::ProofHandler* proof_handler)
: QuicCryptoHandshaker(stream, session),
......@@ -91,7 +91,7 @@ QuicCryptoClientHandshaker::QuicCryptoClientHandshaker(
channel_id_sent_(false),
channel_id_source_callback_run_(false),
channel_id_source_callback_(nullptr),
verify_context_(verify_context),
verify_context_(std::move(verify_context)),
proof_verify_callback_(nullptr),
proof_handler_(proof_handler),
verify_ok_(false),
......
......@@ -29,7 +29,7 @@ class QUIC_EXPORT_PRIVATE QuicCryptoClientHandshaker
const QuicServerId& server_id,
QuicCryptoClientStream* stream,
QuicSession* session,
ProofVerifyContext* verify_context,
std::unique_ptr<ProofVerifyContext> verify_context,
QuicCryptoClientConfig* crypto_config,
QuicCryptoClientStream::ProofHandler* proof_handler);
......
......@@ -30,7 +30,7 @@ QuicCryptoClientStreamBase::QuicCryptoClientStreamBase(QuicSession* session)
QuicCryptoClientStream::QuicCryptoClientStream(
const QuicServerId& server_id,
QuicSession* session,
ProofVerifyContext* verify_context,
std::unique_ptr<ProofVerifyContext> verify_context,
QuicCryptoClientConfig* crypto_config,
ProofHandler* proof_handler)
: QuicCryptoClientStreamBase(session) {
......@@ -38,13 +38,13 @@ QuicCryptoClientStream::QuicCryptoClientStream(
switch (session->connection()->version().handshake_protocol) {
case PROTOCOL_QUIC_CRYPTO:
handshaker_ = QuicMakeUnique<QuicCryptoClientHandshaker>(
server_id, this, session, verify_context, crypto_config,
server_id, this, session, std::move(verify_context), crypto_config,
proof_handler);
break;
case PROTOCOL_TLS1_3:
handshaker_ = QuicMakeUnique<TlsClientHandshaker>(
this, session, server_id, crypto_config->proof_verifier(),
crypto_config->ssl_ctx(), verify_context,
crypto_config->ssl_ctx(), std::move(verify_context),
crypto_config->user_agent_id());
break;
case PROTOCOL_UNSUPPORTED:
......
......@@ -131,7 +131,7 @@ class QUIC_EXPORT_PRIVATE QuicCryptoClientStream
QuicCryptoClientStream(const QuicServerId& server_id,
QuicSession* session,
ProofVerifyContext* verify_context,
std::unique_ptr<ProofVerifyContext> verify_context,
QuicCryptoClientConfig* crypto_config,
ProofHandler* proof_handler);
......
......@@ -131,8 +131,8 @@ std::unique_ptr<QuicCryptoClientStreamBase>
QuicSpdyClientSession::CreateQuicCryptoStream() {
return QuicMakeUnique<QuicCryptoClientStream>(
server_id_, this,
crypto_config_->proof_verifier()->CreateDefaultContext().release(),
crypto_config_, this);
crypto_config_->proof_verifier()->CreateDefaultContext(), crypto_config_,
this);
}
bool QuicSpdyClientSession::IsAuthorized(const QuicString& authority) {
......
......@@ -37,17 +37,18 @@ void TlsClientHandshaker::ProofVerifierCallbackImpl::Cancel() {
parent_ = nullptr;
}
TlsClientHandshaker::TlsClientHandshaker(QuicCryptoStream* stream,
QuicSession* session,
const QuicServerId& server_id,
ProofVerifier* proof_verifier,
SSL_CTX* ssl_ctx,
ProofVerifyContext* verify_context,
const QuicString& user_agent_id)
TlsClientHandshaker::TlsClientHandshaker(
QuicCryptoStream* stream,
QuicSession* session,
const QuicServerId& server_id,
ProofVerifier* proof_verifier,
SSL_CTX* ssl_ctx,
std::unique_ptr<ProofVerifyContext> verify_context,
const QuicString& user_agent_id)
: TlsHandshaker(stream, session, ssl_ctx),
server_id_(server_id),
proof_verifier_(proof_verifier),
verify_context_(verify_context),
verify_context_(std::move(verify_context)),
user_agent_id_(user_agent_id),
crypto_negotiated_params_(new QuicCryptoNegotiatedParameters) {}
......
......@@ -27,8 +27,7 @@ class QUIC_EXPORT_PRIVATE TlsClientHandshaker
const QuicServerId& server_id,
ProofVerifier* proof_verifier,
SSL_CTX* ssl_ctx,
// Takes ownership of |verify_context|.
ProofVerifyContext* verify_context,
std::unique_ptr<ProofVerifyContext> verify_context,
const QuicString& user_agent_id);
~TlsClientHandshaker() override;
......
......@@ -294,9 +294,10 @@ void QuartcSession::StartCryptoHandshake() {
if (perspective_ == Perspective::IS_CLIENT) {
QuicServerId server_id(unique_remote_server_id_, kQuicServerPort,
/*privacy_mode_enabled=*/false);
QuicCryptoClientStream* crypto_stream =
new QuicCryptoClientStream(server_id, this, new ProofVerifyContext(),
quic_crypto_client_config_.get(), this);
QuicCryptoClientStream* crypto_stream = new QuicCryptoClientStream(
server_id, this,
quic_crypto_client_config_->proof_verifier()->CreateDefaultContext(),
quic_crypto_client_config_.get(), this);
crypto_stream_.reset(crypto_stream);
QuicSession::Initialize();
crypto_stream->CryptoConnect();
......
......@@ -189,7 +189,7 @@ uint64_t LeafCertHashForTesting();
// Returns a |ProofVerifyContext| that must be used with the verifier
// returned by |ProofVerifierForTesting|.
ProofVerifyContext* ProofVerifyContextForTesting();
std::unique_ptr<ProofVerifyContext> ProofVerifyContextForTesting();
// MockCommonCertSets returns a CommonCertSets that contains a single set with
// hash |hash|, consisting of the certificate |cert| at index |index|.
......
......@@ -22,7 +22,7 @@ namespace quic {
MockCryptoClientStream::MockCryptoClientStream(
const QuicServerId& server_id,
QuicSpdyClientSessionBase* session,
ProofVerifyContext* verify_context,
std::unique_ptr<ProofVerifyContext> verify_context,
const QuicConfig& config,
QuicCryptoClientConfig* crypto_config,
HandshakeMode handshake_mode,
......@@ -30,7 +30,7 @@ MockCryptoClientStream::MockCryptoClientStream(
bool use_mock_crypter)
: QuicCryptoClientStream(server_id,
session,
verify_context,
std::move(verify_context),
crypto_config,
session),
QuicCryptoHandshaker(this, session),
......
......@@ -48,7 +48,7 @@ class MockCryptoClientStream : public QuicCryptoClientStream,
MockCryptoClientStream(
const QuicServerId& server_id,
QuicSpdyClientSessionBase* session,
ProofVerifyContext* verify_context,
std::unique_ptr<ProofVerifyContext> verify_context,
const QuicConfig& config,
QuicCryptoClientConfig* crypto_config,
HandshakeMode handshake_mode,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment