Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / net / tools / quic / quic_client_session.h
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 // A client specific QuicSession subclass.
6
7 #ifndef NET_TOOLS_QUIC_QUIC_CLIENT_SESSION_H_
8 #define NET_TOOLS_QUIC_QUIC_CLIENT_SESSION_H_
9
10 #include <string>
11
12 #include "base/basictypes.h"
13 #include "net/quic/quic_client_session_base.h"
14 #include "net/quic/quic_crypto_client_stream.h"
15 #include "net/quic/quic_protocol.h"
16 #include "net/tools/quic/quic_spdy_client_stream.h"
17
18 namespace net {
19
20 class QuicConnection;
21 class QuicServerId;
22 class ReliableQuicStream;
23
24 namespace tools {
25
26 class QuicClientSession : public QuicClientSessionBase {
27  public:
28   QuicClientSession(const QuicConfig& config,
29                     QuicConnection* connection,
30                     bool is_secure);
31   ~QuicClientSession() override;
32
33   void InitializeSession(const QuicServerId& server_id,
34                          QuicCryptoClientConfig* config);
35
36   // QuicSession methods:
37   QuicSpdyClientStream* CreateOutgoingDataStream() override;
38   QuicCryptoClientStream* GetCryptoStream() override;
39
40   // QuicClientSessionBase methods:
41   void OnProofValid(const QuicCryptoClientConfig::CachedState& cached) override;
42   void OnProofVerifyDetailsAvailable(
43       const ProofVerifyDetails& verify_details) override;
44
45   // Performs a crypto handshake with the server. Returns true if the crypto
46   // handshake is started successfully.
47   bool CryptoConnect();
48
49   // Returns the number of client hello messages that have been sent on the
50   // crypto stream. If the handshake has completed then this is one greater
51   // than the number of round-trips needed for the handshake.
52   int GetNumSentClientHellos() const;
53
54  protected:
55   // QuicSession methods:
56   QuicDataStream* CreateIncomingDataStream(QuicStreamId id) override;
57
58  private:
59   scoped_ptr<QuicCryptoClientStream> crypto_stream_;
60
61   DISALLOW_COPY_AND_ASSIGN(QuicClientSession);
62 };
63
64 }  // namespace tools
65 }  // namespace net
66
67 #endif  // NET_TOOLS_QUIC_QUIC_CLIENT_SESSION_H_