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 "base/profiler/scoped_tracker.h" | 8 #include "base/profiler/scoped_tracker.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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 : QuicCryptoStream(session), | 80 : QuicCryptoStream(session), |
81 next_state_(STATE_IDLE), | 81 next_state_(STATE_IDLE), |
82 num_client_hellos_(0), | 82 num_client_hellos_(0), |
83 crypto_config_(crypto_config), | 83 crypto_config_(crypto_config), |
84 server_id_(server_id), | 84 server_id_(server_id), |
85 generation_counter_(0), | 85 generation_counter_(0), |
86 channel_id_sent_(false), | 86 channel_id_sent_(false), |
87 channel_id_source_callback_run_(false), | 87 channel_id_source_callback_run_(false), |
88 channel_id_source_callback_(nullptr), | 88 channel_id_source_callback_(nullptr), |
89 verify_context_(verify_context), | 89 verify_context_(verify_context), |
90 proof_verify_callback_(nullptr) {} | 90 proof_verify_callback_(nullptr) { |
| 91 DCHECK(!session->connection()->is_server()); |
| 92 } |
91 | 93 |
92 QuicCryptoClientStream::~QuicCryptoClientStream() { | 94 QuicCryptoClientStream::~QuicCryptoClientStream() { |
93 if (channel_id_source_callback_) { | 95 if (channel_id_source_callback_) { |
94 channel_id_source_callback_->Cancel(); | 96 channel_id_source_callback_->Cancel(); |
95 } | 97 } |
96 if (proof_verify_callback_) { | 98 if (proof_verify_callback_) { |
97 proof_verify_callback_->Cancel(); | 99 proof_verify_callback_->Cancel(); |
98 } | 100 } |
99 } | 101 } |
100 | 102 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 CHECK_NE(STATE_NONE, next_state_); | 191 CHECK_NE(STATE_NONE, next_state_); |
190 const State state = next_state_; | 192 const State state = next_state_; |
191 next_state_ = STATE_IDLE; | 193 next_state_ = STATE_IDLE; |
192 rv = QUIC_SUCCESS; | 194 rv = QUIC_SUCCESS; |
193 switch (state) { | 195 switch (state) { |
194 case STATE_INITIALIZE: | 196 case STATE_INITIALIZE: |
195 DoInitialize(cached); | 197 DoInitialize(cached); |
196 break; | 198 break; |
197 case STATE_SEND_CHLO: | 199 case STATE_SEND_CHLO: |
198 DoSendCHLO(in, cached); | 200 DoSendCHLO(in, cached); |
199 return; | 201 return; // return waiting to hear from server. |
200 case STATE_RECV_REJ: | 202 case STATE_RECV_REJ: |
201 DoReceiveREJ(in, cached); | 203 DoReceiveREJ(in, cached); |
202 break; | 204 break; |
203 case STATE_VERIFY_PROOF: | 205 case STATE_VERIFY_PROOF: |
204 rv = DoVerifyProof(cached); | 206 rv = DoVerifyProof(cached); |
205 break; | 207 break; |
206 case STATE_VERIFY_PROOF_COMPLETE: | 208 case STATE_VERIFY_PROOF_COMPLETE: |
207 DoVerifyProofComplete(cached); | 209 DoVerifyProofComplete(cached); |
208 break; | 210 break; |
209 case STATE_GET_CHANNEL_ID: | 211 case STATE_GET_CHANNEL_ID: |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 } | 633 } |
632 | 634 |
633 bool QuicCryptoClientStream::RequiresChannelID( | 635 bool QuicCryptoClientStream::RequiresChannelID( |
634 QuicCryptoClientConfig::CachedState* cached) { | 636 QuicCryptoClientConfig::CachedState* cached) { |
635 if (!server_id_.is_https() || | 637 if (!server_id_.is_https() || |
636 server_id_.privacy_mode() == PRIVACY_MODE_ENABLED || | 638 server_id_.privacy_mode() == PRIVACY_MODE_ENABLED || |
637 !crypto_config_->channel_id_source()) { | 639 !crypto_config_->channel_id_source()) { |
638 return false; | 640 return false; |
639 } | 641 } |
640 const CryptoHandshakeMessage* scfg = cached->GetServerConfig(); | 642 const CryptoHandshakeMessage* scfg = cached->GetServerConfig(); |
641 if (!scfg) { // scfg may be null when we send an inchoate CHLO. | 643 if (!scfg) { // scfg may be null then we send an inchoate CHLO. |
642 return false; | 644 return false; |
643 } | 645 } |
644 const QuicTag* their_proof_demands; | 646 const QuicTag* their_proof_demands; |
645 size_t num_their_proof_demands; | 647 size_t num_their_proof_demands; |
646 if (scfg->GetTaglist(kPDMD, &their_proof_demands, | 648 if (scfg->GetTaglist(kPDMD, &their_proof_demands, |
647 &num_their_proof_demands) != QUIC_NO_ERROR) { | 649 &num_their_proof_demands) != QUIC_NO_ERROR) { |
648 return false; | 650 return false; |
649 } | 651 } |
650 for (size_t i = 0; i < num_their_proof_demands; i++) { | 652 for (size_t i = 0; i < num_their_proof_demands; i++) { |
651 if (their_proof_demands[i] == kCHID) { | 653 if (their_proof_demands[i] == kCHID) { |
652 return true; | 654 return true; |
653 } | 655 } |
654 } | 656 } |
655 return false; | 657 return false; |
656 } | 658 } |
657 | 659 |
658 QuicClientSessionBase* QuicCryptoClientStream::client_session() { | 660 QuicClientSessionBase* QuicCryptoClientStream::client_session() { |
659 return reinterpret_cast<QuicClientSessionBase*>(session()); | 661 return reinterpret_cast<QuicClientSessionBase*>(session()); |
660 } | 662 } |
661 | 663 |
662 } // namespace net | 664 } // namespace net |
OLD | NEW |