vasilvv | d88f162 | 2019-11-04 13:50:53 -0800 | [diff] [blame] | 1 | // Copyright (c) 2019 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. |
| 4 | |
| 5 | #include "net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.h" |
| 6 | |
| 7 | #include <memory> |
| 8 | |
| 9 | #include "net/third_party/quiche/src/quic/core/quic_connection.h" |
| 10 | #include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" |
| 11 | #include "net/third_party/quiche/src/quic/core/quic_types.h" |
| 12 | #include "net/third_party/quiche/src/quic/core/quic_versions.h" |
| 13 | #include "net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h" |
QUICHE team | 5015e2e | 2019-12-11 09:38:06 -0800 | [diff] [blame] | 14 | #include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" |
vasilvv | d88f162 | 2019-11-04 13:50:53 -0800 | [diff] [blame] | 15 | |
| 16 | namespace quic { |
| 17 | |
| 18 | QuicTransportSimpleServerDispatcher::QuicTransportSimpleServerDispatcher( |
| 19 | const QuicConfig* config, |
| 20 | const QuicCryptoServerConfig* crypto_config, |
| 21 | QuicVersionManager* version_manager, |
| 22 | std::unique_ptr<QuicConnectionHelperInterface> helper, |
| 23 | std::unique_ptr<QuicCryptoServerStream::Helper> session_helper, |
| 24 | std::unique_ptr<QuicAlarmFactory> alarm_factory, |
| 25 | uint8_t expected_server_connection_id_length, |
vasilvv | d88f162 | 2019-11-04 13:50:53 -0800 | [diff] [blame] | 26 | std::vector<url::Origin> accepted_origins) |
| 27 | : QuicDispatcher(config, |
| 28 | crypto_config, |
| 29 | version_manager, |
| 30 | std::move(helper), |
| 31 | std::move(session_helper), |
| 32 | std::move(alarm_factory), |
| 33 | expected_server_connection_id_length), |
vasilvv | d88f162 | 2019-11-04 13:50:53 -0800 | [diff] [blame] | 34 | accepted_origins_(accepted_origins) {} |
| 35 | |
wub | 89490e0 | 2019-12-12 12:45:58 -0800 | [diff] [blame] | 36 | std::unique_ptr<QuicSession> |
| 37 | QuicTransportSimpleServerDispatcher::CreateQuicSession( |
vasilvv | d88f162 | 2019-11-04 13:50:53 -0800 | [diff] [blame] | 38 | QuicConnectionId server_connection_id, |
| 39 | const QuicSocketAddress& peer_address, |
QUICHE team | 5015e2e | 2019-12-11 09:38:06 -0800 | [diff] [blame] | 40 | quiche::QuicheStringPiece /*alpn*/, |
vasilvv | d88f162 | 2019-11-04 13:50:53 -0800 | [diff] [blame] | 41 | const ParsedQuicVersion& version) { |
| 42 | auto connection = std::make_unique<QuicConnection>( |
| 43 | server_connection_id, peer_address, helper(), alarm_factory(), writer(), |
| 44 | /*owns_writer=*/false, Perspective::IS_SERVER, |
| 45 | ParsedQuicVersionVector{version}); |
wub | 89490e0 | 2019-12-12 12:45:58 -0800 | [diff] [blame] | 46 | auto session = std::make_unique<QuicTransportSimpleServerSession>( |
| 47 | connection.release(), /*owns_connection=*/true, this, config(), |
| 48 | GetSupportedVersions(), crypto_config(), compressed_certs_cache(), |
| 49 | accepted_origins_); |
wub | 50c6a37 | 2019-11-25 05:34:56 -0800 | [diff] [blame] | 50 | session->Initialize(); |
| 51 | return session; |
vasilvv | d88f162 | 2019-11-04 13:50:53 -0800 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | } // namespace quic |