1 // Copyright 2015 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 #include "net/tools/quic/test_tools/quic_test_server.h"
13 class QuicTestDispatcher
: public QuicDispatcher
{
15 QuicTestDispatcher(const QuicConfig
& config
,
16 const QuicCryptoServerConfig
& crypto_config
,
17 const QuicVersionVector
& versions
,
18 PacketWriterFactory
* factory
,
20 : QuicDispatcher(config
, crypto_config
, versions
, factory
, eps
) {}
21 QuicSession
* CreateQuicSession(QuicConnectionId id
,
22 const IPEndPoint
& server
,
23 const IPEndPoint
& client
) override
{
24 if (session_creator_
== nullptr) {
25 return QuicDispatcher::CreateQuicSession(id
, server
, client
);
27 QuicConnection
* connection
= CreateQuicConnection(id
, server
, client
);
28 QuicServerSession
* session
=
29 (session_creator_
)(config(), connection
, this);
30 session
->InitializeSession(crypto_config());
35 void set_session_creator(
36 const QuicTestServer::SessionCreationFunction
& function
) {
37 session_creator_
= function
;
41 QuicTestServer::SessionCreationFunction session_creator_
;
44 QuicDispatcher
* QuicTestServer::CreateQuicDispatcher() {
45 return new QuicTestDispatcher(
46 config(), crypto_config(), supported_versions(),
47 new QuicDispatcher::DefaultPacketWriterFactory(), epoll_server());
50 void QuicTestServer::SetSessionCreator(
51 const SessionCreationFunction
& function
) {
52 static_cast<QuicTestDispatcher
*>(dispatcher())->set_session_creator(function
);
55 /////////////////////////// TEST SESSIONS ///////////////////////////////
57 ImmediateGoAwaySession::ImmediateGoAwaySession(
58 const QuicConfig
& config
,
59 QuicConnection
* connection
,
60 QuicServerSessionVisitor
* visitor
)
61 : QuicServerSession(config
, connection
, visitor
) {
62 SendGoAway(QUIC_PEER_GOING_AWAY
, "");