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;
29 class QuicServerSessionPeer;
32 // An interface from the session to the entity owning the session.
33 // This lets the session notify its owner (the Dispatcher) when the connection
35 class QuicSessionOwner {
37 virtual ~QuicSessionOwner() {}
39 virtual void OnConnectionClosed(QuicGuid guid, QuicErrorCode error) = 0;
42 class QuicServerSession : public QuicSession {
44 QuicServerSession(const QuicConfig& config,
45 QuicConnection *connection,
46 QuicSessionOwner* owner);
48 // Override the base class to notify the owner of the connection close.
49 virtual void OnConnectionClosed(QuicErrorCode error, bool from_peer) OVERRIDE;
51 virtual ~QuicServerSession();
53 virtual void InitializeSession(const QuicCryptoServerConfig& crypto_config);
55 const QuicCryptoServerStream* crypto_stream() { return crypto_stream_.get(); }
58 // QuicSession methods:
59 virtual ReliableQuicStream* CreateIncomingReliableStream(
60 QuicStreamId id) OVERRIDE;
61 virtual ReliableQuicStream* CreateOutgoingReliableStream() OVERRIDE;
62 virtual QuicCryptoServerStream* GetCryptoStream() OVERRIDE;
64 // If we should create an incoming stream, returns true. Otherwise
65 // does error handling, including communicating the error to the client and
66 // possibly closing the connection, and returns false.
67 virtual bool ShouldCreateIncomingReliableStream(QuicStreamId id);
69 virtual QuicCryptoServerStream* CreateQuicCryptoServerStream(
70 const QuicCryptoServerConfig& crypto_config);
73 friend class test::QuicServerSessionPeer;
75 scoped_ptr<QuicCryptoServerStream> crypto_stream_;
76 QuicSessionOwner* owner_;
78 DISALLOW_COPY_AND_ASSIGN(QuicServerSession);
84 #endif // NET_TOOLS_QUIC_QUIC_SERVER_SESSION_H_