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