Removing prefixMatch attribute of CacheQueryOptions.
[chromium-blink-merge.git] / net / tools / quic / test_tools / quic_test_server.cc
blob3d6c2476c6c0f6b3ca7ef82cdc5199bcf3774794
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"
7 namespace net {
9 namespace tools {
11 namespace test {
13 class QuicTestDispatcher : public QuicDispatcher {
14 public:
15 QuicTestDispatcher(const QuicConfig& config,
16 const QuicCryptoServerConfig& crypto_config,
17 const QuicVersionVector& versions,
18 PacketWriterFactory* factory,
19 EpollServer* eps)
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);
26 } else {
27 QuicConnection* connection = CreateQuicConnection(id, server, client);
28 QuicServerSession* session =
29 (session_creator_)(config(), connection, this);
30 session->InitializeSession(crypto_config());
31 return session;
35 void set_session_creator(
36 const QuicTestServer::SessionCreationFunction& function) {
37 session_creator_ = function;
40 private:
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, "");
65 } // namespace test
67 } // namespace tools
69 } // namespace net