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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 } | 88 } |
89 | 89 |
90 bool HasOpenDataStreams() const override { | 90 bool HasOpenDataStreams() const override { |
91 return session_->HasOpenDataStreams(); | 91 return session_->HasOpenDataStreams(); |
92 } | 92 } |
93 | 93 |
94 private: | 94 private: |
95 QuicSession* session_; | 95 QuicSession* session_; |
96 }; | 96 }; |
97 | 97 |
98 QuicSession::QuicSession(QuicConnection* connection, const QuicConfig& config, | 98 QuicSession::QuicSession(QuicConnection* connection, const QuicConfig& config) |
99 bool is_secure) | |
100 : connection_(connection), | 99 : connection_(connection), |
101 visitor_shim_(new VisitorShim(this)), | 100 visitor_shim_(new VisitorShim(this)), |
102 config_(config), | 101 config_(config), |
103 max_open_streams_(config_.MaxStreamsPerConnection()), | 102 max_open_streams_(config_.MaxStreamsPerConnection()), |
104 next_stream_id_(is_server() ? 2 : 5), | 103 next_stream_id_(is_server() ? 2 : 5), |
105 largest_peer_created_stream_id_(0), | 104 largest_peer_created_stream_id_(0), |
106 error_(QUIC_NO_ERROR), | 105 error_(QUIC_NO_ERROR), |
107 goaway_received_(false), | 106 goaway_received_(false), |
108 goaway_sent_(false), | 107 goaway_sent_(false), |
109 has_pending_handshake_(false), | 108 has_pending_handshake_(false) { |
110 is_secure_(is_secure) { | |
111 if (connection_->version() == QUIC_VERSION_19) { | 109 if (connection_->version() == QUIC_VERSION_19) { |
112 flow_controller_.reset(new QuicFlowController( | 110 flow_controller_.reset(new QuicFlowController( |
113 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, | 111 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, |
114 config_.GetInitialFlowControlWindowToSend(), | 112 config_.GetInitialFlowControlWindowToSend(), |
115 config_.GetInitialFlowControlWindowToSend())); | 113 config_.GetInitialFlowControlWindowToSend())); |
116 } else { | 114 } else { |
117 flow_controller_.reset(new QuicFlowController( | 115 flow_controller_.reset(new QuicFlowController( |
118 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, | 116 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, |
119 config_.GetInitialSessionFlowControlWindowToSend(), | 117 config_.GetInitialSessionFlowControlWindowToSend(), |
120 config_.GetInitialSessionFlowControlWindowToSend())); | 118 config_.GetInitialSessionFlowControlWindowToSend())); |
121 } | 119 } |
122 } | 120 } |
123 | 121 |
124 void QuicSession::InitializeSession() { | 122 void QuicSession::InitializeSession() { |
125 connection_->set_visitor(visitor_shim_.get()); | 123 connection_->set_visitor(visitor_shim_.get()); |
126 connection_->SetFromConfig(config_); | 124 connection_->SetFromConfig(config_); |
127 if (!FLAGS_quic_unified_timeouts && connection_->connected()) { | |
128 connection_->SetOverallConnectionTimeout( | |
129 config_.max_time_before_crypto_handshake()); | |
130 } | |
131 headers_stream_.reset(new QuicHeadersStream(this)); | 125 headers_stream_.reset(new QuicHeadersStream(this)); |
132 } | 126 } |
133 | 127 |
134 QuicSession::~QuicSession() { | 128 QuicSession::~QuicSession() { |
135 STLDeleteElements(&closed_streams_); | 129 STLDeleteElements(&closed_streams_); |
136 STLDeleteValues(&stream_map_); | 130 STLDeleteValues(&stream_map_); |
137 | 131 |
138 DLOG_IF(WARNING, | 132 DLOG_IF(WARNING, |
139 locally_closed_streams_highest_offset_.size() > max_open_streams_) | 133 locally_closed_streams_highest_offset_.size() > max_open_streams_) |
140 << "Surprisingly high number of locally closed streams still waiting for " | 134 << "Surprisingly high number of locally closed streams still waiting for " |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 // decrypted by the peer. | 556 // decrypted by the peer. |
563 connection_->RetransmitUnackedPackets(ALL_INITIAL_RETRANSMISSION); | 557 connection_->RetransmitUnackedPackets(ALL_INITIAL_RETRANSMISSION); |
564 break; | 558 break; |
565 | 559 |
566 case HANDSHAKE_CONFIRMED: | 560 case HANDSHAKE_CONFIRMED: |
567 LOG_IF(DFATAL, !config_.negotiated()) << ENDPOINT | 561 LOG_IF(DFATAL, !config_.negotiated()) << ENDPOINT |
568 << "Handshake confirmed without parameter negotiation."; | 562 << "Handshake confirmed without parameter negotiation."; |
569 // Discard originally encrypted packets, since they can't be decrypted by | 563 // Discard originally encrypted packets, since they can't be decrypted by |
570 // the peer. | 564 // the peer. |
571 connection_->NeuterUnencryptedPackets(); | 565 connection_->NeuterUnencryptedPackets(); |
572 if (!FLAGS_quic_unified_timeouts) { | |
573 connection_->SetOverallConnectionTimeout(QuicTime::Delta::Infinite()); | |
574 } | |
575 if (!FLAGS_quic_allow_more_open_streams) { | 566 if (!FLAGS_quic_allow_more_open_streams) { |
576 max_open_streams_ = config_.MaxStreamsPerConnection(); | 567 max_open_streams_ = config_.MaxStreamsPerConnection(); |
577 } | 568 } |
578 break; | 569 break; |
579 | 570 |
580 default: | 571 default: |
581 LOG(ERROR) << ENDPOINT << "Got unknown handshake event: " << event; | 572 LOG(ERROR) << ENDPOINT << "Got unknown handshake event: " << event; |
582 } | 573 } |
583 } | 574 } |
584 | 575 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 for (DataStreamMap::iterator it = stream_map_.begin(); | 781 for (DataStreamMap::iterator it = stream_map_.begin(); |
791 it != stream_map_.end(); ++it) { | 782 it != stream_map_.end(); ++it) { |
792 if (it->second->flow_controller()->IsBlocked()) { | 783 if (it->second->flow_controller()->IsBlocked()) { |
793 return true; | 784 return true; |
794 } | 785 } |
795 } | 786 } |
796 return false; | 787 return false; |
797 } | 788 } |
798 | 789 |
799 } // namespace net | 790 } // namespace net |
OLD | NEW |