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_server_id.h"
10 #include "net/tools/quic/quic_spdy_client_stream.h"
17 QuicClientSession::QuicClientSession(const QuicConfig& config,
18 QuicConnection* connection,
20 : QuicClientSessionBase(connection, config, is_secure) {
23 QuicClientSession::~QuicClientSession() {
26 void QuicClientSession::InitializeSession(
27 const QuicServerId& server_id,
28 QuicCryptoClientConfig* crypto_config) {
29 QuicClientSessionBase::InitializeSession();
31 new QuicCryptoClientStream(server_id, this, nullptr, crypto_config));
34 void QuicClientSession::OnProofValid(
35 const QuicCryptoClientConfig::CachedState& /*cached*/) {
38 void QuicClientSession::OnProofVerifyDetailsAvailable(
39 const ProofVerifyDetails& /*verify_details*/) {
42 QuicSpdyClientStream* QuicClientSession::CreateOutgoingDataStream() {
43 if (!crypto_stream_->encryption_established()) {
44 DVLOG(1) << "Encryption not active so no outgoing stream created.";
47 if (GetNumOpenStreams() >= get_max_open_streams()) {
48 DVLOG(1) << "Failed to create a new outgoing stream. "
49 << "Already " << GetNumOpenStreams() << " open.";
52 if (goaway_received()) {
53 DVLOG(1) << "Failed to create a new outgoing stream. "
54 << "Already received goaway.";
57 QuicSpdyClientStream* stream
58 = new QuicSpdyClientStream(GetNextStreamId(), this);
59 ActivateStream(stream);
63 QuicCryptoClientStream* QuicClientSession::GetCryptoStream() {
64 return crypto_stream_.get();
67 bool QuicClientSession::CryptoConnect() {
68 DCHECK(flow_controller());
69 return crypto_stream_->CryptoConnect();
72 int QuicClientSession::GetNumSentClientHellos() const {
73 return crypto_stream_->num_sent_client_hellos();
76 QuicDataStream* QuicClientSession::CreateIncomingDataStream(
78 DLOG(ERROR) << "Server push not supported";