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