Bug 1953331 - Generate WebTransport ID in a static function, r=jesup,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D241288
This commit is contained in:
Kershaw Chang
2025-03-14 09:43:48 +00:00
parent a21ebc0f8c
commit d26a1b29f5
4 changed files with 12 additions and 7 deletions

View File

@@ -7005,7 +7005,7 @@ nsresult nsHttpChannel::BeginConnect() {
wtconSettings->GetDedicated(&dedicated);
if (dedicated) {
connInfo->SetWebTransportId(
gHttpHandler->ConnMgr()->GenerateNewWebTransportId());
nsHttpConnectionInfo::GenerateNewWebTransportId());
}
} else {
connInfo = new nsHttpConnectionInfo(host, port, ""_ns, mUsername,

View File

@@ -72,6 +72,15 @@ nsHttpConnectionInfo::nsHttpConnectionInfo(
true, aIsHttp3, aWebTransport);
}
// static
uint64_t nsHttpConnectionInfo::GenerateNewWebTransportId() {
// Used for generating unique IDSs for dedicated connections, currently used
// by WebTransport
MOZ_ASSERT(XRE_IsParentProcess());
static Atomic<uint64_t> id(0);
return ++id;
}
void nsHttpConnectionInfo::Init(const nsACString& host, int32_t port,
const nsACString& npnToken,
const nsACString& username,

View File

@@ -276,6 +276,8 @@ class nsHttpConnectionInfo final : public ARefBase {
void SetEchConfig(const nsACString& aEchConfig) { mEchConfig = aEchConfig; }
const nsCString& GetEchConfig() const { return mEchConfig; }
static uint64_t GenerateNewWebTransportId();
private:
void Init(const nsACString& host, int32_t port, const nsACString& npnToken,
const nsACString& username, nsProxyInfo* proxyInfo,

View File

@@ -152,8 +152,6 @@ class nsHttpConnectionMgr final : public HttpConnectionMgrShell,
const nsTArray<RefPtr<nsIWebTransportHash>>* GetServerCertHashes(
nsHttpConnectionInfo* aConnInfo);
uint64_t GenerateNewWebTransportId() { return mMaxWebTransportId++; }
private:
virtual ~nsHttpConnectionMgr();
@@ -471,10 +469,6 @@ class nsHttpConnectionMgr final : public HttpConnectionMgrShell,
void NotifyConnectionOfBrowserIdChange(uint64_t previousId);
void CheckTransInPendingQueue(nsHttpTransaction* aTrans);
// Used for generating unique IDSs for dedicated connections, currently used
// by WebTransport
Atomic<uint64_t> mMaxWebTransportId{1};
};
} // namespace mozilla::net