blob: 6d25b592cb18ebe3c1f20e24acebb17c8f8a87d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// A client specific QuicSession subclass.
#ifndef NET_TOOLS_QUIC_QUIC_CLIENT_SESSION_H_
#define NET_TOOLS_QUIC_QUIC_CLIENT_SESSION_H_
#include <string>
#include "base/macros.h"
#include "net/quic/quic_client_session_base.h"
#include "net/quic/quic_crypto_client_stream.h"
#include "net/quic/quic_protocol.h"
#include "net/tools/quic/quic_spdy_client_stream.h"
namespace net {
class QuicConnection;
class QuicServerId;
class ReliableQuicStream;
namespace tools {
// The maximum time a promises stream can be reserved without being
// claimed by a client request.
const int64_t kPushPromiseTimeoutSecs = 60;
class QuicClientSession : public QuicClientSessionBase {
public:
QuicClientSession(const QuicConfig& config,
QuicConnection* connection,
const QuicServerId& server_id,
QuicCryptoClientConfig* crypto_config);
~QuicClientSession() override;
// Set up the QuicClientSession. Must be called prior to use.
void Initialize() override;
// QuicSession methods:
QuicSpdyClientStream* CreateOutgoingDynamicStream(
SpdyPriority priority) override;
QuicCryptoClientStreamBase* GetCryptoStream() override;
// QuicClientSessionBase methods:
void OnProofValid(const QuicCryptoClientConfig::CachedState& cached) override;
void OnProofVerifyDetailsAvailable(
const ProofVerifyDetails& verify_details) override;
// Performs a crypto handshake with the server.
void CryptoConnect();
// Returns the number of client hello messages that have been sent on the
// crypto stream. If the handshake has completed then this is one greater
// than the number of round-trips needed for the handshake.
int GetNumSentClientHellos() const;
void set_respect_goaway(bool respect_goaway) {
respect_goaway_ = respect_goaway;
}
protected:
// QuicSession methods:
QuicSpdyStream* CreateIncomingDynamicStream(QuicStreamId id) override;
// Create the crypto stream. Called by Initialize()
virtual QuicCryptoClientStreamBase* CreateQuicCryptoStream();
// Unlike CreateOutgoingDynamicStream, which applies a bunch of sanity checks,
// this simply returns a new QuicSpdyClientStream. This may be used by
// subclasses which want to use a subclass of QuicSpdyClientStream for streams
// but wish to use the sanity checks in CreateOutgoingDynamicStream.
virtual QuicSpdyClientStream* CreateClientStream();
const QuicServerId& server_id() { return server_id_; }
QuicCryptoClientConfig* crypto_config() { return crypto_config_; }
private:
bool ShouldCreateIncomingDynamicStream(QuicStreamId id);
scoped_ptr<QuicCryptoClientStreamBase> crypto_stream_;
QuicServerId server_id_;
QuicCryptoClientConfig* crypto_config_;
// If this is set to false, the client will ignore server GOAWAYs and allow
// the creation of streams regardless of the high chance they will fail.
bool respect_goaway_;
DISALLOW_COPY_AND_ASSIGN(QuicClientSession);
};
} // namespace tools
} // namespace net
#endif // NET_TOOLS_QUIC_QUIC_CLIENT_SESSION_H_
|