No public description PiperOrigin-RevId: 758757943
diff --git a/quiche/quic/tools/quic_client_default_network_helper.cc b/quiche/quic/tools/quic_client_default_network_helper.cc index d53df5f..0fac1e5 100644 --- a/quiche/quic/tools/quic_client_default_network_helper.cc +++ b/quiche/quic/tools/quic_client_default_network_helper.cc
@@ -11,11 +11,13 @@ #include "absl/cleanup/cleanup.h" #include "quiche/quic/core/io/quic_event_loop.h" +#include "quiche/quic/core/io/socket.h" #include "quiche/quic/core/quic_default_packet_writer.h" #include "quiche/quic/core/quic_packets.h" #include "quiche/quic/core/quic_types.h" #include "quiche/quic/core/quic_udp_socket.h" #include "quiche/quic/platform/api/quic_logging.h" +#include "quiche/quic/platform/api/quic_socket_address.h" #include "quiche/common/platform/api/quiche_logging.h" #include "quiche/common/platform/api/quiche_system_event_loop.h" @@ -99,15 +101,24 @@ << strerror(errno); } - if (event_loop_->RegisterSocket( - fd, kSocketEventReadable | kSocketEventWritable, this)) { - fd_address_map_[fd] = client_address; + if (RegisterSocket(fd, kSocketEventReadable | kSocketEventWritable, + client_address)) { std::move(closer).Cancel(); return true; } return false; } +bool QuicClientDefaultNetworkHelper::RegisterSocket( + SocketFd fd, QuicSocketEventMask event_mask, + QuicSocketAddress client_address) { + if (event_loop_->RegisterSocket(fd, event_mask, this)) { + fd_address_map_[fd] = client_address; + return true; + } + return false; +} + void QuicClientDefaultNetworkHelper::CleanUpUDPSocket(SocketFd fd) { CleanUpUDPSocketImpl(fd); fd_address_map_.erase(fd);
diff --git a/quiche/quic/tools/quic_client_default_network_helper.h b/quiche/quic/tools/quic_client_default_network_helper.h index 9b9ba35..ecf9ced 100644 --- a/quiche/quic/tools/quic_client_default_network_helper.h +++ b/quiche/quic/tools/quic_client_default_network_helper.h
@@ -15,6 +15,7 @@ #include "quiche/quic/core/quic_default_packet_writer.h" #include "quiche/quic/core/quic_packet_reader.h" #include "quiche/quic/core/quic_udp_socket.h" +#include "quiche/quic/platform/api/quic_socket_address.h" #include "quiche/quic/tools/quic_client_base.h" #include "quiche/common/quiche_linked_hash_map.h" @@ -131,6 +132,13 @@ // Actually clean up |fd|. virtual void CleanUpUDPSocketImpl(SocketFd fd); + protected: + // For use by subclasses, registers the provided socket with the event loop + // and records it in the address map. Returns true if registration was + // successful, false otherwise. + bool RegisterSocket(SocketFd fd, QuicSocketEventMask event_mask, + QuicSocketAddress client_address); + private: // Listens for events on the client socket. QuicEventLoop* event_loop_;