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