| Index: net/quic/core/crypto/quic_crypto_server_config.cc
|
| diff --git a/net/quic/core/crypto/quic_crypto_server_config.cc b/net/quic/core/crypto/quic_crypto_server_config.cc
|
| index 111f10909ff8c02d37f444c33f07b7819169baa8..27adc5d73bc54bea2385376a7b8081d666c8e987 100644
|
| --- a/net/quic/core/crypto/quic_crypto_server_config.cc
|
| +++ b/net/quic/core/crypto/quic_crypto_server_config.cc
|
| @@ -81,8 +81,11 @@ IPAddress DualstackIPAddress(const IPAddress& ip) {
|
|
|
| class ValidateClientHelloHelper {
|
| public:
|
| - ValidateClientHelloHelper(ValidateClientHelloResultCallback::Result* result,
|
| - ValidateClientHelloResultCallback* done_cb)
|
| + // Note: stores a pointer to a unique_ptr, and std::moves the unique_ptr when
|
| + // ValidationComplete is called.
|
| + ValidateClientHelloHelper(
|
| + std::unique_ptr<ValidateClientHelloResultCallback::Result>* result,
|
| + ValidateClientHelloResultCallback* done_cb)
|
| : result_(result), done_cb_(done_cb) {}
|
|
|
| ~ValidateClientHelloHelper() {
|
| @@ -94,9 +97,9 @@ class ValidateClientHelloHelper {
|
| QuicErrorCode error_code,
|
| const char* error_details,
|
| std::unique_ptr<ProofSource::Details> proof_source_details) {
|
| - result_->error_code = error_code;
|
| - result_->error_details = error_details;
|
| - done_cb_->Run(result_, std::move(proof_source_details));
|
| + (*result_)->error_code = error_code;
|
| + (*result_)->error_details = error_details;
|
| + done_cb_->Run(std::move(*result_), std::move(proof_source_details));
|
| DetachCallback();
|
| }
|
|
|
| @@ -106,7 +109,7 @@ class ValidateClientHelloHelper {
|
| }
|
|
|
| private:
|
| - ValidateClientHelloResultCallback::Result* result_;
|
| + std::unique_ptr<ValidateClientHelloResultCallback::Result>* result_;
|
| ValidateClientHelloResultCallback* done_cb_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ValidateClientHelloHelper);
|
| @@ -116,10 +119,10 @@ class VerifyNonceIsValidAndUniqueCallback
|
| : public StrikeRegisterClient::ResultCallback {
|
| public:
|
| VerifyNonceIsValidAndUniqueCallback(
|
| - ValidateClientHelloResultCallback::Result* result,
|
| + std::unique_ptr<ValidateClientHelloResultCallback::Result> result,
|
| std::unique_ptr<ProofSource::Details> proof_source_details,
|
| ValidateClientHelloResultCallback* done_cb)
|
| - : result_(result),
|
| + : result_(std::move(result)),
|
| proof_source_details_(std::move(proof_source_details)),
|
| done_cb_(done_cb) {}
|
|
|
| @@ -160,11 +163,11 @@ class VerifyNonceIsValidAndUniqueCallback
|
| }
|
| result_->info.reject_reasons.push_back(client_nonce_error);
|
| }
|
| - done_cb_->Run(result_, std::move(proof_source_details_));
|
| + done_cb_->Run(std::move(result_), std::move(proof_source_details_));
|
| }
|
|
|
| private:
|
| - ValidateClientHelloResultCallback::Result* result_;
|
| + std::unique_ptr<ValidateClientHelloResultCallback::Result> result_;
|
| std::unique_ptr<ProofSource::Details> proof_source_details_;
|
| ValidateClientHelloResultCallback* done_cb_;
|
|
|
| @@ -199,10 +202,9 @@ ValidateClientHelloResultCallback::ValidateClientHelloResultCallback() {}
|
| ValidateClientHelloResultCallback::~ValidateClientHelloResultCallback() {}
|
|
|
| void ValidateClientHelloResultCallback::Run(
|
| - const Result* result,
|
| + std::unique_ptr<Result> result,
|
| std::unique_ptr<ProofSource::Details> details) {
|
| - RunImpl(result->client_hello, *result, std::move(details));
|
| - delete result;
|
| + RunImpl(std::move(result), std::move(details));
|
| delete this;
|
| }
|
|
|
| @@ -505,9 +507,9 @@ void QuicCryptoServerConfig::ValidateClientHello(
|
| ValidateClientHelloResultCallback* done_cb) const {
|
| const QuicWallTime now(clock->WallNow());
|
|
|
| - ValidateClientHelloResultCallback::Result* result =
|
| + std::unique_ptr<ValidateClientHelloResultCallback::Result> result(
|
| new ValidateClientHelloResultCallback::Result(client_hello, client_ip,
|
| - now);
|
| + now));
|
|
|
| StringPiece requested_scid;
|
| client_hello.GetStringPiece(kSCID, &requested_scid);
|
| @@ -546,9 +548,10 @@ void QuicCryptoServerConfig::ValidateClientHello(
|
| crypto_proof->cert_sct = "";
|
| }
|
| EvaluateClientHello(server_ip, version, primary_orbit, requested_config,
|
| - primary_config, crypto_proof, result, done_cb);
|
| + primary_config, crypto_proof, std::move(result),
|
| + done_cb);
|
| } else {
|
| - done_cb->Run(result, nullptr /* proof_source_details */);
|
| + done_cb->Run(std::move(result), /* details = */ nullptr);
|
| }
|
| }
|
|
|
| @@ -1002,7 +1005,8 @@ class EvaluateClientHelloCallback : public ProofSource::Callback {
|
| scoped_refptr<QuicCryptoServerConfig::Config> requested_config,
|
| scoped_refptr<QuicCryptoServerConfig::Config> primary_config,
|
| QuicCryptoProof* crypto_proof,
|
| - ValidateClientHelloResultCallback::Result* client_hello_state,
|
| + std::unique_ptr<ValidateClientHelloResultCallback::Result>
|
| + client_hello_state,
|
| ValidateClientHelloResultCallback* done_cb)
|
| : config_(config),
|
| found_error_(found_error),
|
| @@ -1012,7 +1016,7 @@ class EvaluateClientHelloCallback : public ProofSource::Callback {
|
| requested_config_(std::move(requested_config)),
|
| primary_config_(std::move(primary_config)),
|
| crypto_proof_(crypto_proof),
|
| - client_hello_state_(client_hello_state),
|
| + client_hello_state_(std::move(client_hello_state)),
|
| done_cb_(done_cb) {}
|
|
|
| void Run(bool ok,
|
| @@ -1028,7 +1032,7 @@ class EvaluateClientHelloCallback : public ProofSource::Callback {
|
| config_.EvaluateClientHelloAfterGetProof(
|
| found_error_, server_ip_, version_, primary_orbit_, requested_config_,
|
| primary_config_, crypto_proof_, std::move(details), !ok,
|
| - client_hello_state_, done_cb_);
|
| + std::move(client_hello_state_), done_cb_);
|
| }
|
|
|
| private:
|
| @@ -1040,7 +1044,8 @@ class EvaluateClientHelloCallback : public ProofSource::Callback {
|
| const scoped_refptr<QuicCryptoServerConfig::Config> requested_config_;
|
| const scoped_refptr<QuicCryptoServerConfig::Config> primary_config_;
|
| QuicCryptoProof* crypto_proof_;
|
| - ValidateClientHelloResultCallback::Result* client_hello_state_;
|
| + std::unique_ptr<ValidateClientHelloResultCallback::Result>
|
| + client_hello_state_;
|
| ValidateClientHelloResultCallback* done_cb_;
|
| };
|
|
|
| @@ -1051,9 +1056,10 @@ void QuicCryptoServerConfig::EvaluateClientHello(
|
| scoped_refptr<Config> requested_config,
|
| scoped_refptr<Config> primary_config,
|
| QuicCryptoProof* crypto_proof,
|
| - ValidateClientHelloResultCallback::Result* client_hello_state,
|
| + std::unique_ptr<ValidateClientHelloResultCallback::Result>
|
| + client_hello_state,
|
| ValidateClientHelloResultCallback* done_cb) const {
|
| - ValidateClientHelloHelper helper(client_hello_state, done_cb);
|
| + ValidateClientHelloHelper helper(&client_hello_state, done_cb);
|
|
|
| const CryptoHandshakeMessage& client_hello = client_hello_state->client_hello;
|
| ClientHelloInfo* info = &(client_hello_state->info);
|
| @@ -1131,7 +1137,7 @@ void QuicCryptoServerConfig::EvaluateClientHello(
|
| new EvaluateClientHelloCallback(
|
| *this, found_error, server_ip, version, primary_orbit,
|
| requested_config, primary_config, crypto_proof,
|
| - client_hello_state, done_cb));
|
| + std::move(client_hello_state), done_cb));
|
| proof_source_->GetProof(server_ip, info->sni.as_string(),
|
| serialized_config, version, chlo_hash,
|
| std::move(cb));
|
| @@ -1154,7 +1160,7 @@ void QuicCryptoServerConfig::EvaluateClientHello(
|
| EvaluateClientHelloAfterGetProof(
|
| found_error, server_ip, version, primary_orbit, requested_config,
|
| primary_config, crypto_proof, nullptr /* proof_source_details */,
|
| - get_proof_failed, client_hello_state, done_cb);
|
| + get_proof_failed, std::move(client_hello_state), done_cb);
|
| helper.DetachCallback();
|
| }
|
|
|
| @@ -1168,9 +1174,10 @@ void QuicCryptoServerConfig::EvaluateClientHelloAfterGetProof(
|
| QuicCryptoProof* crypto_proof,
|
| std::unique_ptr<ProofSource::Details> proof_source_details,
|
| bool get_proof_failed,
|
| - ValidateClientHelloResultCallback::Result* client_hello_state,
|
| + std::unique_ptr<ValidateClientHelloResultCallback::Result>
|
| + client_hello_state,
|
| ValidateClientHelloResultCallback* done_cb) const {
|
| - ValidateClientHelloHelper helper(client_hello_state, done_cb);
|
| + ValidateClientHelloHelper helper(&client_hello_state, done_cb);
|
| const CryptoHandshakeMessage& client_hello = client_hello_state->client_hello;
|
| ClientHelloInfo* info = &(client_hello_state->info);
|
|
|
| @@ -1266,8 +1273,9 @@ void QuicCryptoServerConfig::EvaluateClientHelloAfterGetProof(
|
|
|
| strike_register_client->VerifyNonceIsValidAndUnique(
|
| info->client_nonce, info->now,
|
| - new VerifyNonceIsValidAndUniqueCallback(
|
| - client_hello_state, std::move(proof_source_details), done_cb));
|
| + new VerifyNonceIsValidAndUniqueCallback(std::move(client_hello_state),
|
| + std::move(proof_source_details),
|
| + done_cb));
|
| helper.DetachCallback();
|
| }
|
|
|
|
|