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/crypto/proof_verifier_chromium.h"
10 #include "net/quic/quic_server_id.h"
11 #include "net/tools/quic/quic_spdy_client_stream.h"
18 QuicClientSession::QuicClientSession(const QuicConfig
& config
,
19 QuicConnection
* connection
,
20 const QuicServerId
& server_id
,
21 QuicCryptoClientConfig
* crypto_config
)
22 : QuicClientSessionBase(connection
, config
),
23 crypto_stream_(new QuicCryptoClientStream(
26 new ProofVerifyContextChromium(0, BoundNetLog()),
28 respect_goaway_(true) {
31 QuicClientSession::~QuicClientSession() {
34 void QuicClientSession::OnProofValid(
35 const QuicCryptoClientConfig::CachedState
& /*cached*/) {}
37 void QuicClientSession::OnProofVerifyDetailsAvailable(
38 const ProofVerifyDetails
& /*verify_details*/) {}
40 QuicSpdyClientStream
* QuicClientSession::CreateOutgoingDynamicStream() {
41 if (!crypto_stream_
->encryption_established()) {
42 DVLOG(1) << "Encryption not active so no outgoing stream created.";
45 if (GetNumOpenStreams() >= get_max_open_streams()) {
46 DVLOG(1) << "Failed to create a new outgoing stream. "
47 << "Already " << GetNumOpenStreams() << " open.";
50 if (goaway_received() && respect_goaway_
) {
51 DVLOG(1) << "Failed to create a new outgoing stream. "
52 << "Already received goaway.";
55 QuicSpdyClientStream
* stream
= CreateClientStream();
56 ActivateStream(stream
);
60 QuicSpdyClientStream
* QuicClientSession::CreateClientStream() {
61 return new QuicSpdyClientStream(GetNextStreamId(), this);
64 QuicCryptoClientStream
* QuicClientSession::GetCryptoStream() {
65 return crypto_stream_
.get();
68 void QuicClientSession::CryptoConnect() {
69 DCHECK(flow_controller());
70 crypto_stream_
->CryptoConnect();
73 int QuicClientSession::GetNumSentClientHellos() const {
74 return crypto_stream_
->num_sent_client_hellos();
77 QuicDataStream
* QuicClientSession::CreateIncomingDynamicStream(
79 DLOG(ERROR
) << "Server push not supported";