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