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_client_session.h" | 5 #include "net/tools/quic/quic_client_session.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/quic/crypto/crypto_protocol.h" | 8 #include "net/quic/crypto/crypto_protocol.h" |
9 #include "net/tools/quic/quic_reliable_client_stream.h" | |
10 #include "net/tools/quic/quic_spdy_client_stream.h" | 9 #include "net/tools/quic/quic_spdy_client_stream.h" |
11 | 10 |
12 using std::string; | 11 using std::string; |
13 | 12 |
14 namespace net { | 13 namespace net { |
15 namespace tools { | 14 namespace tools { |
16 | 15 |
17 QuicClientSession::QuicClientSession( | 16 QuicClientSession::QuicClientSession( |
18 const string& server_hostname, | 17 const string& server_hostname, |
19 const QuicConfig& config, | 18 const QuicConfig& config, |
20 QuicConnection* connection, | 19 QuicConnection* connection, |
21 QuicCryptoClientConfig* crypto_config) | 20 QuicCryptoClientConfig* crypto_config) |
22 : QuicSession(connection, config, false), | 21 : QuicSession(connection, config, false), |
23 crypto_stream_(server_hostname, this, crypto_config) { | 22 crypto_stream_(server_hostname, this, crypto_config) { |
24 } | 23 } |
25 | 24 |
26 QuicClientSession::~QuicClientSession() { | 25 QuicClientSession::~QuicClientSession() { |
27 } | 26 } |
28 | 27 |
29 QuicReliableClientStream* QuicClientSession::CreateOutgoingReliableStream() { | 28 QuicSpdyClientStream* QuicClientSession::CreateOutgoingReliableStream() { |
30 if (!crypto_stream_.encryption_established()) { | 29 if (!crypto_stream_.encryption_established()) { |
31 DLOG(INFO) << "Encryption not active so no outgoing stream created."; | 30 DLOG(INFO) << "Encryption not active so no outgoing stream created."; |
32 return NULL; | 31 return NULL; |
33 } | 32 } |
34 if (GetNumOpenStreams() >= get_max_open_streams()) { | 33 if (GetNumOpenStreams() >= get_max_open_streams()) { |
35 DLOG(INFO) << "Failed to create a new outgoing stream. " | 34 DLOG(INFO) << "Failed to create a new outgoing stream. " |
36 << "Already " << GetNumOpenStreams() << " open."; | 35 << "Already " << GetNumOpenStreams() << " open."; |
37 return NULL; | 36 return NULL; |
38 } | 37 } |
39 if (goaway_received()) { | 38 if (goaway_received()) { |
40 DLOG(INFO) << "Failed to create a new outgoing stream. " | 39 DLOG(INFO) << "Failed to create a new outgoing stream. " |
41 << "Already received goaway."; | 40 << "Already received goaway."; |
42 return NULL; | 41 return NULL; |
43 } | 42 } |
44 QuicReliableClientStream* stream | 43 QuicSpdyClientStream* stream |
45 = new QuicSpdyClientStream(GetNextStreamId(), this); | 44 = new QuicSpdyClientStream(GetNextStreamId(), this); |
46 ActivateStream(stream); | 45 ActivateStream(stream); |
47 return stream; | 46 return stream; |
48 } | 47 } |
49 | 48 |
50 QuicCryptoClientStream* QuicClientSession::GetCryptoStream() { | 49 QuicCryptoClientStream* QuicClientSession::GetCryptoStream() { |
51 return &crypto_stream_; | 50 return &crypto_stream_; |
52 } | 51 } |
53 | 52 |
54 bool QuicClientSession::CryptoConnect() { | 53 bool QuicClientSession::CryptoConnect() { |
55 return crypto_stream_.CryptoConnect(); | 54 return crypto_stream_.CryptoConnect(); |
56 } | 55 } |
57 | 56 |
58 int QuicClientSession::GetNumSentClientHellos() const { | 57 int QuicClientSession::GetNumSentClientHellos() const { |
59 return crypto_stream_.num_sent_client_hellos(); | 58 return crypto_stream_.num_sent_client_hellos(); |
60 } | 59 } |
61 | 60 |
62 ReliableQuicStream* QuicClientSession::CreateIncomingReliableStream( | 61 ReliableQuicStream* QuicClientSession::CreateIncomingReliableStream( |
63 QuicStreamId id) { | 62 QuicStreamId id) { |
64 DLOG(ERROR) << "Server push not supported"; | 63 DLOG(ERROR) << "Server push not supported"; |
65 return NULL; | 64 return NULL; |
66 } | 65 } |
67 | 66 |
68 } // namespace tools | 67 } // namespace tools |
69 } // namespace net | 68 } // namespace net |
OLD | NEW |