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.
5 // A server specific QuicSession subclass.
7 #ifndef NET_TOOLS_QUIC_QUIC_SERVER_SESSION_H_
8 #define NET_TOOLS_QUIC_QUIC_SERVER_SESSION_H_
13 #include "base/containers/hash_tables.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "net/quic/quic_crypto_server_stream.h"
16 #include "net/quic/quic_protocol.h"
17 #include "net/quic/quic_session.h"
23 class QuicCryptoServerConfig
;
24 class ReliableQuicStream
;
28 // An interface from the session to the entity owning the session.
29 // This lets the session notify its owner (the Dispatcher) when the connection
31 class QuicSessionOwner
{
33 virtual ~QuicSessionOwner() {}
35 virtual void OnConnectionClose(QuicGuid guid
, QuicErrorCode error
) = 0;
38 class QuicServerSession
: public QuicSession
{
40 QuicServerSession(const QuicConfig
& config
,
41 QuicConnection
*connection
,
42 QuicSessionOwner
* owner
);
44 // Override the base class to notify the owner of the connection close.
45 virtual void ConnectionClose(QuicErrorCode error
, bool from_peer
) OVERRIDE
;
47 virtual ~QuicServerSession();
49 virtual void InitializeSession(const QuicCryptoServerConfig
& crypto_config
);
51 const QuicCryptoServerStream
* crypto_stream() { return crypto_stream_
.get(); }
54 // QuicSession methods:
55 virtual ReliableQuicStream
* CreateIncomingReliableStream(
56 QuicStreamId id
) OVERRIDE
;
57 virtual ReliableQuicStream
* CreateOutgoingReliableStream() OVERRIDE
;
58 virtual QuicCryptoServerStream
* GetCryptoStream() OVERRIDE
;
60 // If we should create an incoming stream, returns true. Otherwise
61 // does error handling, including communicating the error to the client and
62 // possibly closing the connection, and returns false.
63 virtual bool ShouldCreateIncomingReliableStream(QuicStreamId id
);
65 virtual QuicCryptoServerStream
* CreateQuicCryptoServerStream(
66 const QuicCryptoServerConfig
& crypto_config
);
69 scoped_ptr
<QuicCryptoServerStream
> crypto_stream_
;
70 QuicSessionOwner
* owner_
;
72 DISALLOW_COPY_AND_ASSIGN(QuicServerSession
);
78 #endif // NET_TOOLS_QUIC_QUIC_SERVER_SESSION_H_