From bf91b5a3a9a64d4ad6eb289941db439b730a55cf Mon Sep 17 00:00:00 2001 From: Valentin Gosu Date: Thu, 14 Oct 2021 12:58:01 +0000 Subject: [PATCH] Bug 1733922 - Specialize TransportSetup into Primary/BackupTransportSetup r=necko-reviewers,dragana Differential Revision: https://phabricator.services.mozilla.com/D127410 --- netwerk/protocol/http/DnsAndConnectSocket.cpp | 4 +--- netwerk/protocol/http/DnsAndConnectSocket.h | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/netwerk/protocol/http/DnsAndConnectSocket.cpp b/netwerk/protocol/http/DnsAndConnectSocket.cpp index a6c13b2bc031..c411a2ad40c5 100644 --- a/netwerk/protocol/http/DnsAndConnectSocket.cpp +++ b/netwerk/protocol/http/DnsAndConnectSocket.cpp @@ -53,13 +53,11 @@ DnsAndConnectSocket::DnsAndConnectSocket(nsHttpConnectionInfo* ci, uint32_t caps, bool speculative, bool isFromPredictor, bool urgentStart) : mTransaction(trans), - mPrimaryTransport(false), mCaps(caps), mSpeculative(speculative), mUrgentStart(urgentStart), mIsFromPredictor(isFromPredictor), - mConnInfo(ci), - mBackupTransport(true) { + mConnInfo(ci) { MOZ_ASSERT(ci && trans, "constructor with null arguments"); LOG(("Creating DnsAndConnectSocket [this=%p trans=%p ent=%s key=%s]\n", this, trans, mConnInfo->Origin(), mConnInfo->HashKey().get())); diff --git a/netwerk/protocol/http/DnsAndConnectSocket.h b/netwerk/protocol/http/DnsAndConnectSocket.h index 473061596b6a..5ddaa4525211 100644 --- a/netwerk/protocol/http/DnsAndConnectSocket.h +++ b/netwerk/protocol/http/DnsAndConnectSocket.h @@ -169,8 +169,6 @@ class DnsAndConnectSocket final : public nsIOutputStreamCallback, void SetConnecting(); void MaybeSetConnectingDone(); - explicit TransportSetup(bool isBackup); - nsresult Init(DnsAndConnectSocket* dnsAndSock); void CancelDnsResolution(); void Abandon(); @@ -184,6 +182,17 @@ class DnsAndConnectSocket final : public nsIOutputStreamCallback, nsresult OnLookupComplete(DnsAndConnectSocket* dnsAndSock, nsIDNSRecord* rec, nsresult status); nsresult CheckConnectedResult(DnsAndConnectSocket* dnsAndSock); + + protected: + explicit TransportSetup(bool isBackup); + }; + + struct PrimaryTransportSetup final : TransportSetup { + PrimaryTransportSetup() : TransportSetup(false) {} + }; + + struct BackupTransportSetup final : TransportSetup { + BackupTransportSetup() : TransportSetup(true) {} }; nsresult SetupConn(bool isPrimary, nsresult status); @@ -210,7 +219,7 @@ class DnsAndConnectSocket final : public nsIOutputStreamCallback, RefPtr mTransaction; bool mDispatchedMTransaction = false; - TransportSetup mPrimaryTransport; + PrimaryTransportSetup mPrimaryTransport; uint32_t mCaps; // mSpeculative is set if the socket was created from @@ -247,7 +256,7 @@ class DnsAndConnectSocket final : public nsIOutputStreamCallback, RefPtr mConnInfo; nsCOMPtr mSynTimer; - TransportSetup mBackupTransport; + BackupTransportSetup mBackupTransport; bool mIsHttp3;