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/quic/quic_server_id.h" | 9 #include "net/quic/quic_server_id.h" |
10 #include "net/tools/quic/quic_spdy_client_stream.h" | 10 #include "net/tools/quic/quic_spdy_client_stream.h" |
11 | 11 |
12 using std::string; | 12 using std::string; |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 namespace tools { | 15 namespace tools { |
16 | 16 |
17 QuicClientSession::QuicClientSession( | 17 QuicClientSession::QuicClientSession(const QuicConfig& config, |
18 const QuicServerId& server_id, | 18 QuicConnection* connection) |
19 const QuicConfig& config, | 19 : QuicClientSessionBase(connection, config) { |
20 QuicConnection* connection, | |
21 QuicCryptoClientConfig* crypto_config) | |
22 : QuicClientSessionBase(connection, config), | |
23 crypto_stream_(server_id, this, NULL, crypto_config) { | |
24 } | 20 } |
25 | 21 |
26 QuicClientSession::~QuicClientSession() { | 22 QuicClientSession::~QuicClientSession() { |
27 } | 23 } |
28 | 24 |
| 25 void QuicClientSession::InitializeSession( |
| 26 const QuicServerId& server_id, |
| 27 QuicCryptoClientConfig* crypto_config) { |
| 28 QuicClientSessionBase::InitializeSession(); |
| 29 crypto_stream_.reset( |
| 30 new QuicCryptoClientStream(server_id, this, NULL, crypto_config)); |
| 31 } |
| 32 |
29 void QuicClientSession::OnProofValid( | 33 void QuicClientSession::OnProofValid( |
30 const QuicCryptoClientConfig::CachedState& /*cached*/) { | 34 const QuicCryptoClientConfig::CachedState& /*cached*/) { |
31 } | 35 } |
32 | 36 |
33 void QuicClientSession::OnProofVerifyDetailsAvailable( | 37 void QuicClientSession::OnProofVerifyDetailsAvailable( |
34 const ProofVerifyDetails& /*verify_details*/) { | 38 const ProofVerifyDetails& /*verify_details*/) { |
35 } | 39 } |
36 | 40 |
37 QuicSpdyClientStream* QuicClientSession::CreateOutgoingDataStream() { | 41 QuicSpdyClientStream* QuicClientSession::CreateOutgoingDataStream() { |
38 if (!crypto_stream_.encryption_established()) { | 42 if (!crypto_stream_->encryption_established()) { |
39 DVLOG(1) << "Encryption not active so no outgoing stream created."; | 43 DVLOG(1) << "Encryption not active so no outgoing stream created."; |
40 return NULL; | 44 return NULL; |
41 } | 45 } |
42 if (GetNumOpenStreams() >= get_max_open_streams()) { | 46 if (GetNumOpenStreams() >= get_max_open_streams()) { |
43 DVLOG(1) << "Failed to create a new outgoing stream. " | 47 DVLOG(1) << "Failed to create a new outgoing stream. " |
44 << "Already " << GetNumOpenStreams() << " open."; | 48 << "Already " << GetNumOpenStreams() << " open."; |
45 return NULL; | 49 return NULL; |
46 } | 50 } |
47 if (goaway_received()) { | 51 if (goaway_received()) { |
48 DVLOG(1) << "Failed to create a new outgoing stream. " | 52 DVLOG(1) << "Failed to create a new outgoing stream. " |
49 << "Already received goaway."; | 53 << "Already received goaway."; |
50 return NULL; | 54 return NULL; |
51 } | 55 } |
52 QuicSpdyClientStream* stream | 56 QuicSpdyClientStream* stream |
53 = new QuicSpdyClientStream(GetNextStreamId(), this); | 57 = new QuicSpdyClientStream(GetNextStreamId(), this); |
54 ActivateStream(stream); | 58 ActivateStream(stream); |
55 return stream; | 59 return stream; |
56 } | 60 } |
57 | 61 |
58 QuicCryptoClientStream* QuicClientSession::GetCryptoStream() { | 62 QuicCryptoClientStream* QuicClientSession::GetCryptoStream() { |
59 return &crypto_stream_; | 63 return crypto_stream_.get(); |
60 } | 64 } |
61 | 65 |
62 bool QuicClientSession::CryptoConnect() { | 66 bool QuicClientSession::CryptoConnect() { |
63 return crypto_stream_.CryptoConnect(); | 67 DCHECK(flow_controller()); |
| 68 return crypto_stream_->CryptoConnect(); |
64 } | 69 } |
65 | 70 |
66 int QuicClientSession::GetNumSentClientHellos() const { | 71 int QuicClientSession::GetNumSentClientHellos() const { |
67 return crypto_stream_.num_sent_client_hellos(); | 72 return crypto_stream_->num_sent_client_hellos(); |
68 } | 73 } |
69 | 74 |
70 QuicDataStream* QuicClientSession::CreateIncomingDataStream( | 75 QuicDataStream* QuicClientSession::CreateIncomingDataStream( |
71 QuicStreamId id) { | 76 QuicStreamId id) { |
72 DLOG(ERROR) << "Server push not supported"; | 77 DLOG(ERROR) << "Server push not supported"; |
73 return NULL; | 78 return NULL; |
74 } | 79 } |
75 | 80 |
76 } // namespace tools | 81 } // namespace tools |
77 } // namespace net | 82 } // namespace net |
OLD | NEW |