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.
5 #include "net/tools/quic/quic_client_session.h"
7 #include "base/logging.h"
8 #include "net/quic/crypto/crypto_protocol.h"
9 #include "net/quic/quic_session_key.h"
10 #include "net/tools/quic/quic_spdy_client_stream.h"
17 QuicClientSession::QuicClientSession(
18 const QuicSessionKey& server_key,
19 const QuicConfig& config,
20 QuicConnection* connection,
21 QuicCryptoClientConfig* crypto_config)
22 : QuicClientSessionBase(connection, config),
23 crypto_stream_(server_key, this, NULL, crypto_config) {
26 QuicClientSession::~QuicClientSession() {
29 void QuicClientSession::OnProofValid(
30 const QuicCryptoClientConfig::CachedState& /*cached*/) {
33 void QuicClientSession::OnProofVerifyDetailsAvailable(
34 const ProofVerifyDetails& /*verify_details*/) {
37 QuicSpdyClientStream* QuicClientSession::CreateOutgoingDataStream() {
38 if (!crypto_stream_.encryption_established()) {
39 DVLOG(1) << "Encryption not active so no outgoing stream created.";
42 if (GetNumOpenStreams() >= get_max_open_streams()) {
43 DVLOG(1) << "Failed to create a new outgoing stream. "
44 << "Already " << GetNumOpenStreams() << " open.";
47 if (goaway_received()) {
48 DVLOG(1) << "Failed to create a new outgoing stream. "
49 << "Already received goaway.";
52 QuicSpdyClientStream* stream
53 = new QuicSpdyClientStream(GetNextStreamId(), this);
54 ActivateStream(stream);
58 QuicCryptoClientStream* QuicClientSession::GetCryptoStream() {
59 return &crypto_stream_;
62 bool QuicClientSession::CryptoConnect() {
63 return crypto_stream_.CryptoConnect();
66 int QuicClientSession::GetNumSentClientHellos() const {
67 return crypto_stream_.num_sent_client_hellos();
70 QuicDataStream* QuicClientSession::CreateIncomingDataStream(
72 DLOG(ERROR) << "Server push not supported";