| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_server_session.h" | 5 #include "net/quic/quic_server_session.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/quic/quic_connection.h" | 8 #include "net/quic/quic_connection.h" |
| 9 #include "net/quic/quic_flags.h" |
| 9 #include "net/quic/quic_spdy_server_stream.h" | 10 #include "net/quic/quic_spdy_server_stream.h" |
| 10 #include "net/quic/reliable_quic_stream.h" | 11 #include "net/quic/reliable_quic_stream.h" |
| 11 | 12 |
| 12 namespace net { | 13 namespace net { |
| 13 | 14 |
| 14 QuicServerSession::QuicServerSession( | 15 QuicServerSession::QuicServerSession( |
| 15 const QuicConfig& config, | 16 const QuicConfig& config, |
| 16 QuicConnection* connection, | 17 QuicConnection* connection, |
| 17 QuicPerConnectionPacketWriter* connection_packet_writer, | 18 QuicPerConnectionPacketWriter* connection_packet_writer, |
| 18 QuicServerSessionVisitor* visitor) | 19 QuicServerSessionVisitor* visitor) |
| 19 : QuicSession(connection, config), | 20 : QuicSession(connection, config), |
| 20 connection_packet_writer_(connection_packet_writer), | 21 connection_packet_writer_(connection_packet_writer), |
| 21 visitor_(visitor) {} | 22 visitor_(visitor) {} |
| 22 | 23 |
| 23 QuicServerSession::~QuicServerSession() {} | 24 QuicServerSession::~QuicServerSession() {} |
| 24 | 25 |
| 25 void QuicServerSession::InitializeSession( | 26 void QuicServerSession::InitializeSession( |
| 26 const QuicCryptoServerConfig& crypto_config) { | 27 const QuicCryptoServerConfig& crypto_config) { |
| 27 crypto_stream_.reset(CreateQuicCryptoServerStream(crypto_config)); | 28 crypto_stream_.reset(CreateQuicCryptoServerStream(crypto_config)); |
| 28 } | 29 } |
| 29 | 30 |
| 30 QuicCryptoServerStream* QuicServerSession::CreateQuicCryptoServerStream( | 31 QuicCryptoServerStream* QuicServerSession::CreateQuicCryptoServerStream( |
| 31 const QuicCryptoServerConfig& crypto_config) { | 32 const QuicCryptoServerConfig& crypto_config) { |
| 32 return new QuicCryptoServerStream(crypto_config, this); | 33 return new QuicCryptoServerStream(crypto_config, this); |
| 33 } | 34 } |
| 34 | 35 |
| 36 void QuicServerSession::OnConfigNegotiated() { |
| 37 QuicSession::OnConfigNegotiated(); |
| 38 if (!FLAGS_enable_quic_fec || |
| 39 !config()->HasReceivedConnectionOptions() || |
| 40 !ContainsQuicTag(config()->ReceivedConnectionOptions(), kFHDR)) { |
| 41 return; |
| 42 } |
| 43 // kFHDR config maps to FEC protection always for headers stream. |
| 44 // TODO(jri): Add crypto stream in addition to headers for kHDR. |
| 45 headers_stream_->set_fec_policy(FEC_PROTECT_ALWAYS); |
| 46 } |
| 47 |
| 35 void QuicServerSession::OnConnectionClosed(QuicErrorCode error, | 48 void QuicServerSession::OnConnectionClosed(QuicErrorCode error, |
| 36 bool from_peer) { | 49 bool from_peer) { |
| 37 QuicSession::OnConnectionClosed(error, from_peer); | 50 QuicSession::OnConnectionClosed(error, from_peer); |
| 38 // In the unlikely event we get a connection close while doing an asynchronous | 51 // In the unlikely event we get a connection close while doing an asynchronous |
| 39 // crypto event, make sure we cancel the callback. | 52 // crypto event, make sure we cancel the callback. |
| 40 if (crypto_stream_.get() != NULL) { | 53 if (crypto_stream_.get() != NULL) { |
| 41 crypto_stream_->CancelOutstandingCallbacks(); | 54 crypto_stream_->CancelOutstandingCallbacks(); |
| 42 } | 55 } |
| 43 visitor_->OnConnectionClosed(connection()->connection_id(), error); | 56 visitor_->OnConnectionClosed(connection()->connection_id(), error); |
| 44 } | 57 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 75 QuicDataStream* QuicServerSession::CreateOutgoingDataStream() { | 88 QuicDataStream* QuicServerSession::CreateOutgoingDataStream() { |
| 76 DLOG(ERROR) << "Server push not yet supported"; | 89 DLOG(ERROR) << "Server push not yet supported"; |
| 77 return NULL; | 90 return NULL; |
| 78 } | 91 } |
| 79 | 92 |
| 80 QuicCryptoServerStream* QuicServerSession::GetCryptoStream() { | 93 QuicCryptoServerStream* QuicServerSession::GetCryptoStream() { |
| 81 return crypto_stream_.get(); | 94 return crypto_stream_.get(); |
| 82 } | 95 } |
| 83 | 96 |
| 84 } // namespace net | 97 } // namespace net |
| OLD | NEW |