blob: 99bf26efcc8f735b3a0d326af62cc416ba7d97d8 (
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
|
// Copyright 2014 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 server specific QuicSession subclass.
#ifndef NET_QUIC_QUIC_SERVER_SESSION_H_
#define NET_QUIC_QUIC_SERVER_SESSION_H_
#include <set>
#include <vector>
#include "base/basictypes.h"
#include "base/containers/hash_tables.h"
#include "base/memory/scoped_ptr.h"
#include "net/quic/quic_crypto_server_stream.h"
#include "net/quic/quic_per_connection_packet_writer.h"
#include "net/quic/quic_protocol.h"
#include "net/quic/quic_session.h"
namespace net {
class QuicBlockedWriterInterface;
class QuicConfig;
class QuicConnection;
class QuicCryptoServerConfig;
class ReliableQuicStream;
namespace test {
class QuicServerSessionPeer;
} // namespace test
// An interface from the session to the entity owning the session.
// This lets the session notify its owner (the Dispatcher) when the connection
// is closed or blocked.
class QuicServerSessionVisitor {
public:
virtual ~QuicServerSessionVisitor() {}
virtual void OnConnectionClosed(QuicConnectionId connection_id,
QuicErrorCode error) = 0;
virtual void OnWriteBlocked(QuicBlockedWriterInterface* writer) = 0;
};
class QuicServerSession : public QuicSession {
public:
// Takes ownership of connection_packet_writer
QuicServerSession(const QuicConfig& config,
QuicConnection* connection,
QuicPerConnectionPacketWriter* connection_packet_writer,
QuicServerSessionVisitor* visitor);
// Override the base class to notify the owner of the connection close.
virtual void OnConnectionClosed(QuicErrorCode error, bool from_peer) OVERRIDE;
virtual void OnWriteBlocked() OVERRIDE;
virtual ~QuicServerSession();
virtual void InitializeSession(const QuicCryptoServerConfig& crypto_config);
const QuicCryptoServerStream* crypto_stream() const {
return crypto_stream_.get();
}
protected:
// QuicSession methods:
virtual QuicDataStream* CreateIncomingDataStream(QuicStreamId id) OVERRIDE;
virtual QuicDataStream* CreateOutgoingDataStream() OVERRIDE;
virtual QuicCryptoServerStream* GetCryptoStream() OVERRIDE;
// If we should create an incoming stream, returns true. Otherwise
// does error handling, including communicating the error to the client and
// possibly closing the connection, and returns false.
virtual bool ShouldCreateIncomingDataStream(QuicStreamId id);
virtual QuicCryptoServerStream* CreateQuicCryptoServerStream(
const QuicCryptoServerConfig& crypto_config);
private:
friend class test::QuicServerSessionPeer;
scoped_ptr<QuicCryptoServerStream> crypto_stream_;
scoped_ptr<QuicPerConnectionPacketWriter> connection_packet_writer_;
QuicServerSessionVisitor* visitor_;
DISALLOW_COPY_AND_ASSIGN(QuicServerSession);
};
} // namespace net
#endif // NET_QUIC_QUIC_SERVER_SESSION_H_
|