| OLD | NEW |
| 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/quic_crypto_client_stream.h" | 5 #include "net/quic/quic_crypto_client_stream.h" |
| 6 | 6 |
| 7 #include "net/base/completion_callback.h" | 7 #include "net/base/completion_callback.h" |
| 8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
| 9 #include "net/quic/crypto/crypto_protocol.h" | 9 #include "net/quic/crypto/crypto_protocol.h" |
| 10 #include "net/quic/crypto/crypto_utils.h" | 10 #include "net/quic/crypto/crypto_utils.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // returns. | 60 // returns. |
| 61 } | 61 } |
| 62 | 62 |
| 63 void QuicCryptoClientStream::ProofVerifierCallbackImpl::Cancel() { | 63 void QuicCryptoClientStream::ProofVerifierCallbackImpl::Cancel() { |
| 64 stream_ = NULL; | 64 stream_ = NULL; |
| 65 } | 65 } |
| 66 | 66 |
| 67 | 67 |
| 68 QuicCryptoClientStream::QuicCryptoClientStream( | 68 QuicCryptoClientStream::QuicCryptoClientStream( |
| 69 const string& server_hostname, | 69 const string& server_hostname, |
| 70 uint16 server_port, |
| 70 QuicSession* session, | 71 QuicSession* session, |
| 71 QuicCryptoClientConfig* crypto_config) | 72 QuicCryptoClientConfig* crypto_config) |
| 72 : QuicCryptoStream(session), | 73 : QuicCryptoStream(session), |
| 73 next_state_(STATE_IDLE), | 74 next_state_(STATE_IDLE), |
| 74 num_client_hellos_(0), | 75 num_client_hellos_(0), |
| 75 crypto_config_(crypto_config), | 76 crypto_config_(crypto_config), |
| 76 server_hostname_(server_hostname), | 77 server_hostname_(server_hostname), |
| 78 server_port_(server_port), |
| 77 generation_counter_(0), | 79 generation_counter_(0), |
| 78 proof_verify_callback_(NULL), | 80 proof_verify_callback_(NULL), |
| 79 disk_cache_load_result_(ERR_UNEXPECTED), | 81 disk_cache_load_result_(ERR_UNEXPECTED), |
| 80 weak_factory_(this) { | 82 weak_factory_(this) { |
| 81 } | 83 } |
| 82 | 84 |
| 83 QuicCryptoClientStream::~QuicCryptoClientStream() { | 85 QuicCryptoClientStream::~QuicCryptoClientStream() { |
| 84 if (proof_verify_callback_) { | 86 if (proof_verify_callback_) { |
| 85 proof_verify_callback_->Cancel(); | 87 proof_verify_callback_->Cancel(); |
| 86 } | 88 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // * One failure due the server's certificate chain being unavailible and the | 147 // * One failure due the server's certificate chain being unavailible and the |
| 146 // server being unwilling to send it without a valid source-address token. | 148 // server being unwilling to send it without a valid source-address token. |
| 147 static const int kMaxClientHellos = 3; | 149 static const int kMaxClientHellos = 3; |
| 148 | 150 |
| 149 void QuicCryptoClientStream::DoHandshakeLoop( | 151 void QuicCryptoClientStream::DoHandshakeLoop( |
| 150 const CryptoHandshakeMessage* in) { | 152 const CryptoHandshakeMessage* in) { |
| 151 CryptoHandshakeMessage out; | 153 CryptoHandshakeMessage out; |
| 152 QuicErrorCode error; | 154 QuicErrorCode error; |
| 153 string error_details; | 155 string error_details; |
| 154 QuicCryptoClientConfig::CachedState* cached = | 156 QuicCryptoClientConfig::CachedState* cached = |
| 155 crypto_config_->LookupOrCreate(server_hostname_); | 157 crypto_config_->LookupOrCreate(server_hostname_, server_port_); |
| 156 | 158 |
| 157 if (in != NULL) { | 159 if (in != NULL) { |
| 158 DVLOG(1) << "Client: Received " << in->DebugString(); | 160 DVLOG(1) << "Client: Received " << in->DebugString(); |
| 159 } | 161 } |
| 160 | 162 |
| 161 for (;;) { | 163 for (;;) { |
| 162 const State state = next_state_; | 164 const State state = next_state_; |
| 163 next_state_ = STATE_IDLE; | 165 next_state_ = STATE_IDLE; |
| 164 switch (state) { | 166 switch (state) { |
| 165 case STATE_LOAD_QUIC_SERVER_INFO: { | 167 case STATE_LOAD_QUIC_SERVER_INFO: { |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 generation_counter_ = cached->generation_counter(); | 427 generation_counter_ = cached->generation_counter(); |
| 426 next_state_ = STATE_LOAD_QUIC_SERVER_INFO_COMPLETE; | 428 next_state_ = STATE_LOAD_QUIC_SERVER_INFO_COMPLETE; |
| 427 | 429 |
| 428 // TODO(rtenneti): If multiple tabs load the same URL, all requests except for | 430 // TODO(rtenneti): If multiple tabs load the same URL, all requests except for |
| 429 // the first request send InchoateClientHello. Fix the code to handle multiple | 431 // the first request send InchoateClientHello. Fix the code to handle multiple |
| 430 // requests. A possible solution is to wait for the first request to finish | 432 // requests. A possible solution is to wait for the first request to finish |
| 431 // and use the data from the disk cache for all requests. | 433 // and use the data from the disk cache for all requests. |
| 432 // We may need to call quic_server_info->Persist later. | 434 // We may need to call quic_server_info->Persist later. |
| 433 // quic_server_info->Persist requires quic_server_info to be ready, so we | 435 // quic_server_info->Persist requires quic_server_info to be ready, so we |
| 434 // always call WaitForDataReady, even though we might have initialized | 436 // always call WaitForDataReady, even though we might have initialized |
| 435 // |cached| config from the cached state for a canonical hostname. | 437 // |cached| config from the cached state for a canonical hostname and port. |
| 436 int rv = quic_server_info->WaitForDataReady( | 438 int rv = quic_server_info->WaitForDataReady( |
| 437 base::Bind(&QuicCryptoClientStream::OnIOComplete, | 439 base::Bind(&QuicCryptoClientStream::OnIOComplete, |
| 438 weak_factory_.GetWeakPtr())); | 440 weak_factory_.GetWeakPtr())); |
| 439 | 441 |
| 440 if (rv != ERR_IO_PENDING) { | 442 if (rv != ERR_IO_PENDING) { |
| 441 disk_cache_load_result_ = rv; | 443 disk_cache_load_result_ = rv; |
| 442 } | 444 } |
| 443 return rv; | 445 return rv; |
| 444 } | 446 } |
| 445 | 447 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 473 ProofVerifier* verifier = crypto_config_->proof_verifier(); | 475 ProofVerifier* verifier = crypto_config_->proof_verifier(); |
| 474 if (!verifier) { | 476 if (!verifier) { |
| 475 // If no verifier is set then we don't check the certificates. | 477 // If no verifier is set then we don't check the certificates. |
| 476 cached->SetProofValid(); | 478 cached->SetProofValid(); |
| 477 } else if (!cached->signature().empty()) { | 479 } else if (!cached->signature().empty()) { |
| 478 next_state_ = STATE_VERIFY_PROOF; | 480 next_state_ = STATE_VERIFY_PROOF; |
| 479 } | 481 } |
| 480 } | 482 } |
| 481 | 483 |
| 482 } // namespace net | 484 } // namespace net |
| OLD | NEW |