Migrating MASQUE uses of QuicClient to QuicDefaultClient. I will rename the classes themselves later. PiperOrigin-RevId: 468790033
diff --git a/quiche/quic/masque/masque_client_bin.cc b/quiche/quic/masque/masque_client_bin.cc index 2d686df..c2918ef 100644 --- a/quiche/quic/masque/masque_client_bin.cc +++ b/quiche/quic/masque/masque_client_bin.cc
@@ -13,6 +13,9 @@ #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "url/third_party/mozilla/url_parse.h" +#include "quiche/quic/core/io/quic_default_event_loop.h" +#include "quiche/quic/core/io/quic_event_loop.h" +#include "quiche/quic/core/quic_default_clock.h" #include "quiche/quic/core/quic_server_id.h" #include "quiche/quic/masque/masque_client_tools.h" #include "quiche/quic/masque/masque_encapsulated_epoll_client.h" @@ -38,7 +41,7 @@ namespace { int RunMasqueClient(int argc, char* argv[]) { - quiche::QuicheSystemEventLoop event_loop("masque_client"); + quiche::QuicheSystemEventLoop system_event_loop("masque_client"); const char* usage = "Usage: masque_client [options] <url>"; // The first non-flag argument is the URI template of the MASQUE server. @@ -55,7 +58,8 @@ const bool disable_certificate_verification = quiche::GetQuicheCommandLineFlag(FLAGS_disable_certificate_verification); - QuicEpollServer epoll_server; + std::unique_ptr<QuicEventLoop> event_loop = + GetDefaultEventLoop()->Create(QuicDefaultClock::Get()); std::string uri_template = urls[0]; if (!absl::StrContains(uri_template, '/')) { @@ -90,7 +94,7 @@ return 1; } std::unique_ptr<MasqueEpollClient> masque_client = MasqueEpollClient::Create( - uri_template, masque_mode, &epoll_server, std::move(proof_verifier)); + uri_template, masque_mode, event_loop.get(), std::move(proof_verifier)); if (masque_client == nullptr) { return 1; } @@ -100,7 +104,7 @@ for (size_t i = 1; i < urls.size(); ++i) { if (!tools::SendEncapsulatedMasqueRequest( - masque_client.get(), &epoll_server, urls[i], + masque_client.get(), event_loop.get(), urls[i], disable_certificate_verification)) { return 1; }
diff --git a/quiche/quic/masque/masque_client_tools.cc b/quiche/quic/masque/masque_client_tools.cc index 2c21a77..cd87b50 100644 --- a/quiche/quic/masque/masque_client_tools.cc +++ b/quiche/quic/masque/masque_client_tools.cc
@@ -8,6 +8,7 @@ #include "quiche/quic/masque/masque_utils.h" #include "quiche/quic/platform/api/quic_default_proof_providers.h" #include "quiche/quic/tools/fake_proof_verifier.h" +#include "quiche/quic/tools/quic_name_lookup.h" #include "quiche/quic/tools/quic_url.h" #include "quiche/spdy/core/http2_header_block.h" @@ -15,7 +16,7 @@ namespace tools { bool SendEncapsulatedMasqueRequest(MasqueEpollClient* masque_client, - QuicEpollServer* epoll_server, + QuicEventLoop* event_loop, std::string url_string, bool disable_certificate_verification) { const QuicUrl url(url_string, "https"); @@ -35,7 +36,7 @@ } const QuicServerId server_id(url.host(), url.port()); auto client = std::make_unique<MasqueEncapsulatedEpollClient>( - addr, server_id, epoll_server, std::move(proof_verifier), masque_client); + addr, server_id, event_loop, std::move(proof_verifier), masque_client); if (client == nullptr) { QUIC_LOG(ERROR) << "Failed to create MasqueEncapsulatedEpollClient for "
diff --git a/quiche/quic/masque/masque_client_tools.h b/quiche/quic/masque/masque_client_tools.h index 0a8a439..6953ef0 100644 --- a/quiche/quic/masque/masque_client_tools.h +++ b/quiche/quic/masque/masque_client_tools.h
@@ -11,11 +11,11 @@ namespace tools { // Sends an HTTP GET request for |url_string|, proxied over the MASQUE -// connection represented by |masque_client|. A valid and owned |epoll_server| +// connection represented by |masque_client|. A valid and owned |event_loop| // is required. |disable_certificate_verification| allows disabling verification // of the HTTP server's TLS certificate. bool SendEncapsulatedMasqueRequest(MasqueEpollClient* masque_client, - QuicEpollServer* epoll_server, + QuicEventLoop* event_loop, std::string url_string, bool disable_certificate_verification);
diff --git a/quiche/quic/masque/masque_encapsulated_epoll_client.cc b/quiche/quic/masque/masque_encapsulated_epoll_client.cc index 242d265..8f92203 100644 --- a/quiche/quic/masque/masque_encapsulated_epoll_client.cc +++ b/quiche/quic/masque/masque_encapsulated_epoll_client.cc
@@ -9,6 +9,7 @@ #include "quiche/quic/masque/masque_encapsulated_client_session.h" #include "quiche/quic/masque/masque_epoll_client.h" #include "quiche/quic/masque/masque_utils.h" +#include "quiche/quic/tools/quic_client_default_network_helper.h" namespace quic { @@ -38,7 +39,7 @@ void SetWritable() override {} absl::optional<int> MessageTooBigErrorCode() const override { - return EMSGSIZE; + return absl::nullopt; } QuicByteCount GetMaxPacketSize( @@ -63,11 +64,11 @@ // Custom network helper that allows injecting a custom packet writer in order // to get all of a connection's outgoing packets. -class MasqueClientEpollNetworkHelper : public QuicClientEpollNetworkHelper { +class MasqueClientDefaultNetworkHelper : public QuicClientDefaultNetworkHelper { public: - MasqueClientEpollNetworkHelper(QuicEpollServer* epoll_server, - MasqueEncapsulatedEpollClient* client) - : QuicClientEpollNetworkHelper(epoll_server, client), client_(client) {} + MasqueClientDefaultNetworkHelper(QuicEventLoop* event_loop, + MasqueEncapsulatedEpollClient* client) + : QuicClientDefaultNetworkHelper(event_loop, client), client_(client) {} QuicPacketWriter* CreateQuicPacketWriter() override { return new MasquePacketWriter(client_); } @@ -80,13 +81,12 @@ MasqueEncapsulatedEpollClient::MasqueEncapsulatedEpollClient( QuicSocketAddress server_address, const QuicServerId& server_id, - QuicEpollServer* epoll_server, - std::unique_ptr<ProofVerifier> proof_verifier, + QuicEventLoop* event_loop, std::unique_ptr<ProofVerifier> proof_verifier, MasqueEpollClient* masque_client) - : QuicClient( + : QuicDefaultClient( server_address, server_id, MasqueSupportedVersions(), - MasqueEncapsulatedConfig(), epoll_server, - std::make_unique<MasqueClientEpollNetworkHelper>(epoll_server, this), + MasqueEncapsulatedConfig(), event_loop, + std::make_unique<MasqueClientDefaultNetworkHelper>(event_loop, this), std::move(proof_verifier)), masque_client_(masque_client) {} @@ -108,7 +108,8 @@ MasqueEncapsulatedClientSession* MasqueEncapsulatedEpollClient::masque_encapsulated_client_session() { - return static_cast<MasqueEncapsulatedClientSession*>(QuicClient::session()); + return static_cast<MasqueEncapsulatedClientSession*>( + QuicDefaultClient::session()); } } // namespace quic
diff --git a/quiche/quic/masque/masque_encapsulated_epoll_client.h b/quiche/quic/masque/masque_encapsulated_epoll_client.h index 2b98652..06777b9 100644 --- a/quiche/quic/masque/masque_encapsulated_epoll_client.h +++ b/quiche/quic/masque/masque_encapsulated_epoll_client.h
@@ -5,19 +5,20 @@ #ifndef QUICHE_QUIC_MASQUE_MASQUE_ENCAPSULATED_EPOLL_CLIENT_H_ #define QUICHE_QUIC_MASQUE_MASQUE_ENCAPSULATED_EPOLL_CLIENT_H_ +#include "quiche/quic/core/io/quic_event_loop.h" #include "quiche/quic/masque/masque_encapsulated_client_session.h" #include "quiche/quic/masque/masque_epoll_client.h" #include "quiche/quic/platform/api/quic_export.h" -#include "quiche/quic/tools/quic_client.h" +#include "quiche/quic/tools/quic_default_client.h" namespace quic { // QUIC client for QUIC encapsulated in MASQUE. -class QUIC_NO_EXPORT MasqueEncapsulatedEpollClient : public QuicClient { +class QUIC_NO_EXPORT MasqueEncapsulatedEpollClient : public QuicDefaultClient { public: MasqueEncapsulatedEpollClient(QuicSocketAddress server_address, const QuicServerId& server_id, - QuicEpollServer* epoll_server, + QuicEventLoop* event_loop, std::unique_ptr<ProofVerifier> proof_verifier, MasqueEpollClient* masque_client); ~MasqueEncapsulatedEpollClient() override;
diff --git a/quiche/quic/masque/masque_epoll_client.cc b/quiche/quic/masque/masque_epoll_client.cc index 705ea15..0f2619f 100644 --- a/quiche/quic/masque/masque_epoll_client.cc +++ b/quiche/quic/masque/masque_epoll_client.cc
@@ -9,17 +9,18 @@ #include "absl/memory/memory.h" #include "quiche/quic/masque/masque_client_session.h" #include "quiche/quic/masque/masque_utils.h" +#include "quiche/quic/tools/quic_name_lookup.h" #include "quiche/quic/tools/quic_url.h" namespace quic { MasqueEpollClient::MasqueEpollClient( QuicSocketAddress server_address, const QuicServerId& server_id, - MasqueMode masque_mode, QuicEpollServer* epoll_server, + MasqueMode masque_mode, QuicEventLoop* event_loop, std::unique_ptr<ProofVerifier> proof_verifier, const std::string& uri_template) - : QuicClient(server_address, server_id, MasqueSupportedVersions(), - epoll_server, std::move(proof_verifier)), + : QuicDefaultClient(server_address, server_id, MasqueSupportedVersions(), + event_loop, std::move(proof_verifier)), masque_mode_(masque_mode), uri_template_(uri_template) {} @@ -34,7 +35,7 @@ } MasqueClientSession* MasqueEpollClient::masque_client_session() { - return static_cast<MasqueClientSession*>(QuicClient::session()); + return static_cast<MasqueClientSession*>(QuicDefaultClient::session()); } QuicConnectionId MasqueEpollClient::connection_id() { @@ -49,8 +50,7 @@ // static std::unique_ptr<MasqueEpollClient> MasqueEpollClient::Create( const std::string& uri_template, MasqueMode masque_mode, - QuicEpollServer* epoll_server, - std::unique_ptr<ProofVerifier> proof_verifier) { + QuicEventLoop* event_loop, std::unique_ptr<ProofVerifier> proof_verifier) { QuicUrl url(uri_template); std::string host = url.host(); uint16_t port = url.port(); @@ -65,7 +65,7 @@ // std::make_unique<MasqueEpollClient>(...) because the constructor for // MasqueEpollClient is private and therefore not accessible from make_unique. auto masque_client = absl::WrapUnique( - new MasqueEpollClient(addr, server_id, masque_mode, epoll_server, + new MasqueEpollClient(addr, server_id, masque_mode, event_loop, std::move(proof_verifier), uri_template)); if (masque_client == nullptr) {
diff --git a/quiche/quic/masque/masque_epoll_client.h b/quiche/quic/masque/masque_epoll_client.h index 7eff270..8326e38 100644 --- a/quiche/quic/masque/masque_epoll_client.h +++ b/quiche/quic/masque/masque_epoll_client.h
@@ -7,23 +7,22 @@ #include <string> +#include "quiche/quic/core/io/quic_event_loop.h" #include "quiche/quic/masque/masque_client_session.h" #include "quiche/quic/masque/masque_utils.h" #include "quiche/quic/platform/api/quic_export.h" -#include "quiche/quic/tools/quic_client.h" -#include "quiche/quic/tools/quic_url.h" +#include "quiche/quic/tools/quic_default_client.h" namespace quic { // QUIC client that implements MASQUE. -class QUIC_NO_EXPORT MasqueEpollClient : public QuicClient, +class QUIC_NO_EXPORT MasqueEpollClient : public QuicDefaultClient, public MasqueClientSession::Owner { public: // Constructs a MasqueEpollClient, performs a synchronous DNS lookup. static std::unique_ptr<MasqueEpollClient> Create( const std::string& uri_template, MasqueMode masque_mode, - QuicEpollServer* epoll_server, - std::unique_ptr<ProofVerifier> proof_verifier); + QuicEventLoop* event_loop, std::unique_ptr<ProofVerifier> proof_verifier); // From QuicClient. std::unique_ptr<QuicSession> CreateQuicClientSession( @@ -45,7 +44,7 @@ // Constructor is private, use Create() instead. MasqueEpollClient(QuicSocketAddress server_address, const QuicServerId& server_id, MasqueMode masque_mode, - QuicEpollServer* epoll_server, + QuicEventLoop* event_loop, std::unique_ptr<ProofVerifier> proof_verifier, const std::string& uri_template);