| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/tools/quic/test_tools/quic_test_server.h" | 5 #include "net/tools/quic/test_tools/quic_test_server.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 const QuicCryptoServerConfig* crypto_config, | 54 const QuicCryptoServerConfig* crypto_config, |
| 55 const QuicVersionVector& versions, | 55 const QuicVersionVector& versions, |
| 56 PacketWriterFactory* factory, | 56 PacketWriterFactory* factory, |
| 57 QuicConnectionHelperInterface* helper) | 57 QuicConnectionHelperInterface* helper) |
| 58 : QuicDispatcher(config, crypto_config, versions, factory, helper) {} | 58 : QuicDispatcher(config, crypto_config, versions, factory, helper) {} |
| 59 QuicServerSession* CreateQuicSession(QuicConnectionId id, | 59 QuicServerSession* CreateQuicSession(QuicConnectionId id, |
| 60 const IPEndPoint& client) override { | 60 const IPEndPoint& client) override { |
| 61 if (session_creator_ == nullptr && stream_creator_ == nullptr) { | 61 if (session_creator_ == nullptr && stream_creator_ == nullptr) { |
| 62 return QuicDispatcher::CreateQuicSession(id, client); | 62 return QuicDispatcher::CreateQuicSession(id, client); |
| 63 } | 63 } |
| 64 QuicConnection* connection = | 64 QuicConnection* connection = new QuicConnection( |
| 65 new QuicConnection(id, client, helper(), connection_writer_factory(), | 65 id, client, helper(), connection_writer_factory(), |
| 66 /* owns_writer= */ true, Perspective::IS_SERVER, | 66 /* owns_writer= */ true, Perspective::IS_SERVER, supported_versions()); |
| 67 /* is_secure */ true, supported_versions()); | |
| 68 | 67 |
| 69 QuicServerSession* session = nullptr; | 68 QuicServerSession* session = nullptr; |
| 70 if (stream_creator_ != nullptr) { | 69 if (stream_creator_ != nullptr) { |
| 71 session = new CustomStreamSession(config(), connection, this, | 70 session = new CustomStreamSession(config(), connection, this, |
| 72 crypto_config(), stream_creator_); | 71 crypto_config(), stream_creator_); |
| 73 } else { | 72 } else { |
| 74 session = session_creator_(config(), connection, this, crypto_config()); | 73 session = session_creator_(config(), connection, this, crypto_config()); |
| 75 } | 74 } |
| 76 session->Initialize(); | 75 session->Initialize(); |
| 77 return session; | 76 return session; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 99 | 98 |
| 100 QuicTestServer::StreamCreationFunction stream_creator() { | 99 QuicTestServer::StreamCreationFunction stream_creator() { |
| 101 return stream_creator_; | 100 return stream_creator_; |
| 102 } | 101 } |
| 103 | 102 |
| 104 private: | 103 private: |
| 105 QuicTestServer::SessionCreationFunction session_creator_; | 104 QuicTestServer::SessionCreationFunction session_creator_; |
| 106 QuicTestServer::StreamCreationFunction stream_creator_; | 105 QuicTestServer::StreamCreationFunction stream_creator_; |
| 107 }; | 106 }; |
| 108 | 107 |
| 109 QuicTestServer::QuicTestServer() : QuicServer() {} | 108 QuicTestServer::QuicTestServer(ProofSource* proof_source) |
| 109 : QuicServer(proof_source) {} |
| 110 | 110 |
| 111 QuicTestServer::QuicTestServer(const QuicConfig& config, | 111 QuicTestServer::QuicTestServer(ProofSource* proof_source, |
| 112 const QuicConfig& config, |
| 112 const QuicVersionVector& supported_versions) | 113 const QuicVersionVector& supported_versions) |
| 113 : QuicServer(config, supported_versions) {} | 114 : QuicServer(proof_source, config, supported_versions) {} |
| 114 | 115 |
| 115 QuicDispatcher* QuicTestServer::CreateQuicDispatcher() { | 116 QuicDispatcher* QuicTestServer::CreateQuicDispatcher() { |
| 116 return new QuicTestDispatcher( | 117 return new QuicTestDispatcher( |
| 117 config(), &crypto_config(), supported_versions(), | 118 config(), &crypto_config(), supported_versions(), |
| 118 new QuicDispatcher::DefaultPacketWriterFactory(), | 119 new QuicDispatcher::DefaultPacketWriterFactory(), |
| 119 new QuicEpollConnectionHelper(epoll_server())); | 120 new QuicEpollConnectionHelper(epoll_server())); |
| 120 } | 121 } |
| 121 | 122 |
| 122 void QuicTestServer::SetSessionCreator(SessionCreationFunction function) { | 123 void QuicTestServer::SetSessionCreator(SessionCreationFunction function) { |
| 123 static_cast<QuicTestDispatcher*>(dispatcher()) | 124 static_cast<QuicTestDispatcher*>(dispatcher()) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 137 QuicConnection* connection, | 138 QuicConnection* connection, |
| 138 QuicServerSessionVisitor* visitor, | 139 QuicServerSessionVisitor* visitor, |
| 139 const QuicCryptoServerConfig* crypto_config) | 140 const QuicCryptoServerConfig* crypto_config) |
| 140 : QuicServerSession(config, connection, visitor, crypto_config) { | 141 : QuicServerSession(config, connection, visitor, crypto_config) { |
| 141 SendGoAway(QUIC_PEER_GOING_AWAY, ""); | 142 SendGoAway(QUIC_PEER_GOING_AWAY, ""); |
| 142 } | 143 } |
| 143 | 144 |
| 144 } // namespace test | 145 } // namespace test |
| 145 } // namespace tools | 146 } // namespace tools |
| 146 } // namespace net | 147 } // namespace net |
| OLD | NEW |