| 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/quic_connection.h" | 8 #include "net/quic/quic_connection.h" |
| 9 | 9 |
| 10 using base::StringPiece; | 10 using base::StringPiece; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 bool is_server) | 69 bool is_server) |
| 70 : connection_(connection), | 70 : connection_(connection), |
| 71 visitor_shim_(new VisitorShim(this)), | 71 visitor_shim_(new VisitorShim(this)), |
| 72 config_(config), | 72 config_(config), |
| 73 max_open_streams_(kDefaultMaxStreamsPerConnection), | 73 max_open_streams_(kDefaultMaxStreamsPerConnection), |
| 74 next_stream_id_(is_server ? 2 : 3), | 74 next_stream_id_(is_server ? 2 : 3), |
| 75 is_server_(is_server), | 75 is_server_(is_server), |
| 76 largest_peer_created_stream_id_(0), | 76 largest_peer_created_stream_id_(0), |
| 77 goaway_received_(false), | 77 goaway_received_(false), |
| 78 goaway_sent_(false) { | 78 goaway_sent_(false) { |
| 79 connection->set_visitor(visitor_shim_.get()); | 79 set_max_open_streams(config_.max_streams_per_connection()); |
| 80 |
| 81 connection_->set_visitor(visitor_shim_.get()); |
| 82 connection_->SetIdleNetworkTimeout(config_.idle_connection_state_lifetime()); |
| 83 connection_->SetOverallConnectionTimeout( |
| 84 config_.max_time_before_crypto_handshake()); |
| 85 // TODO(satyamshekhar): Set congestion control and ICSL also. |
| 80 } | 86 } |
| 81 | 87 |
| 82 QuicSession::~QuicSession() { | 88 QuicSession::~QuicSession() { |
| 83 STLDeleteElements(&closed_streams_); | 89 STLDeleteElements(&closed_streams_); |
| 84 STLDeleteValues(&stream_map_); | 90 STLDeleteValues(&stream_map_); |
| 85 } | 91 } |
| 86 | 92 |
| 87 bool QuicSession::OnPacket(const IPEndPoint& self_address, | 93 bool QuicSession::OnPacket(const IPEndPoint& self_address, |
| 88 const IPEndPoint& peer_address, | 94 const IPEndPoint& peer_address, |
| 89 const QuicPacketHeader& header, | 95 const QuicPacketHeader& header, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 107 | 113 |
| 108 for (size_t i = 0; i < frames.size(); ++i) { | 114 for (size_t i = 0; i < frames.size(); ++i) { |
| 109 ReliableQuicStream* stream = GetStream(frames[i].stream_id); | 115 ReliableQuicStream* stream = GetStream(frames[i].stream_id); |
| 110 if (stream) { | 116 if (stream) { |
| 111 stream->OnStreamFrame(frames[i]); | 117 stream->OnStreamFrame(frames[i]); |
| 112 } | 118 } |
| 113 } | 119 } |
| 114 | 120 |
| 115 while (!decompression_blocked_streams_.empty()) { | 121 while (!decompression_blocked_streams_.empty()) { |
| 116 QuicHeaderId header_id = decompression_blocked_streams_.begin()->first; | 122 QuicHeaderId header_id = decompression_blocked_streams_.begin()->first; |
| 117 if (header_id == decompressor_.current_header_id()) { | 123 if (header_id != decompressor_.current_header_id()) { |
| 118 QuicStreamId stream_id = decompression_blocked_streams_.begin()->second; | 124 break; |
| 119 decompression_blocked_streams_.erase(header_id); | |
| 120 ReliableQuicStream* stream = GetStream(stream_id); | |
| 121 if (!stream) { | |
| 122 connection()->SendConnectionClose( | |
| 123 QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED); | |
| 124 } | |
| 125 stream->OnDecompressorAvailable(); | |
| 126 } | 125 } |
| 126 QuicStreamId stream_id = decompression_blocked_streams_.begin()->second; |
| 127 decompression_blocked_streams_.erase(header_id); |
| 128 ReliableQuicStream* stream = GetStream(stream_id); |
| 129 if (!stream) { |
| 130 connection()->SendConnectionClose( |
| 131 QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED); |
| 132 } |
| 133 stream->OnDecompressorAvailable(); |
| 127 } | 134 } |
| 128 return true; | 135 return true; |
| 129 } | 136 } |
| 130 | 137 |
| 131 void QuicSession::OnRstStream(const QuicRstStreamFrame& frame) { | 138 void QuicSession::OnRstStream(const QuicRstStreamFrame& frame) { |
| 132 ReliableQuicStream* stream = GetStream(frame.stream_id); | 139 ReliableQuicStream* stream = GetStream(frame.stream_id); |
| 133 if (!stream) { | 140 if (!stream) { |
| 134 return; // Errors are handled by GetStream. | 141 return; // Errors are handled by GetStream. |
| 135 } | 142 } |
| 136 stream->OnStreamReset(frame.error_code); | 143 stream->OnStreamReset(frame.error_code); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 case ENCRYPTION_REESTABLISHED: | 232 case ENCRYPTION_REESTABLISHED: |
| 226 // Retransmit originally packets that were sent, since they can't be | 233 // Retransmit originally packets that were sent, since they can't be |
| 227 // decrypted by the peer. | 234 // decrypted by the peer. |
| 228 connection_->RetransmitUnackedPackets( | 235 connection_->RetransmitUnackedPackets( |
| 229 QuicConnection::INITIAL_ENCRYPTION_ONLY); | 236 QuicConnection::INITIAL_ENCRYPTION_ONLY); |
| 230 break; | 237 break; |
| 231 | 238 |
| 232 case HANDSHAKE_CONFIRMED: | 239 case HANDSHAKE_CONFIRMED: |
| 233 LOG_IF(DFATAL, !config_.negotiated()) | 240 LOG_IF(DFATAL, !config_.negotiated()) |
| 234 << "Handshake confirmed without parameter negotiation."; | 241 << "Handshake confirmed without parameter negotiation."; |
| 235 connection_->SetConnectionTimeout( | 242 connection_->SetIdleNetworkTimeout( |
| 236 config_.idle_connection_state_lifetime()); | 243 config_.idle_connection_state_lifetime()); |
| 244 connection_->SetOverallConnectionTimeout(QuicTime::Delta::Infinite()); |
| 237 max_open_streams_ = config_.max_streams_per_connection(); | 245 max_open_streams_ = config_.max_streams_per_connection(); |
| 238 break; | 246 break; |
| 239 | 247 |
| 240 default: | 248 default: |
| 241 LOG(ERROR) << "Got unknown handshake event: " << event; | 249 LOG(ERROR) << "Got unknown handshake event: " << event; |
| 242 } | 250 } |
| 243 } | 251 } |
| 244 | 252 |
| 245 QuicConfig* QuicSession::config() { | 253 QuicConfig* QuicSession::config() { |
| 246 return &config_; | 254 return &config_; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 QuicStreamId stream_id) { | 359 QuicStreamId stream_id) { |
| 352 decompression_blocked_streams_[header_id] = stream_id; | 360 decompression_blocked_streams_[header_id] = stream_id; |
| 353 } | 361 } |
| 354 | 362 |
| 355 void QuicSession::PostProcessAfterData() { | 363 void QuicSession::PostProcessAfterData() { |
| 356 STLDeleteElements(&closed_streams_); | 364 STLDeleteElements(&closed_streams_); |
| 357 closed_streams_.clear(); | 365 closed_streams_.clear(); |
| 358 } | 366 } |
| 359 | 367 |
| 360 } // namespace net | 368 } // namespace net |
| OLD | NEW |