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

Side by Side Diff: net/quic/core/quic_crypto_server_stream.cc

Issue 2338013004: Simplify lifetime management of ValidateClientHelloResultCallback::Result objects (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « net/quic/core/quic_crypto_server_stream.h ('k') | net/quic/test_tools/crypto_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/core/quic_crypto_server_stream.h" 5 #include "net/quic/core/quic_crypto_server_stream.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "crypto/secure_hash.h" 10 #include "crypto/secure_hash.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 validate_client_hello_cb_ = new ValidateCallback(this); 118 validate_client_hello_cb_ = new ValidateCallback(this);
119 crypto_config_->ValidateClientHello( 119 crypto_config_->ValidateClientHello(
120 message, session()->connection()->peer_address().address(), 120 message, session()->connection()->peer_address().address(),
121 session()->connection()->self_address().address(), version(), 121 session()->connection()->self_address().address(), version(),
122 session()->connection()->clock(), &crypto_proof_, 122 session()->connection()->clock(), &crypto_proof_,
123 validate_client_hello_cb_); 123 validate_client_hello_cb_);
124 } 124 }
125 125
126 void QuicCryptoServerStream::FinishProcessingHandshakeMessage( 126 void QuicCryptoServerStream::FinishProcessingHandshakeMessage(
127 const CryptoHandshakeMessage& message,
128 const ValidateClientHelloResultCallback::Result& result, 127 const ValidateClientHelloResultCallback::Result& result,
129 std::unique_ptr<ProofSource::Details> details) { 128 std::unique_ptr<ProofSource::Details> details) {
129 const CryptoHandshakeMessage& message = result.client_hello;
130
130 // Clear the callback that got us here. 131 // Clear the callback that got us here.
131 DCHECK(validate_client_hello_cb_ != nullptr); 132 DCHECK(validate_client_hello_cb_ != nullptr);
132 validate_client_hello_cb_ = nullptr; 133 validate_client_hello_cb_ = nullptr;
133 134
134 if (use_stateless_rejects_if_peer_supported_) { 135 if (use_stateless_rejects_if_peer_supported_) {
135 peer_supports_stateless_rejects_ = DoesPeerSupportStatelessRejects(message); 136 peer_supports_stateless_rejects_ = DoesPeerSupportStatelessRejects(message);
136 } 137 }
137 138
138 CryptoHandshakeMessage reply; 139 CryptoHandshakeMessage reply;
139 DiversificationNonce diversification_nonce; 140 DiversificationNonce diversification_nonce;
140 string error_details; 141 string error_details;
141 QuicErrorCode error = 142 QuicErrorCode error =
142 ProcessClientHello(message, result, std::move(details), &reply, 143 ProcessClientHello(result, std::move(details), &reply,
143 &diversification_nonce, &error_details); 144 &diversification_nonce, &error_details);
144 145
145 if (error != QUIC_NO_ERROR) { 146 if (error != QUIC_NO_ERROR) {
146 CloseConnectionWithDetails(error, error_details); 147 CloseConnectionWithDetails(error, error_details);
147 return; 148 return;
148 } 149 }
149 150
150 if (reply.tag() != kSHLO) { 151 if (reply.tag() != kSHLO) {
151 if (reply.tag() == kSREJ) { 152 if (reply.tag() == kSREJ) {
152 DCHECK(use_stateless_rejects_if_peer_supported_); 153 DCHECK(use_stateless_rejects_if_peer_supported_);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 if ((*output)[len - 1] == '=') { 373 if ((*output)[len - 1] == '=') {
373 len--; 374 len--;
374 } 375 }
375 output->resize(len); 376 output->resize(len);
376 } 377 }
377 } 378 }
378 return true; 379 return true;
379 } 380 }
380 381
381 QuicErrorCode QuicCryptoServerStream::ProcessClientHello( 382 QuicErrorCode QuicCryptoServerStream::ProcessClientHello(
382 const CryptoHandshakeMessage& message,
383 const ValidateClientHelloResultCallback::Result& result, 383 const ValidateClientHelloResultCallback::Result& result,
384 std::unique_ptr<ProofSource::Details> proof_source_details, 384 std::unique_ptr<ProofSource::Details> proof_source_details,
385 CryptoHandshakeMessage* reply, 385 CryptoHandshakeMessage* reply,
386 DiversificationNonce* out_diversification_nonce, 386 DiversificationNonce* out_diversification_nonce,
387 string* error_details) { 387 string* error_details) {
388 const CryptoHandshakeMessage& message = result.client_hello;
388 if (!helper_->CanAcceptClientHello( 389 if (!helper_->CanAcceptClientHello(
389 message, session()->connection()->self_address(), error_details)) { 390 message, session()->connection()->self_address(), error_details)) {
390 return QUIC_HANDSHAKE_FAILED; 391 return QUIC_HANDSHAKE_FAILED;
391 } 392 }
392 393
393 if (!result.info.server_nonce.empty()) { 394 if (!result.info.server_nonce.empty()) {
394 ++num_handshake_messages_with_server_nonces_; 395 ++num_handshake_messages_with_server_nonces_;
395 } 396 }
396 // Store the bandwidth estimate from the client. 397 // Store the bandwidth estimate from the client.
397 if (result.cached_network_params.bandwidth_estimate_bytes_per_second() > 0) { 398 if (result.cached_network_params.bandwidth_estimate_bytes_per_second() > 0) {
(...skipping 23 matching lines...) Expand all
421 422
422 QuicCryptoServerStream::ValidateCallback::ValidateCallback( 423 QuicCryptoServerStream::ValidateCallback::ValidateCallback(
423 QuicCryptoServerStream* parent) 424 QuicCryptoServerStream* parent)
424 : parent_(parent) {} 425 : parent_(parent) {}
425 426
426 void QuicCryptoServerStream::ValidateCallback::Cancel() { 427 void QuicCryptoServerStream::ValidateCallback::Cancel() {
427 parent_ = nullptr; 428 parent_ = nullptr;
428 } 429 }
429 430
430 void QuicCryptoServerStream::ValidateCallback::RunImpl( 431 void QuicCryptoServerStream::ValidateCallback::RunImpl(
431 const CryptoHandshakeMessage& client_hello, 432 std::unique_ptr<Result> result,
432 const Result& result,
433 std::unique_ptr<ProofSource::Details> details) { 433 std::unique_ptr<ProofSource::Details> details) {
434 if (parent_ != nullptr) { 434 if (parent_ != nullptr) {
435 parent_->FinishProcessingHandshakeMessage(client_hello, result, 435 parent_->FinishProcessingHandshakeMessage(*result, std::move(details));
436 std::move(details));
437 } 436 }
438 } 437 }
439 438
440 QuicConnectionId QuicCryptoServerStream::GenerateConnectionIdForReject( 439 QuicConnectionId QuicCryptoServerStream::GenerateConnectionIdForReject(
441 bool use_stateless_rejects) { 440 bool use_stateless_rejects) {
442 if (!use_stateless_rejects) { 441 if (!use_stateless_rejects) {
443 return 0; 442 return 0;
444 } 443 }
445 return helper_->GenerateConnectionIdForReject( 444 return helper_->GenerateConnectionIdForReject(
446 session()->connection()->connection_id()); 445 session()->connection()->connection_id());
447 } 446 }
448 447
449 } // namespace net 448 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_crypto_server_stream.h ('k') | net/quic/test_tools/crypto_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698