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_session.h" | 5 #include "net/quic/quic_session.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "net/quic/crypto/proof_verifier.h" | 8 #include "net/quic/crypto/proof_verifier.h" |
9 #include "net/quic/quic_connection.h" | 9 #include "net/quic/quic_connection.h" |
10 #include "net/quic/quic_flags.h" | 10 #include "net/quic/quic_flags.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 96 } |
97 | 97 |
98 private: | 98 private: |
99 QuicSession* session_; | 99 QuicSession* session_; |
100 }; | 100 }; |
101 | 101 |
102 QuicSession::QuicSession(QuicConnection* connection, const QuicConfig& config) | 102 QuicSession::QuicSession(QuicConnection* connection, const QuicConfig& config) |
103 : connection_(connection), | 103 : connection_(connection), |
104 visitor_shim_(new VisitorShim(this)), | 104 visitor_shim_(new VisitorShim(this)), |
105 config_(config), | 105 config_(config), |
106 max_open_streams_(config_.max_streams_per_connection()), | 106 max_open_streams_(config_.MaxStreamsPerConnection()), |
107 next_stream_id_(is_server() ? 2 : 5), | 107 next_stream_id_(is_server() ? 2 : 5), |
108 largest_peer_created_stream_id_(0), | 108 largest_peer_created_stream_id_(0), |
109 error_(QUIC_NO_ERROR), | 109 error_(QUIC_NO_ERROR), |
110 goaway_received_(false), | 110 goaway_received_(false), |
111 goaway_sent_(false), | 111 goaway_sent_(false), |
112 has_pending_handshake_(false) { | 112 has_pending_handshake_(false) { |
113 if (connection_->version() <= QUIC_VERSION_19) { | 113 if (connection_->version() <= QUIC_VERSION_19) { |
114 flow_controller_.reset(new QuicFlowController( | 114 flow_controller_.reset(new QuicFlowController( |
115 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, | 115 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, |
116 config_.GetInitialFlowControlWindowToSend(), | 116 config_.GetInitialFlowControlWindowToSend(), |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 | 469 |
470 void QuicSession::OnConfigNegotiated() { | 470 void QuicSession::OnConfigNegotiated() { |
471 connection_->SetFromConfig(config_); | 471 connection_->SetFromConfig(config_); |
472 QuicVersion version = connection()->version(); | 472 QuicVersion version = connection()->version(); |
473 | 473 |
474 // A server should accept a small number of additional streams beyond the | 474 // A server should accept a small number of additional streams beyond the |
475 // limit sent to the client. This helps avoid early connection termination | 475 // limit sent to the client. This helps avoid early connection termination |
476 // when FIN/RSTs for old streams are lost or arrive out of order. | 476 // when FIN/RSTs for old streams are lost or arrive out of order. |
477 if (FLAGS_quic_allow_more_open_streams) { | 477 if (FLAGS_quic_allow_more_open_streams) { |
478 set_max_open_streams((is_server() ? kMaxStreamsMultiplier : 1.0) * | 478 set_max_open_streams((is_server() ? kMaxStreamsMultiplier : 1.0) * |
479 config_.max_streams_per_connection()); | 479 config_.MaxStreamsPerConnection()); |
480 } | 480 } |
481 | 481 |
482 if (version <= QUIC_VERSION_16) { | 482 if (version <= QUIC_VERSION_16) { |
483 return; | 483 return; |
484 } | 484 } |
485 | 485 |
486 if (version <= QUIC_VERSION_19) { | 486 if (version <= QUIC_VERSION_19) { |
487 // QUIC_VERSION_17,18,19 don't support independent stream/session flow | 487 // QUIC_VERSION_17,18,19 don't support independent stream/session flow |
488 // control windows. | 488 // control windows. |
489 if (config_.HasReceivedInitialFlowControlWindowBytes()) { | 489 if (config_.HasReceivedInitialFlowControlWindowBytes()) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 break; | 561 break; |
562 | 562 |
563 case HANDSHAKE_CONFIRMED: | 563 case HANDSHAKE_CONFIRMED: |
564 LOG_IF(DFATAL, !config_.negotiated()) << ENDPOINT | 564 LOG_IF(DFATAL, !config_.negotiated()) << ENDPOINT |
565 << "Handshake confirmed without parameter negotiation."; | 565 << "Handshake confirmed without parameter negotiation."; |
566 // Discard originally encrypted packets, since they can't be decrypted by | 566 // Discard originally encrypted packets, since they can't be decrypted by |
567 // the peer. | 567 // the peer. |
568 connection_->NeuterUnencryptedPackets(); | 568 connection_->NeuterUnencryptedPackets(); |
569 connection_->SetOverallConnectionTimeout(QuicTime::Delta::Infinite()); | 569 connection_->SetOverallConnectionTimeout(QuicTime::Delta::Infinite()); |
570 if (!FLAGS_quic_allow_more_open_streams) { | 570 if (!FLAGS_quic_allow_more_open_streams) { |
571 max_open_streams_ = config_.max_streams_per_connection(); | 571 max_open_streams_ = config_.MaxStreamsPerConnection(); |
572 } | 572 } |
573 break; | 573 break; |
574 | 574 |
575 default: | 575 default: |
576 LOG(ERROR) << ENDPOINT << "Got unknown handshake event: " << event; | 576 LOG(ERROR) << ENDPOINT << "Got unknown handshake event: " << event; |
577 } | 577 } |
578 } | 578 } |
579 | 579 |
580 void QuicSession::OnCryptoHandshakeMessageSent( | 580 void QuicSession::OnCryptoHandshakeMessageSent( |
581 const CryptoHandshakeMessage& message) { | 581 const CryptoHandshakeMessage& message) { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 } | 776 } |
777 for (DataStreamMap::iterator it = stream_map_.begin(); | 777 for (DataStreamMap::iterator it = stream_map_.begin(); |
778 it != stream_map_.end(); ++it) { | 778 it != stream_map_.end(); ++it) { |
779 if (version <= QUIC_VERSION_16) { | 779 if (version <= QUIC_VERSION_16) { |
780 it->second->flow_controller()->Disable(); | 780 it->second->flow_controller()->Disable(); |
781 } | 781 } |
782 } | 782 } |
783 } | 783 } |
784 | 784 |
785 } // namespace net | 785 } // namespace net |
OLD | NEW |