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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_.max_streams_per_connection()), |
107 next_stream_id_(is_server() ? 2 : 3), | 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(), |
117 config_.GetInitialFlowControlWindowToSend())); | 117 config_.GetInitialFlowControlWindowToSend())); |
118 } else { | 118 } else { |
119 flow_controller_.reset(new QuicFlowController( | 119 flow_controller_.reset(new QuicFlowController( |
120 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, | 120 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, |
121 config_.GetInitialSessionFlowControlWindowToSend(), | 121 config_.GetInitialSessionFlowControlWindowToSend(), |
122 config_.GetInitialSessionFlowControlWindowToSend())); | 122 config_.GetInitialSessionFlowControlWindowToSend())); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 void QuicSession::InitializeSession() { | 126 void QuicSession::InitializeSession() { |
127 connection_->set_visitor(visitor_shim_.get()); | 127 connection_->set_visitor(visitor_shim_.get()); |
128 connection_->SetFromConfig(config_); | 128 connection_->SetFromConfig(config_); |
129 if (connection_->connected()) { | 129 if (connection_->connected()) { |
130 connection_->SetOverallConnectionTimeout( | 130 connection_->SetOverallConnectionTimeout( |
131 config_.max_time_before_crypto_handshake()); | 131 config_.max_time_before_crypto_handshake()); |
132 } | 132 } |
133 headers_stream_.reset(new QuicHeadersStream(this)); | 133 headers_stream_.reset(new QuicHeadersStream(this)); |
134 if (!is_server()) { | |
135 // For version above QUIC v12, the headers stream is stream 3, so the | |
136 // next available local stream ID should be 5. | |
137 DCHECK_EQ(kHeadersStreamId, next_stream_id_); | |
138 next_stream_id_ += 2; | |
139 } | |
140 } | 134 } |
141 | 135 |
142 QuicSession::~QuicSession() { | 136 QuicSession::~QuicSession() { |
143 STLDeleteElements(&closed_streams_); | 137 STLDeleteElements(&closed_streams_); |
144 STLDeleteValues(&stream_map_); | 138 STLDeleteValues(&stream_map_); |
145 | 139 |
146 DLOG_IF(WARNING, | 140 DLOG_IF(WARNING, |
147 locally_closed_streams_highest_offset_.size() > max_open_streams_) | 141 locally_closed_streams_highest_offset_.size() > max_open_streams_) |
148 << "Surprisingly high number of locally closed streams still waiting for " | 142 << "Surprisingly high number of locally closed streams still waiting for " |
149 "final byte offset: " << locally_closed_streams_highest_offset_.size(); | 143 "final byte offset: " << locally_closed_streams_highest_offset_.size(); |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 } | 759 } |
766 for (DataStreamMap::iterator it = stream_map_.begin(); | 760 for (DataStreamMap::iterator it = stream_map_.begin(); |
767 it != stream_map_.end(); ++it) { | 761 it != stream_map_.end(); ++it) { |
768 if (version <= QUIC_VERSION_16) { | 762 if (version <= QUIC_VERSION_16) { |
769 it->second->flow_controller()->Disable(); | 763 it->second->flow_controller()->Disable(); |
770 } | 764 } |
771 } | 765 } |
772 } | 766 } |
773 | 767 |
774 } // namespace net | 768 } // namespace net |
OLD | NEW |