1 // Copyright 2022 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 #ifndef QUICHE_QUIC_CORE_IO_EVENT_LOOP_SOCKET_FACTORY_H_ 6 #define QUICHE_QUIC_CORE_IO_EVENT_LOOP_SOCKET_FACTORY_H_ 7 8 #include <memory> 9 10 #include "quiche/quic/core/connecting_client_socket.h" 11 #include "quiche/quic/core/io/quic_event_loop.h" 12 #include "quiche/quic/core/quic_types.h" 13 #include "quiche/quic/core/socket_factory.h" 14 #include "quiche/quic/platform/api/quic_socket_address.h" 15 #include "quiche/common/platform/api/quiche_export.h" 16 #include "quiche/common/quiche_buffer_allocator.h" 17 18 namespace quic { 19 20 // A socket factory that creates sockets implemented using an underlying 21 // QuicEventLoop. 22 class EventLoopSocketFactory : public SocketFactory { 23 public: 24 // `event_loop` and `buffer_allocator` must outlive the created factory. 25 EventLoopSocketFactory(QuicEventLoop* event_loop, 26 quiche::QuicheBufferAllocator* buffer_allocator); 27 28 // SocketFactory: 29 std::unique_ptr<ConnectingClientSocket> CreateTcpClientSocket( 30 const quic::QuicSocketAddress& peer_address, 31 QuicByteCount receive_buffer_size, QuicByteCount send_buffer_size, 32 ConnectingClientSocket::AsyncVisitor* async_visitor) override; 33 std::unique_ptr<ConnectingClientSocket> CreateConnectingUdpClientSocket( 34 const quic::QuicSocketAddress& peer_address, 35 QuicByteCount receive_buffer_size, QuicByteCount send_buffer_size, 36 ConnectingClientSocket::AsyncVisitor* async_visitor) override; 37 38 private: 39 QuicEventLoop* const event_loop_; // unowned 40 quiche::QuicheBufferAllocator* buffer_allocator_; // unowned 41 }; 42 43 } // namespace quic 44 45 #endif // QUICHE_QUIC_CORE_IO_EVENT_LOOP_SOCKET_FACTORY_H_ 46