Bug 1733922 - Specialize TransportSetup into Primary/BackupTransportSetup r=necko-reviewers,dragana
☠☠ backed out by c274f0061d80 ☠ ☠
authorValentin Gosu <valentin.gosu@gmail.com>
Wed, 13 Oct 2021 19:39:09 +0000
changeset 595730 85b747a60e7348d3c650c4188275160839983f86
parent 595729 4af7a3a697ad38c7f9e136f6877cdbf2eb58283e
child 595731 487c3eb6a0cdc989e28268562d1d753671fcdee6
push id151443
push uservalentin.gosu@gmail.com
push dateWed, 13 Oct 2021 19:43:33 +0000
treeherderautoland@85b747a60e73 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnecko-reviewers, dragana
bugs1733922
milestone95.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1733922 - Specialize TransportSetup into Primary/BackupTransportSetup r=necko-reviewers,dragana Differential Revision: https://phabricator.services.mozilla.com/D127410
netwerk/protocol/http/DnsAndConnectSocket.cpp
netwerk/protocol/http/DnsAndConnectSocket.h
--- a/netwerk/protocol/http/DnsAndConnectSocket.cpp
+++ b/netwerk/protocol/http/DnsAndConnectSocket.cpp
@@ -48,23 +48,21 @@ NS_INTERFACE_MAP_BEGIN(DnsAndConnectSock
   NS_INTERFACE_MAP_ENTRY_CONCRETE(DnsAndConnectSocket)
 NS_INTERFACE_MAP_END
 
 DnsAndConnectSocket::DnsAndConnectSocket(nsHttpConnectionInfo* ci,
                                          nsAHttpTransaction* trans,
                                          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()));
 
   mIsHttp3 = mConnInfo->IsHttp3();
   if (speculative) {
     Telemetry::AutoCounter<Telemetry::HTTPCONNMGR_TOTAL_SPECULATIVE_CONN>
         totalSpeculativeConn;
--- a/netwerk/protocol/http/DnsAndConnectSocket.h
+++ b/netwerk/protocol/http/DnsAndConnectSocket.h
@@ -164,31 +164,40 @@ class DnsAndConnectSocket final : public
     TimeStamp mSynStarted;
     bool mConnectedOK = false;
     bool mIsBackup;
 
     bool mWaitingForConnect = false;
     void SetConnecting();
     void MaybeSetConnectingDone();
 
-    explicit TransportSetup(bool isBackup);
-
     nsresult Init(DnsAndConnectSocket* dnsAndSock);
     void CancelDnsResolution();
     void Abandon();
     void CloseAll();
     nsresult SetupConn(nsAHttpTransaction* transaction, ConnectionEntry* ent,
                        nsresult status, uint32_t cap,
                        HttpConnectionBase** connection);
     [[nodiscard]] nsresult SetupStreams(DnsAndConnectSocket* dnsAndSock);
     nsresult ResolveHost(DnsAndConnectSocket* dnsAndSock);
     bool ShouldRetryDNS();
     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);
   void SetupBackupTimer();
   void CancelBackupTimer();
 
   bool IsPrimary(nsITransport* trans);
   bool IsPrimary(nsIAsyncOutputStream* out);
@@ -205,17 +214,17 @@ class DnsAndConnectSocket final : public
 
   void CheckProxyConfig();
   nsresult SetupDnsFlags(ConnectionEntry* ent);
   nsresult SetupEvent(SetupEvents event);
 
   RefPtr<nsAHttpTransaction> mTransaction;
   bool mDispatchedMTransaction = false;
 
-  TransportSetup mPrimaryTransport;
+  PrimaryTransportSetup mPrimaryTransport;
   uint32_t mCaps;
 
   // mSpeculative is set if the socket was created from
   // SpeculativeConnect(). It is cleared when a transaction would normally
   // start a new connection from scratch but instead finds this one in
   // the half open list and claims it for its own use. (which due to
   // the vagaries of scheduling from the pending queue might not actually
   // match up - but it prevents a speculative connection from opening
@@ -242,17 +251,17 @@ class DnsAndConnectSocket final : public
   // A DnsAndConnectSocket can be made for a concrete non-null transaction,
   // but the transaction can be dispatch to another connection. In that
   // case we can free this transaction to be claimed by other
   // transactions.
   bool mFreeToUse = true;
 
   RefPtr<nsHttpConnectionInfo> mConnInfo;
   nsCOMPtr<nsITimer> mSynTimer;
-  TransportSetup mBackupTransport;
+  BackupTransportSetup mBackupTransport;
 
   bool mIsHttp3;
 
   bool mSkipDnsResolution = false;
   bool mProxyNotTransparent = false;
   bool mProxyTransparentResolvesHost = false;
 };