PendingTransactionInfo.h (2108B)
1 /* vim:t ts=4 sw=2 sts=2 et cin: */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef PendingTransactionInfo_h__ 7 #define PendingTransactionInfo_h__ 8 9 #include "DnsAndConnectSocket.h" 10 11 namespace mozilla { 12 namespace net { 13 14 class PendingTransactionInfo final : public ARefBase { 15 public: 16 explicit PendingTransactionInfo(nsHttpTransaction* trans) 17 : mTransaction(trans) {} 18 19 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PendingTransactionInfo, override) 20 21 void PrintDiagnostics(nsCString& log); 22 23 // Return true if the transaction has claimed a DnsAndConnectSocket or 24 // a connection in TLS handshake phase. 25 bool IsAlreadyClaimedInitializingConn(); 26 27 // This function return a weak poointer to DnsAndConnectSocket. 28 // The pointer is used by the caller(ConnectionEntry) to remove the 29 // DnsAndConnectSocket from the internal list. PendingTransactionInfo 30 // cannot perform this opereation. 31 [[nodiscard]] nsWeakPtr ForgetDnsAndConnectSocketAndActiveConn(); 32 33 // Remember associated DnsAndConnectSocket. 34 void RememberDnsAndConnectSocket(DnsAndConnectSocket* sock); 35 // Similar as above, but for a ActiveConn that is performing a TLS handshake 36 // and has only a NullTransaction associated. 37 bool TryClaimingActiveConn(HttpConnectionBase* conn); 38 // It is similar as above, but in tihs case the halfOpen is made for this 39 // PendingTransactionInfo and it is already claimed. 40 void AddDnsAndConnectSocket(DnsAndConnectSocket* sock); 41 42 nsHttpTransaction* Transaction() const { return mTransaction; } 43 44 private: 45 RefPtr<nsHttpTransaction> mTransaction; 46 nsWeakPtr mDnsAndSock; 47 nsWeakPtr mActiveConn; 48 49 ~PendingTransactionInfo(); 50 }; 51 52 class PendingComparator { 53 public: 54 bool Equals(const PendingTransactionInfo* aPendingTrans, 55 const nsAHttpTransaction* aTrans) const { 56 return aPendingTrans->Transaction() == aTrans; 57 } 58 }; 59 60 } // namespace net 61 } // namespace mozilla 62 63 #endif // !PendingTransactionInfo_h__