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/reliable_quic_stream.h" | 9 #include "net/quic/reliable_quic_stream.h" |
10 #include "net/tools/quic/quic_spdy_server_stream.h" | 10 #include "net/tools/quic/quic_spdy_server_stream.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 namespace tools { | 13 namespace tools { |
14 | 14 |
15 QuicServerSession::QuicServerSession( | 15 QuicServerSession::QuicServerSession( |
16 const QuicConfig& config, | 16 const QuicConfig& config, |
17 QuicConnection* connection, | 17 QuicConnection* connection, |
18 QuicSessionOwner* owner) | 18 QuicServerSessionVisitor* visitor) |
19 : QuicSession(connection, config), | 19 : QuicSession(connection, config), |
20 owner_(owner) { | 20 visitor_(visitor) {} |
21 } | |
22 | 21 |
23 QuicServerSession::~QuicServerSession() { | 22 QuicServerSession::~QuicServerSession() {} |
24 } | |
25 | 23 |
26 void QuicServerSession::InitializeSession( | 24 void QuicServerSession::InitializeSession( |
27 const QuicCryptoServerConfig& crypto_config) { | 25 const QuicCryptoServerConfig& crypto_config) { |
28 crypto_stream_.reset(CreateQuicCryptoServerStream(crypto_config)); | 26 crypto_stream_.reset(CreateQuicCryptoServerStream(crypto_config)); |
29 } | 27 } |
30 | 28 |
31 QuicCryptoServerStream* QuicServerSession::CreateQuicCryptoServerStream( | 29 QuicCryptoServerStream* QuicServerSession::CreateQuicCryptoServerStream( |
32 const QuicCryptoServerConfig& crypto_config) { | 30 const QuicCryptoServerConfig& crypto_config) { |
33 return new QuicCryptoServerStream(crypto_config, this); | 31 return new QuicCryptoServerStream(crypto_config, this); |
34 } | 32 } |
35 | 33 |
36 void QuicServerSession::OnConnectionClosed(QuicErrorCode error, | 34 void QuicServerSession::OnConnectionClosed(QuicErrorCode error, |
37 bool from_peer) { | 35 bool from_peer) { |
38 QuicSession::OnConnectionClosed(error, from_peer); | 36 QuicSession::OnConnectionClosed(error, from_peer); |
39 owner_->OnConnectionClosed(connection()->guid(), error); | 37 visitor_->OnConnectionClosed(connection()->guid(), error); |
| 38 } |
| 39 |
| 40 void QuicServerSession::OnWriteBlocked() { |
| 41 QuicSession::OnWriteBlocked(); |
| 42 visitor_->OnWriteBlocked(connection()); |
40 } | 43 } |
41 | 44 |
42 bool QuicServerSession::ShouldCreateIncomingDataStream(QuicStreamId id) { | 45 bool QuicServerSession::ShouldCreateIncomingDataStream(QuicStreamId id) { |
43 if (id % 2 == 0) { | 46 if (id % 2 == 0) { |
44 DLOG(INFO) << "Invalid incoming even stream_id:" << id; | 47 DLOG(INFO) << "Invalid incoming even stream_id:" << id; |
45 connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID); | 48 connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID); |
46 return false; | 49 return false; |
47 } | 50 } |
48 if (GetNumOpenStreams() >= get_max_open_streams()) { | 51 if (GetNumOpenStreams() >= get_max_open_streams()) { |
49 DLOG(INFO) << "Failed to create a new incoming stream with id:" << id | 52 DLOG(INFO) << "Failed to create a new incoming stream with id:" << id |
(...skipping 17 matching lines...) Expand all Loading... |
67 DLOG(ERROR) << "Server push not yet supported"; | 70 DLOG(ERROR) << "Server push not yet supported"; |
68 return NULL; | 71 return NULL; |
69 } | 72 } |
70 | 73 |
71 QuicCryptoServerStream* QuicServerSession::GetCryptoStream() { | 74 QuicCryptoServerStream* QuicServerSession::GetCryptoStream() { |
72 return crypto_stream_.get(); | 75 return crypto_stream_.get(); |
73 } | 76 } |
74 | 77 |
75 } // namespace tools | 78 } // namespace tools |
76 } // namespace net | 79 } // namespace net |
OLD | NEW |