Update To 11.40.268.0
[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(const QuicConfig& config,
18                                      QuicConnection* connection,
19                                      bool is_secure)
20     : QuicClientSessionBase(connection, config, is_secure) {
21 }
22
23 QuicClientSession::~QuicClientSession() {
24 }
25
26 void QuicClientSession::InitializeSession(
27     const QuicServerId& server_id,
28     QuicCryptoClientConfig* crypto_config) {
29   QuicClientSessionBase::InitializeSession();
30   crypto_stream_.reset(
31       new QuicCryptoClientStream(server_id, this, nullptr, crypto_config));
32 }
33
34 void QuicClientSession::OnProofValid(
35     const QuicCryptoClientConfig::CachedState& /*cached*/) {
36 }
37
38 void QuicClientSession::OnProofVerifyDetailsAvailable(
39     const ProofVerifyDetails& /*verify_details*/) {
40 }
41
42 QuicSpdyClientStream* QuicClientSession::CreateOutgoingDataStream() {
43   if (!crypto_stream_->encryption_established()) {
44     DVLOG(1) << "Encryption not active so no outgoing stream created.";
45     return nullptr;
46   }
47   if (GetNumOpenStreams() >= get_max_open_streams()) {
48     DVLOG(1) << "Failed to create a new outgoing stream. "
49              << "Already " << GetNumOpenStreams() << " open.";
50     return nullptr;
51   }
52   if (goaway_received()) {
53     DVLOG(1) << "Failed to create a new outgoing stream. "
54              << "Already received goaway.";
55     return nullptr;
56   }
57   QuicSpdyClientStream* stream
58       = new QuicSpdyClientStream(GetNextStreamId(), this);
59   ActivateStream(stream);
60   return stream;
61 }
62
63 QuicCryptoClientStream* QuicClientSession::GetCryptoStream() {
64   return crypto_stream_.get();
65 }
66
67 bool QuicClientSession::CryptoConnect() {
68   DCHECK(flow_controller());
69   return crypto_stream_->CryptoConnect();
70 }
71
72 int QuicClientSession::GetNumSentClientHellos() const {
73   return crypto_stream_->num_sent_client_hellos();
74 }
75
76 QuicDataStream* QuicClientSession::CreateIncomingDataStream(
77     QuicStreamId id) {
78   DLOG(ERROR) << "Server push not supported";
79   return nullptr;
80 }
81
82 }  // namespace tools
83 }  // namespace net