Bug 1718082 - track current tab using browserId instead of top browsing context id for network prioritization purposes, r=nika,mconley,necko-reviewers,kershaw,valentin

Differential Revision: https://phabricator.services.mozilla.com/D171646
This commit is contained in:
Gijs Kruitbosch 2023-03-13 17:32:08 +00:00
parent 9e0531a790
commit f1911aef9a
49 changed files with 220 additions and 295 deletions

View File

@ -14,16 +14,6 @@ export class BrowserTabChild extends JSWindowActorChild {
super();
}
actorCreated() {
this.sendAsyncMessage("Browser:WindowCreated", {
userContextId: this.browsingContext.originAttributes.userContextId,
});
}
handleEvent(event) {
// DOMDocElementInserted is only used to create the actor.
}
receiveMessage(message) {
let context = this.manager.browsingContext;
let docShell = context.docShell;

View File

@ -1,24 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const { BrowserWindowTracker } = ChromeUtils.import(
"resource:///modules/BrowserWindowTracker.jsm"
);
export class BrowserTabParent extends JSWindowActorParent {
receiveMessage(message) {
let browsingContext = this.manager.browsingContext;
let browser = browsingContext.embedderElement;
if (!browser) {
return; // Can happen sometimes if browser is being destroyed
}
switch (message.name) {
case "Browser:WindowCreated": {
BrowserWindowTracker.windowCreated(browser);
break;
}
}
}
}

View File

@ -50,7 +50,6 @@ FINAL_TARGET_FILES.actors += [
"BlockedSiteParent.sys.mjs",
"BrowserProcessChild.sys.mjs",
"BrowserTabChild.sys.mjs",
"BrowserTabParent.sys.mjs",
"ClickHandlerChild.sys.mjs",
"ClickHandlerParent.sys.mjs",
"ContentSearchChild.sys.mjs",

View File

@ -32,7 +32,6 @@ const known_scripts = {
// Browser front-end
"resource:///actors/AboutReaderChild.sys.mjs",
"resource:///actors/BrowserTabChild.sys.mjs",
"resource:///actors/LinkHandlerChild.jsm",
"resource:///actors/SearchSERPTelemetryChild.sys.mjs",
"resource://gre/actors/ContentMetaChild.jsm",

View File

@ -418,15 +418,8 @@ let JSWINDOWACTORS = {
},
BrowserTab: {
parent: {
esModuleURI: "resource:///actors/BrowserTabParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/BrowserTabChild.sys.mjs",
events: {
DOMDocElementInserted: {},
},
},
messageManagerGroups: ["browsers"],

View File

@ -27,41 +27,39 @@ const WINDOW_EVENTS = ["activate", "unload"];
const DEBUG = false;
// Variables
var _lastTopBrowsingContextID = 0;
var _trackedWindows = [];
let _lastCurrentBrowserId = 0;
let _trackedWindows = [];
// Global methods
function debug(s) {
if (DEBUG) {
dump("-*- UpdateTopBrowsingContextIDHelper: " + s + "\n");
dump("-*- UpdateBrowserIDHelper: " + s + "\n");
}
}
function _updateCurrentBrowsingContextID(browser) {
function _updateCurrentBrowserId(browser) {
if (
!browser.browsingContext ||
browser.browsingContext.id === _lastTopBrowsingContextID ||
!browser.browserId ||
browser.browserId === _lastCurrentBrowserId ||
browser.ownerGlobal != _trackedWindows[0]
) {
return;
}
debug(
"Current window uri=" +
(browser.currentURI && browser.currentURI.spec) +
" browsing context id=" +
browser.browsingContext.id
);
// Guard on DEBUG here because materializing a long data URI into
// a JS string for concatenation is not free.
if (DEBUG) {
debug(
`Current window uri=${browser.currentURI?.spec} browser id=${browser.browserId}`
);
}
_lastTopBrowsingContextID = browser.browsingContext.id;
_lastCurrentBrowserId = browser.browserId;
let idWrapper = Cc["@mozilla.org/supports-PRUint64;1"].createInstance(
Ci.nsISupportsPRUint64
);
idWrapper.data = _lastTopBrowsingContextID;
Services.obs.notifyObservers(
idWrapper,
"net:current-top-browsing-context-id"
);
idWrapper.data = _lastCurrentBrowserId;
Services.obs.notifyObservers(idWrapper, "net:current-browser-id");
}
function _handleEvent(event) {
@ -71,11 +69,11 @@ function _handleEvent(event) {
event.target.ownerGlobal.gBrowser.selectedBrowser ===
event.target.linkedBrowser
) {
_updateCurrentBrowsingContextID(event.target.linkedBrowser);
_updateCurrentBrowserId(event.target.linkedBrowser);
}
break;
case "TabSelect":
_updateCurrentBrowsingContextID(event.target.linkedBrowser);
_updateCurrentBrowserId(event.target.linkedBrowser);
break;
case "activate":
WindowHelper.onActivate(event.target);
@ -121,7 +119,7 @@ var WindowHelper = {
_trackWindowOrder(window);
// Update the selected tab's content outer window ID.
_updateCurrentBrowsingContextID(window.gBrowser.selectedBrowser);
_updateCurrentBrowserId(window.gBrowser.selectedBrowser);
},
removeWindow(window) {
@ -145,7 +143,7 @@ var WindowHelper = {
_untrackWindowOrder(window);
_trackWindowOrder(window);
_updateCurrentBrowsingContextID(window.gBrowser.selectedBrowser);
_updateCurrentBrowserId(window.gBrowser.selectedBrowser);
},
};
@ -260,12 +258,6 @@ const BrowserWindowTracker = {
return win;
},
windowCreated(browser) {
if (browser === browser.ownerGlobal.gBrowser.selectedBrowser) {
_updateCurrentBrowsingContextID(browser);
}
},
/**
* Number of currently open browser windows.
*/

View File

@ -314,7 +314,7 @@ struct HttpChannelOpenArgs
uint64_t requestContextID;
uint64_t channelId;
uint64_t contentWindowId;
uint64_t topBrowsingContextId;
uint64_t browserId;
uint64_t earlyHintPreloaderId;
nsCString requestMethod;
ClassOfService classOfService;

View File

@ -86,7 +86,7 @@ already_AddRefed<HttpConnectionBase> ConnectionHandle::HttpConnection() {
return rv.forget();
}
void ConnectionHandle::TopBrowsingContextIdChanged(uint64_t id) {
void ConnectionHandle::CurrentBrowserIdChanged(uint64_t id) {
// Do nothing.
}

View File

@ -112,11 +112,10 @@ Http2PushedStream::Http2PushedStream(
Http2PushTransactionBuffer* aTransaction, Http2Session* aSession,
Http2StreamBase* aAssociatedStream, uint32_t aID,
uint64_t aCurrentForegroundTabOuterContentWindowId)
: Http2StreamBase(
(aTransaction->QueryHttpTransaction())
? aTransaction->QueryHttpTransaction()->TopBrowsingContextId()
: 0,
aSession, 0, aCurrentForegroundTabOuterContentWindowId),
: Http2StreamBase((aTransaction->QueryHttpTransaction())
? aTransaction->QueryHttpTransaction()->BrowserId()
: 0,
aSession, 0, aCurrentForegroundTabOuterContentWindowId),
mAssociatedTransaction(aAssociatedStream->Transaction()),
mBufferedPush(aTransaction),
mTransaction(aTransaction) {
@ -137,7 +136,7 @@ Http2PushedStream::Http2PushedStream(
// Assume we are on the same tab as our associated stream, for priority
// purposes. It's possible this could change when we get paired with a sink,
// but it's unlikely and doesn't much matter anyway.
mTransactionTabId = aAssociatedStream->TransactionTabId();
mTransactionBrowserId = aAssociatedStream->TransactionBrowserId();
}
bool Http2PushedStream::GetPushComplete() { return mPushCompleted; }
@ -336,23 +335,23 @@ nsresult Http2PushedStream::GetBufferedData(char* buf, uint32_t count,
return rv;
}
void Http2PushedStream::TopBrowsingContextIdChanged(uint64_t id) {
void Http2PushedStream::CurrentBrowserIdChanged(uint64_t id) {
if (mConsumerStream) {
// Pass through to our sink, who will handle things appropriately.
mConsumerStream->TopBrowsingContextIdChanged(id);
mConsumerStream->CurrentBrowserIdChanged(id);
return;
}
MOZ_ASSERT(gHttpHandler->ActiveTabPriority());
mCurrentTopBrowsingContextId = id;
mCurrentBrowserId = id;
RefPtr<Http2Session> session = Session();
if (!session->UseH2Deps()) {
return;
}
uint32_t oldDependency = mPriorityDependency;
if (mTransactionTabId != mCurrentTopBrowsingContextId) {
if (mTransactionBrowserId != mCurrentBrowserId) {
mPriorityDependency = Http2Session::kBackgroundGroupID;
nsHttp::NotifyActiveTabLoadOptimization();
} else {

View File

@ -72,7 +72,7 @@ class Http2PushedStream final : public Http2StreamBase {
// overload of Http2StreamBase
virtual bool HasSink() override { return !!mConsumerStream; }
void SetPushComplete() { mPushCompleted = true; }
virtual void TopBrowsingContextIdChanged(uint64_t) override;
virtual void CurrentBrowserIdChanged(uint64_t) override;
nsCString& GetRequestString() { return mRequestString; }
nsCString& GetResourceUrl() { return mResourceUrl; }

View File

@ -188,8 +188,7 @@ Http2Session::Http2Session(nsISocketTransport* aSocketTransport,
mPingThreshold = gHttpHandler->SpdyPingThreshold();
mPreviousPingThreshold = mPingThreshold;
mCurrentTopBrowsingContextId =
gHttpHandler->ConnMgr()->CurrentTopBrowsingContextId();
mCurrentBrowserId = gHttpHandler->ConnMgr()->CurrentBrowserId();
mEnableWebsockets = StaticPrefs::network_http_http2_websockets();
@ -514,8 +513,8 @@ void Http2Session::CreateStream(nsAHttpTransaction* aHttpTransaction,
RefPtr<Http2StreamBase> refStream;
switch (streamType) {
case Http2StreamBaseType::Normal:
refStream = new Http2Stream(aHttpTransaction, this, aPriority,
mCurrentTopBrowsingContextId);
refStream =
new Http2Stream(aHttpTransaction, this, aPriority, mCurrentBrowserId);
break;
case Http2StreamBaseType::WebSocket:
case Http2StreamBaseType::Tunnel:
@ -554,7 +553,7 @@ already_AddRefed<nsHttpConnection> Http2Session::CreateTunnelStream(
nsAHttpTransaction* aHttpTransaction, nsIInterfaceRequestor* aCallbacks,
PRIntervalTime aRtt, bool aIsWebSocket) {
RefPtr<Http2StreamTunnel> refStream = CreateTunnelStreamFromConnInfo(
this, mCurrentTopBrowsingContextId, aHttpTransaction->ConnectionInfo(),
this, mCurrentBrowserId, aHttpTransaction->ConnectionInfo(),
aIsWebSocket);
RefPtr<nsHttpConnection> newConn =
@ -1937,7 +1936,7 @@ nsresult Http2Session::RecvPushPromise(Http2Session* self) {
transactionBuffer->SetConnection(self);
RefPtr<Http2PushedStream> pushedStream(
new Http2PushedStream(transactionBuffer, self, associatedStream,
promisedID, self->mCurrentTopBrowsingContextId));
promisedID, self->mCurrentBrowserId));
rv = pushedStream->ConvertPushHeaders(&self->mDecompressor,
self->mDecompressBuffer,
@ -4434,13 +4433,13 @@ bool Http2Session::RealJoinConnection(const nsACString& hostname, int32_t port,
return joinedReturn;
}
void Http2Session::TopBrowsingContextIdChanged(uint64_t id) {
void Http2Session::CurrentBrowserIdChanged(uint64_t id) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
mCurrentTopBrowsingContextId = id;
mCurrentBrowserId = id;
for (const auto& stream : mStreamTransactionHash.Values()) {
stream->TopBrowsingContextIdChanged(id);
stream->CurrentBrowserIdChanged(id);
}
}

View File

@ -591,7 +591,7 @@ class Http2Session final : public ASpdySession,
nsTHashMap<nsCStringHashKey, bool> mJoinConnectionCache;
uint64_t mCurrentTopBrowsingContextId;
uint64_t mCurrentBrowserId;
uint32_t mCntActivated;

View File

@ -23,11 +23,10 @@ namespace mozilla::net {
Http2Stream::Http2Stream(nsAHttpTransaction* httpTransaction,
Http2Session* session, int32_t priority, uint64_t bcId)
: Http2StreamBase(
(httpTransaction->QueryHttpTransaction())
? httpTransaction->QueryHttpTransaction()->TopBrowsingContextId()
: 0,
session, priority, bcId),
: Http2StreamBase((httpTransaction->QueryHttpTransaction())
? httpTransaction->QueryHttpTransaction()->BrowserId()
: 0,
session, priority, bcId),
mTransaction(httpTransaction) {
LOG1(("Http2Stream::Http2Stream %p trans=%p", this, httpTransaction));
}

View File

@ -31,9 +31,9 @@
namespace mozilla::net {
Http2StreamBase::Http2StreamBase(uint64_t aTransactionTabId,
Http2StreamBase::Http2StreamBase(uint64_t aTransactionBrowserId,
Http2Session* session, int32_t priority,
uint64_t bcId)
uint64_t currentBrowserId)
: mSession(
do_GetWeakReference(static_cast<nsISupportsWeakReference*>(session))),
mRequestHeadersDone(0),
@ -41,8 +41,8 @@ Http2StreamBase::Http2StreamBase(uint64_t aTransactionTabId,
mAllHeadersReceived(0),
mQueued(0),
mSocketTransport(session->SocketTransport()),
mCurrentTopBrowsingContextId(bcId),
mTransactionTabId(aTransactionTabId),
mCurrentBrowserId(currentBrowserId),
mTransactionBrowserId(aTransactionBrowserId),
mTxInlineFrameSize(Http2Session::kDefaultBufferSize),
mChunkSize(session->SendingChunkSize()),
mRequestBlockedOnRead(0),
@ -954,7 +954,7 @@ void Http2StreamBase::UpdatePriorityDependency() {
mPriorityDependency = GetPriorityDependencyFromTransaction(trans);
if (gHttpHandler->ActiveTabPriority() &&
mTransactionTabId != mCurrentTopBrowsingContextId &&
mTransactionBrowserId != mCurrentBrowserId &&
mPriorityDependency != Http2Session::kUrgentStartGroupID) {
LOG3(
("Http2StreamBase::UpdatePriorityDependency %p "
@ -971,7 +971,7 @@ void Http2StreamBase::UpdatePriorityDependency() {
this, mPriorityDependency));
}
void Http2StreamBase::TopBrowsingContextIdChanged(uint64_t id) {
void Http2StreamBase::CurrentBrowserIdChanged(uint64_t id) {
if (!mStreamID) {
// For pushed streams, we ignore the direct call from the session and
// instead let it come to the internal function from the pushed stream, so
@ -979,18 +979,18 @@ void Http2StreamBase::TopBrowsingContextIdChanged(uint64_t id) {
return;
}
TopBrowsingContextIdChangedInternal(id);
CurrentBrowserIdChangedInternal(id);
}
void Http2StreamBase::TopBrowsingContextIdChangedInternal(uint64_t id) {
void Http2StreamBase::CurrentBrowserIdChangedInternal(uint64_t id) {
MOZ_ASSERT(gHttpHandler->ActiveTabPriority());
RefPtr<Http2Session> session = Session();
LOG3(
("Http2StreamBase::TopBrowsingContextIdChangedInternal "
"%p bcId=%" PRIx64 "\n",
("Http2StreamBase::CurrentBrowserIdChangedInternal "
"%p browserId=%" PRIx64 "\n",
this, id));
mCurrentTopBrowsingContextId = id;
mCurrentBrowserId = id;
if (!session->UseH2Deps()) {
return;
@ -1002,10 +1002,10 @@ void Http2StreamBase::TopBrowsingContextIdChangedInternal(uint64_t id) {
return;
}
if (mTransactionTabId != mCurrentTopBrowsingContextId) {
if (mTransactionBrowserId != mCurrentBrowserId) {
mPriorityDependency = Http2Session::kBackgroundGroupID;
LOG3(
("Http2StreamBase::TopBrowsingContextIdChangedInternal %p "
("Http2StreamBase::CurrentBrowserIdChangedInternal %p "
"move into background group.\n",
this));
@ -1018,7 +1018,7 @@ void Http2StreamBase::TopBrowsingContextIdChangedInternal(uint64_t id) {
mPriorityDependency = GetPriorityDependencyFromTransaction(trans);
LOG3(
("Http2StreamBase::TopBrowsingContextIdChangedInternal %p "
("Http2StreamBase::CurrentBrowserIdChangedInternal %p "
"depends on stream 0x%X\n",
this, mPriorityDependency));
}

View File

@ -145,7 +145,7 @@ class Http2StreamBase : public nsAHttpSegmentReader,
void SetPriorityDependency(uint32_t, uint32_t);
void UpdatePriorityDependency();
uint64_t TransactionTabId() { return mTransactionTabId; }
uint64_t TransactionBrowserId() { return mTransactionBrowserId; }
// A pull stream has an implicit sink, a pushed stream has a sink
// once it is matched to a pull stream.
@ -159,8 +159,8 @@ class Http2StreamBase : public nsAHttpSegmentReader,
nsresult GetOriginAttributes(mozilla::OriginAttributes* oa);
virtual void TopBrowsingContextIdChanged(uint64_t id);
void TopBrowsingContextIdChangedInternal(
virtual void CurrentBrowserIdChanged(uint64_t id);
void CurrentBrowserIdChangedInternal(
uint64_t id); // For use by pushed streams only
virtual bool IsTunnel() { return false; }
@ -260,8 +260,8 @@ class Http2StreamBase : public nsAHttpSegmentReader,
uint8_t mPriorityWeight = 0; // h2 weight
uint32_t mPriorityDependency = 0; // h2 stream id this one depends on
uint64_t mCurrentTopBrowsingContextId;
uint64_t mTransactionTabId{0};
uint64_t mCurrentBrowserId;
uint64_t mTransactionBrowserId{0};
// The InlineFrame and associated data is used for composing control
// frames and data frame headers.

View File

@ -67,8 +67,7 @@ Http3Session::Http3Session() {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("Http3Session::Http3Session [this=%p]", this));
mCurrentTopBrowsingContextId =
gHttpHandler->ConnMgr()->CurrentTopBrowsingContextId();
mCurrentBrowserId = gHttpHandler->ConnMgr()->CurrentBrowserId();
mThroughCaptivePortal = gHttpHandler->GetThroughCaptivePortal();
}
@ -974,8 +973,7 @@ bool Http3Session::AddStream(nsAHttpTransaction* aHttpTransaction,
mHasWebTransportSession = true;
} else {
LOG3(("Http3Session::AddStream %p atrans=%p.\n", this, aHttpTransaction));
stream = new Http3Stream(aHttpTransaction, this, cos,
mCurrentTopBrowsingContextId);
stream = new Http3Stream(aHttpTransaction, this, cos, mCurrentBrowserId);
}
mStreamTransactionHash.InsertOrUpdate(aHttpTransaction, RefPtr{stream});
@ -1830,15 +1828,15 @@ void Http3Session::CloseWebTransportConn() {
NS_DISPATCH_NORMAL);
}
void Http3Session::TopBrowsingContextIdChanged(uint64_t id) {
void Http3Session::CurrentBrowserIdChanged(uint64_t id) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
mCurrentTopBrowsingContextId = id;
mCurrentBrowserId = id;
for (const auto& stream : mStreamTransactionHash.Values()) {
RefPtr<Http3Stream> httpStream = stream->GetHttp3Stream();
if (httpStream) {
httpStream->TopBrowsingContextIdChanged(id);
httpStream->CurrentBrowserIdChanged(id);
}
}
}

View File

@ -285,7 +285,7 @@ class Http3Session final : public nsAHttpTransaction, public nsAHttpConnection {
// socket.
nsresult mSocketError{NS_OK};
bool mBeforeConnectedError{false};
uint64_t mCurrentTopBrowsingContextId;
uint64_t mCurrentBrowserId;
// True if the mTimer is inited and waiting for firing.
bool mTimerActive{false};

View File

@ -31,15 +31,15 @@ Http3StreamBase::~Http3StreamBase() = default;
Http3Stream::Http3Stream(nsAHttpTransaction* httpTransaction,
Http3Session* session, const ClassOfService& cos,
uint64_t bcId)
uint64_t currentBrowserId)
: Http3StreamBase(httpTransaction, session),
mCurrentTopBrowsingContextId(bcId) {
mCurrentBrowserId(currentBrowserId) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http3Stream::Http3Stream [this=%p]", this));
nsHttpTransaction* trans = mTransaction->QueryHttpTransaction();
if (trans) {
mTransactionTabId = trans->TopBrowsingContextId();
mTransactionBrowserId = trans->BrowserId();
}
SetPriority(cos.Flags());
@ -142,12 +142,12 @@ nsresult Http3Stream::TryActivating() {
mFlatHttpRequestHeaders, &mStreamId, this);
}
void Http3Stream::TopBrowsingContextIdChanged(uint64_t id) {
void Http3Stream::CurrentBrowserIdChanged(uint64_t id) {
MOZ_ASSERT(gHttpHandler->ActiveTabPriority());
bool previouslyFocused = (mCurrentTopBrowsingContextId == mTransactionTabId);
mCurrentTopBrowsingContextId = id;
bool nowFocused = (mCurrentTopBrowsingContextId == mTransactionTabId);
bool previouslyFocused = (mCurrentBrowserId == mTransactionBrowserId);
mCurrentBrowserId = id;
bool nowFocused = (mCurrentBrowserId == mTransactionBrowserId);
if (!StaticPrefs::
network_http_http3_send_background_tabs_deprioritization() ||
@ -514,7 +514,7 @@ uint8_t Http3Stream::PriorityUrgency() {
}
if (StaticPrefs::network_http_http3_send_background_tabs_deprioritization() &&
mCurrentTopBrowsingContextId != mTransactionTabId) {
mCurrentBrowserId != mTransactionBrowserId) {
// Low priority
return 6;
}

View File

@ -39,7 +39,7 @@ class Http3Stream final : public nsAHttpSegmentReader,
nsresult TryActivating();
void TopBrowsingContextIdChanged(uint64_t id);
void CurrentBrowserIdChanged(uint64_t id);
[[nodiscard]] nsresult ReadSegments() override;
[[nodiscard]] nsresult WriteSegments() override;
@ -137,8 +137,8 @@ class Http3Stream final : public nsAHttpSegmentReader,
nsCString mFlatHttpRequestHeaders;
bool mDataReceived{false};
nsTArray<uint8_t> mFlatResponseHeaders;
uint64_t mTransactionTabId{0};
uint64_t mCurrentTopBrowsingContextId;
uint64_t mTransactionBrowserId{0};
uint64_t mCurrentBrowserId;
uint8_t mPriorityUrgency{3}; // urgency field of http priority
bool mPriorityIncremental{false};

View File

@ -197,7 +197,7 @@ HttpBaseChannel::HttpBaseChannel()
mEncodedBodySize(0),
mRequestContextID(0),
mContentWindowId(0),
mTopBrowsingContextId(0),
mBrowserId(0),
mAltDataLength(-1),
mChannelId(0),
mReqContentLength(0U),
@ -1683,14 +1683,14 @@ NS_IMETHODIMP HttpBaseChannel::GetTopLevelContentWindowId(uint64_t* aWindowId) {
return NS_OK;
}
NS_IMETHODIMP HttpBaseChannel::SetTopBrowsingContextId(uint64_t aId) {
mTopBrowsingContextId = aId;
NS_IMETHODIMP HttpBaseChannel::SetBrowserId(uint64_t aId) {
mBrowserId = aId;
return NS_OK;
}
NS_IMETHODIMP HttpBaseChannel::GetTopBrowsingContextId(uint64_t* aId) {
EnsureTopBrowsingContextId();
*aId = mTopBrowsingContextId;
NS_IMETHODIMP HttpBaseChannel::GetBrowserId(uint64_t* aId) {
EnsureBrowserId();
*aId = mBrowserId;
return NS_OK;
}
@ -3300,17 +3300,15 @@ void HttpBaseChannel::AllowOpaqueResponseAfterSniff() {
void HttpBaseChannel::SetChannelBlockedByOpaqueResponse() {
mChannelBlockedByOpaqueResponse = true;
RefPtr<dom::CanonicalBrowsingContext> browsingContext =
dom::CanonicalBrowsingContext::Get(mTopBrowsingContextId);
RefPtr<dom::BrowsingContext> browsingContext =
dom::BrowsingContext::GetCurrentTopByBrowserId(mBrowserId);
if (!browsingContext) {
return;
}
dom::WindowGlobalParent* windowContext =
browsingContext->GetTopWindowContext();
dom::WindowContext* windowContext = browsingContext->GetTopWindowContext();
if (windowContext) {
windowContext->SetHasBlockedOpaqueResponse();
windowContext->Canonical()->SetHasBlockedOpaqueResponse();
}
}
@ -4832,7 +4830,7 @@ nsresult HttpBaseChannel::SetupReplacementChannel(nsIURI* newURI,
// When on the parent process, the channel can't attempt to get it itself.
// When on the child process, it would be waste to query it again.
rv = httpChannel->SetTopBrowsingContextId(mTopBrowsingContextId);
rv = httpChannel->SetBrowserId(mBrowserId);
MOZ_ASSERT(NS_SUCCEEDED(rv));
// Not setting this flag would break carrying permissions down to the child
@ -5642,16 +5640,16 @@ bool HttpBaseChannel::EnsureRequestContext() {
return static_cast<bool>(mRequestContext);
}
void HttpBaseChannel::EnsureTopBrowsingContextId() {
if (mTopBrowsingContextId) {
void HttpBaseChannel::EnsureBrowserId() {
if (mBrowserId) {
return;
}
RefPtr<dom::BrowsingContext> bc;
MOZ_ALWAYS_SUCCEEDS(mLoadInfo->GetBrowsingContext(getter_AddRefs(bc)));
if (bc && bc->Top()) {
mTopBrowsingContextId = bc->Top()->Id();
if (bc) {
mBrowserId = bc->GetBrowserId();
}
}

View File

@ -237,8 +237,8 @@ class HttpBaseChannel : public nsHashPropertyBag,
NS_IMETHOD SetChannelId(uint64_t aChannelId) override;
NS_IMETHOD GetTopLevelContentWindowId(uint64_t* aContentWindowId) override;
NS_IMETHOD SetTopLevelContentWindowId(uint64_t aContentWindowId) override;
NS_IMETHOD GetTopBrowsingContextId(uint64_t* aId) override;
NS_IMETHOD SetTopBrowsingContextId(uint64_t aId) override;
NS_IMETHOD GetBrowserId(uint64_t* aId) override;
NS_IMETHOD SetBrowserId(uint64_t aId) override;
NS_IMETHOD GetIsProxyUsed(bool* aIsProxyUsed) override;
using nsIClassifiedChannel::IsThirdPartyTrackingResource;
@ -774,7 +774,7 @@ class HttpBaseChannel : public nsHashPropertyBag,
// ID of the top-level document's inner window this channel is being
// originated from.
uint64_t mContentWindowId;
uint64_t mTopBrowsingContextId;
uint64_t mBrowserId;
int64_t mAltDataLength;
uint64_t mChannelId;
uint64_t mReqContentLength;
@ -1017,7 +1017,7 @@ class HttpBaseChannel : public nsHashPropertyBag,
void AddAsNonTailRequest();
void RemoveAsNonTailRequest();
void EnsureTopBrowsingContextId();
void EnsureBrowserId();
};
NS_DEFINE_STATIC_IID_ACCESSOR(HttpBaseChannel, HTTP_BASE_CHANNEL_IID)

View File

@ -1639,7 +1639,7 @@ HttpChannelChild::ConnectParent(uint32_t registrarId) {
if (browserChild) {
MOZ_ASSERT(browserChild->WebNavigation());
if (BrowsingContext* bc = browserChild->GetBrowsingContext()) {
mTopBrowsingContextId = bc->Top()->Id();
mBrowserId = bc->BrowserId();
}
}
@ -2168,7 +2168,7 @@ nsresult HttpChannelChild::ContinueAsyncOpen() {
}
}
if (BrowsingContext* bc = browserChild->GetBrowsingContext()) {
mTopBrowsingContextId = bc->Top()->Id();
mBrowserId = bc->BrowserId();
}
}
SetTopLevelContentWindowId(contentWindowId);
@ -2243,11 +2243,11 @@ nsresult HttpChannelChild::ContinueAsyncOpen() {
openArgs.integrityMetadata() = mIntegrityMetadata;
openArgs.contentWindowId() = contentWindowId;
openArgs.topBrowsingContextId() = mTopBrowsingContextId;
openArgs.browserId() = mBrowserId;
LOG(("HttpChannelChild::ContinueAsyncOpen this=%p gid=%" PRIu64
" top bid=%" PRIx64,
this, mChannelId, mTopBrowsingContextId));
" browser id=%" PRIx64,
this, mChannelId, mBrowserId));
if (browserChild && !browserChild->IPCOpen()) {
return NS_ERROR_FAILURE;

View File

@ -136,12 +136,12 @@ bool HttpChannelParent::Init(const HttpChannelCreationArgs& aArgs) {
a.blockAuthPrompt(), a.allowStaleCacheContent(),
a.preferCacheLoadOverBypass(), a.contentTypeHint(), a.requestMode(),
a.redirectMode(), a.channelId(), a.integrityMetadata(),
a.contentWindowId(), a.preferredAlternativeTypes(),
a.topBrowsingContextId(), a.launchServiceWorkerStart(),
a.launchServiceWorkerEnd(), a.dispatchFetchEventStart(),
a.dispatchFetchEventEnd(), a.handleFetchEventStart(),
a.handleFetchEventEnd(), a.forceMainDocumentChannel(),
a.navigationStartTimeStamp(), a.earlyHintPreloaderId());
a.contentWindowId(), a.preferredAlternativeTypes(), a.browserId(),
a.launchServiceWorkerStart(), a.launchServiceWorkerEnd(),
a.dispatchFetchEventStart(), a.dispatchFetchEventEnd(),
a.handleFetchEventStart(), a.handleFetchEventEnd(),
a.forceMainDocumentChannel(), a.navigationStartTimeStamp(),
a.earlyHintPreloaderId());
}
case HttpChannelCreationArgs::THttpChannelConnectArgs: {
const HttpChannelConnectArgs& cArgs = aArgs.get_HttpChannelConnectArgs();
@ -396,8 +396,7 @@ bool HttpChannelParent::DoAsyncOpen(
const nsString& aIntegrityMetadata, const uint64_t& aContentWindowId,
const nsTArray<PreferredAlternativeDataTypeParams>&
aPreferredAlternativeTypes,
const uint64_t& aTopBrowsingContextId,
const TimeStamp& aLaunchServiceWorkerStart,
const uint64_t& aBrowserId, const TimeStamp& aLaunchServiceWorkerStart,
const TimeStamp& aLaunchServiceWorkerEnd,
const TimeStamp& aDispatchFetchEventStart,
const TimeStamp& aDispatchFetchEventEnd,
@ -436,9 +435,8 @@ bool HttpChannelParent::DoAsyncOpen(
}
LOG(("HttpChannelParent RecvAsyncOpen [this=%p uri=%s, gid=%" PRIu64
" top bid=%" PRIx64 "]\n",
this, aURI->GetSpecOrDefault().get(), aChannelId,
aTopBrowsingContextId));
" browserid=%" PRIx64 "]\n",
this, aURI->GetSpecOrDefault().get(), aChannelId, aBrowserId));
nsresult rv;
@ -479,7 +477,7 @@ bool HttpChannelParent::DoAsyncOpen(
// Set the channelId allocated in child to the parent instance
httpChannel->SetChannelId(aChannelId);
httpChannel->SetTopLevelContentWindowId(aContentWindowId);
httpChannel->SetTopBrowsingContextId(aTopBrowsingContextId);
httpChannel->SetBrowserId(aBrowserId);
httpChannel->SetIntegrityMetadata(aIntegrityMetadata);

View File

@ -162,8 +162,7 @@ class HttpChannelParent final : public nsIInterfaceRequestor,
const uint64_t& aContentWindowId,
const nsTArray<PreferredAlternativeDataTypeParams>&
aPreferredAlternativeTypes,
const uint64_t& aTopBrowsingContextId,
const TimeStamp& aLaunchServiceWorkerStart,
const uint64_t& aBrowserId, const TimeStamp& aLaunchServiceWorkerStart,
const TimeStamp& aLaunchServiceWorkerEnd,
const TimeStamp& aDispatchFetchEventStart,
const TimeStamp& aDispatchFetchEventEnd,

View File

@ -48,10 +48,9 @@ HttpConnectionMgrChild::RecvDoShiftReloadConnectionCleanupWithConnInfo(
return IPC_OK();
}
mozilla::ipc::IPCResult
HttpConnectionMgrChild::RecvUpdateCurrentTopBrowsingContextId(
mozilla::ipc::IPCResult HttpConnectionMgrChild::RecvUpdateCurrentBrowserId(
const uint64_t& aId) {
mConnMgr->UpdateCurrentTopBrowsingContextId(aId);
mConnMgr->UpdateCurrentBrowserId(aId);
return IPC_OK();
}

View File

@ -22,8 +22,7 @@ class HttpConnectionMgrChild final : public PHttpConnectionMgrChild {
mozilla::ipc::IPCResult RecvDoShiftReloadConnectionCleanupWithConnInfo(
const HttpConnectionInfoCloneArgs& aArgs);
mozilla::ipc::IPCResult RecvUpdateCurrentTopBrowsingContextId(
const uint64_t& aId);
mozilla::ipc::IPCResult RecvUpdateCurrentBrowserId(const uint64_t& aId);
mozilla::ipc::IPCResult RecvAddTransaction(PHttpTransactionChild* aTrans,
const int32_t& aPriority);
mozilla::ipc::IPCResult RecvAddTransactionWithStickyConn(

View File

@ -131,11 +131,10 @@ void HttpConnectionMgrParent::PrintDiagnostics() {
// socket process.
}
nsresult HttpConnectionMgrParent::UpdateCurrentTopBrowsingContextId(
uint64_t aId) {
nsresult HttpConnectionMgrParent::UpdateCurrentBrowserId(uint64_t aId) {
RefPtr<HttpConnectionMgrParent> self = this;
auto task = [self, aId]() {
Unused << self->SendUpdateCurrentTopBrowsingContextId(aId);
Unused << self->SendUpdateCurrentBrowserId(aId);
};
gIOService->CallOrWaitForSocketProcess(std::move(task));
return NS_OK;

View File

@ -97,7 +97,7 @@ class HttpConnectionMgrShell : public nsISupports {
// printed to the javascript console
virtual void PrintDiagnostics() = 0;
virtual nsresult UpdateCurrentTopBrowsingContextId(uint64_t aId) = 0;
virtual nsresult UpdateCurrentBrowserId(uint64_t aId) = 0;
// adds a transaction to the list of managed transactions.
[[nodiscard]] virtual nsresult AddTransaction(HttpTransactionShell*,
@ -195,7 +195,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(HttpConnectionMgrShell,
virtual void AbortAndCloseAllConnections(int32_t, ARefBase*) override; \
virtual nsresult UpdateParam(nsParamName name, uint16_t value) override; \
virtual void PrintDiagnostics() override; \
virtual nsresult UpdateCurrentTopBrowsingContextId(uint64_t aId) override; \
virtual nsresult UpdateCurrentBrowserId(uint64_t aId) override; \
virtual nsresult AddTransaction(HttpTransactionShell*, int32_t priority) \
override; \
virtual nsresult AddTransactionWithStickyConn( \

View File

@ -68,9 +68,9 @@ nsresult HttpTransactionChild::InitInternal(
uint32_t caps, const HttpConnectionInfoCloneArgs& infoArgs,
nsHttpRequestHead* requestHead, nsIInputStream* requestBody,
uint64_t requestContentLength, bool requestBodyHasHeaders,
uint64_t topLevelOuterContentWindowId, uint8_t httpTrafficCategory,
uint64_t requestContextID, ClassOfService classOfService,
uint32_t initialRwin, bool responseTimeoutEnabled, uint64_t channelId,
uint64_t browserId, uint8_t httpTrafficCategory, uint64_t requestContextID,
ClassOfService classOfService, uint32_t initialRwin,
bool responseTimeoutEnabled, uint64_t channelId,
bool aHasTransactionObserver,
const Maybe<H2PushedStreamArg>& aPushedStreamArg) {
LOG(("HttpTransactionChild::InitInternal [this=%p caps=%x]\n", this, caps));
@ -118,10 +118,10 @@ nsresult HttpTransactionChild::InitInternal(
caps, cinfo, requestHead, requestBody, requestContentLength,
requestBodyHasHeaders, GetCurrentSerialEventTarget(),
nullptr, // TODO: security callback, fix in bug 1512479.
this, topLevelOuterContentWindowId,
static_cast<HttpTrafficCategory>(httpTrafficCategory), rc, classOfService,
initialRwin, responseTimeoutEnabled, channelId, std::move(observer),
std::move(pushCallback), transWithPushedStream, pushedStreamId);
this, browserId, static_cast<HttpTrafficCategory>(httpTrafficCategory),
rc, classOfService, initialRwin, responseTimeoutEnabled, channelId,
std::move(observer), std::move(pushCallback), transWithPushedStream,
pushedStreamId);
if (NS_WARN_IF(NS_FAILED(rv))) {
mTransaction = nullptr;
return rv;

View File

@ -88,7 +88,7 @@ nsresult HttpTransactionParent::Init(
nsIInputStream* requestBody, uint64_t requestContentLength,
bool requestBodyHasHeaders, nsIEventTarget* target,
nsIInterfaceRequestor* callbacks, nsITransportEventSink* eventsink,
uint64_t topLevelOuterContentWindowId, HttpTrafficCategory trafficCategory,
uint64_t browserId, HttpTrafficCategory trafficCategory,
nsIRequestContext* requestContext, ClassOfService classOfService,
uint32_t initialRwin, bool responseTimeoutEnabled, uint64_t channelId,
TransactionObserverFunc&& transactionObserver,
@ -147,7 +147,7 @@ nsresult HttpTransactionParent::Init(
// TODO: Figure out if we have to implement nsIThreadRetargetableRequest in
// bug 1544378.
if (!SendInit(caps, infoArgs, *requestHead, ipcStream, requestContentLength,
requestBodyHasHeaders, topLevelOuterContentWindowId,
requestBodyHasHeaders, browserId,
static_cast<uint8_t>(trafficCategory), requestContextID,
classOfService, initialRwin, responseTimeoutEnabled, mChannelId,
!!mTransactionObserver, pushedStreamArg, throttleQueue,

View File

@ -73,15 +73,15 @@ class HttpTransactionShell : public nsISupports {
// the dispatch target were notifications should be sent.
// @param callbacks
// the notification callbacks to be given to PSM.
// @param topBrowsingContextId
// indicate the id of the top browsing context in which
// this transaction is being loaded.
// @param browserId
// indicate the id of the browser in which this transaction is being
// loaded.
[[nodiscard]] nsresult virtual Init(
uint32_t caps, nsHttpConnectionInfo* connInfo,
nsHttpRequestHead* reqHeaders, nsIInputStream* reqBody,
uint64_t reqContentLength, bool reqBodyIncludesHeaders,
nsIEventTarget* consumerTarget, nsIInterfaceRequestor* callbacks,
nsITransportEventSink* eventsink, uint64_t topBrowsingContextId,
nsITransportEventSink* eventsink, uint64_t browserId,
HttpTrafficCategory trafficCategory, nsIRequestContext* requestContext,
ClassOfService classOfService, uint32_t initialRwin,
bool responseTimeoutEnabled, uint64_t channelId,
@ -177,7 +177,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(HttpTransactionShell, HTTPTRANSACTIONSHELL_IID)
nsHttpRequestHead* reqHeaders, nsIInputStream* reqBody, \
uint64_t reqContentLength, bool reqBodyIncludesHeaders, \
nsIEventTarget* consumerTarget, nsIInterfaceRequestor* callbacks, \
nsITransportEventSink* eventsink, uint64_t topBrowsingContextId, \
nsITransportEventSink* eventsink, uint64_t browserId, \
HttpTrafficCategory trafficCategory, nsIRequestContext* requestContext, \
ClassOfService classOfService, uint32_t initialRwin, \
bool responseTimeoutEnabled, uint64_t channelId, \

View File

@ -73,14 +73,10 @@ NullHttpChannel::SetTopLevelContentWindowId(uint64_t aWindowId) {
}
NS_IMETHODIMP
NullHttpChannel::GetTopBrowsingContextId(uint64_t*) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NullHttpChannel::GetBrowserId(uint64_t*) { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHODIMP
NullHttpChannel::SetTopBrowsingContextId(uint64_t) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NullHttpChannel::SetBrowserId(uint64_t) { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHODIMP
NullHttpChannel::GetTransferSize(uint64_t* aTransferSize) {

View File

@ -55,7 +55,7 @@ class NullHttpTransaction : public nsAHttpTransaction {
// nsHalfOpenSocket could be either nsHttpTransaction or NullHttpTransaction.
// NullHttpTransaction will be activated on the connection immediately after
// creation and be never put in a pending queue, so it's OK to just return 0.
uint64_t TopBrowsingContextId() override { return 0; }
uint64_t BrowserId() override { return 0; }
TimingStruct Timings() { return mTimings; }

View File

@ -54,13 +54,13 @@ ObliviousHttpChannel::SetTopLevelContentWindowId(uint64_t aWindowId) {
}
NS_IMETHODIMP
ObliviousHttpChannel::GetTopBrowsingContextId(uint64_t* aWindowId) {
return mInnerChannel->GetTopBrowsingContextId(aWindowId);
ObliviousHttpChannel::GetBrowserId(uint64_t* aWindowId) {
return mInnerChannel->GetBrowserId(aWindowId);
}
NS_IMETHODIMP
ObliviousHttpChannel::SetTopBrowsingContextId(uint64_t aId) {
return mInnerChannel->SetTopBrowsingContextId(aId);
ObliviousHttpChannel::SetBrowserId(uint64_t aId) {
return mInnerChannel->SetBrowserId(aId);
}
NS_IMETHODIMP

View File

@ -26,7 +26,7 @@ child:
async __delete__();
async DoShiftReloadConnectionCleanupWithConnInfo(HttpConnectionInfoCloneArgs aArgs);
async UpdateCurrentTopBrowsingContextId(uint64_t aId);
async UpdateCurrentBrowserId(uint64_t aId);
async AddTransaction(PHttpTransaction aTrans, int32_t aPriority);
async AddTransactionWithStickyConn(PHttpTransaction aTrans, int32_t aPriority,
PHttpTransaction aTransWithStickyConn);

View File

@ -20,8 +20,7 @@ namespace mozilla {
namespace net {
static uint64_t TabIdForQueuing(nsAHttpTransaction* transaction) {
return gHttpHandler->ActiveTabPriority() ? transaction->TopBrowsingContextId()
: 0;
return gHttpHandler->ActiveTabPriority() ? transaction->BrowserId() : 0;
}
// This function decides the transaction's order in the pending queue.
@ -51,7 +50,7 @@ void PendingTransactionQueue::InsertTransactionNormal(
LOG(
("PendingTransactionQueue::InsertTransactionNormal"
" trans=%p, bid=%" PRIu64 "\n",
info->Transaction(), info->Transaction()->TopBrowsingContextId()));
info->Transaction(), info->Transaction()->BrowserId()));
uint64_t windowId = TabIdForQueuing(info->Transaction());
nsTArray<RefPtr<PendingTransactionInfo>>* const infoArray =

View File

@ -680,7 +680,7 @@ nsresult TRRServiceChannel::SetupTransaction() {
rv = mTransaction->Init(
mCaps, mConnectionInfo, &mRequestHead, mUploadStream, mReqContentLength,
LoadUploadStreamHasHeaders(), mCurrentEventTarget, callbacks, this,
mTopBrowsingContextId, HttpTrafficCategory::eInvalid, mRequestContext,
mBrowserId, HttpTrafficCategory::eInvalid, mRequestContext,
mClassOfService, mInitialRwin, LoadResponseTimeoutEnabled(), mChannelId,
nullptr, std::move(pushCallback), mTransWithPushedStream,
mPushedStreamId);

View File

@ -159,7 +159,7 @@ class nsAHttpConnection : public nsISupports {
virtual HttpVersion Version() = 0;
// A notification of the current active tab id change.
virtual void TopBrowsingContextIdChanged(uint64_t id) = 0;
virtual void CurrentBrowserIdChanged(uint64_t id) = 0;
// categories set by nsHttpTransaction to identify how this connection is
// being used.
@ -190,7 +190,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsAHttpConnection, NS_AHTTPCONNECTION_IID)
[[nodiscard]] nsresult PushBack(const char*, uint32_t) override; \
already_AddRefed<HttpConnectionBase> TakeHttpConnection() override; \
already_AddRefed<HttpConnectionBase> HttpConnection() override; \
void TopBrowsingContextIdChanged(uint64_t id) override; \
void CurrentBrowserIdChanged(uint64_t id) override; \
/* \
Thes methods below have automatic definitions that just forward the \
function to a lower level connection object \

View File

@ -209,7 +209,7 @@ class nsAHttpTransaction : public nsSupportsWeakReference {
return NS_ERROR_NOT_IMPLEMENTED;
}
virtual uint64_t TopBrowsingContextId() {
virtual uint64_t BrowserId() {
MOZ_ASSERT(false);
return 0;
}

View File

@ -1375,7 +1375,7 @@ nsresult nsHttpChannel::SetupTransaction() {
};
}
EnsureTopBrowsingContextId();
EnsureBrowserId();
EnsureRequestContext();
HttpTrafficCategory category = CreateTrafficCategory();
@ -1391,7 +1391,7 @@ nsresult nsHttpChannel::SetupTransaction() {
rv = mTransaction->Init(
mCaps, mConnectionInfo, &mRequestHead, mUploadStream, mReqContentLength,
LoadUploadStreamHasHeaders(), GetCurrentSerialEventTarget(), callbacks,
this, mTopBrowsingContextId, category, mRequestContext, mClassOfService,
this, mBrowserId, category, mRequestContext, mClassOfService,
mInitialRwin, LoadResponseTimeoutEnabled(), mChannelId,
std::move(observer), std::move(pushCallback), mTransWithPushedStream,
mPushedStreamId);

View File

@ -1069,12 +1069,12 @@ void nsHttpConnectionMgr::PreparePendingQForDispatching(
// Only need to dispatch transactions for either focused or
// non-focused window because considerAll is false.
if (!considerAll) {
ent->AppendPendingQForFocusedWindow(mCurrentTopBrowsingContextId, pendingQ,
ent->AppendPendingQForFocusedWindow(mCurrentBrowserId, pendingQ,
maxFocusedWindowConnections);
if (pendingQ.IsEmpty()) {
ent->AppendPendingQForNonFocusedWindows(mCurrentTopBrowsingContextId,
pendingQ, availableConnections);
ent->AppendPendingQForNonFocusedWindows(mCurrentBrowserId, pendingQ,
availableConnections);
}
return;
}
@ -1083,13 +1083,12 @@ void nsHttpConnectionMgr::PreparePendingQForDispatching(
availableConnections - maxFocusedWindowConnections;
nsTArray<RefPtr<PendingTransactionInfo>> remainingPendingQ;
ent->AppendPendingQForFocusedWindow(mCurrentTopBrowsingContextId, pendingQ,
ent->AppendPendingQForFocusedWindow(mCurrentBrowserId, pendingQ,
maxFocusedWindowConnections);
if (maxNonFocusedWindowConnections) {
ent->AppendPendingQForNonFocusedWindows(mCurrentTopBrowsingContextId,
remainingPendingQ,
maxNonFocusedWindowConnections);
ent->AppendPendingQForNonFocusedWindows(
mCurrentBrowserId, remainingPendingQ, maxNonFocusedWindowConnections);
}
// If the slots for either focused or non-focused window are not filled up
@ -1097,11 +1096,11 @@ void nsHttpConnectionMgr::PreparePendingQForDispatching(
// for the other slot (with preference for the focused window).
if (remainingPendingQ.Length() < maxNonFocusedWindowConnections) {
ent->AppendPendingQForFocusedWindow(
mCurrentTopBrowsingContextId, pendingQ,
mCurrentBrowserId, pendingQ,
maxNonFocusedWindowConnections - remainingPendingQ.Length());
} else if (pendingQ.Length() < maxFocusedWindowConnections) {
ent->AppendPendingQForNonFocusedWindows(
mCurrentTopBrowsingContextId, remainingPendingQ,
mCurrentBrowserId, remainingPendingQ,
maxFocusedWindowConnections - pendingQ.Length());
}
@ -2729,10 +2728,10 @@ class UINT64Wrapper : public ARefBase {
virtual ~UINT64Wrapper() = default;
};
nsresult nsHttpConnectionMgr::UpdateCurrentTopBrowsingContextId(uint64_t aId) {
nsresult nsHttpConnectionMgr::UpdateCurrentBrowserId(uint64_t aId) {
RefPtr<UINT64Wrapper> idWrapper = new UINT64Wrapper(aId);
return PostEvent(&nsHttpConnectionMgr::OnMsgUpdateCurrentTopBrowsingContextId,
0, idWrapper);
return PostEvent(&nsHttpConnectionMgr::OnMsgUpdateCurrentBrowserId, 0,
idWrapper);
}
void nsHttpConnectionMgr::SetThrottlingEnabled(bool aEnable) {
@ -2780,9 +2779,9 @@ void nsHttpConnectionMgr::LogActiveTransactions(char operation) {
nsTArray<RefPtr<nsHttpTransaction>>* trs = nullptr;
uint32_t au, at, bu = 0, bt = 0;
trs = mActiveTransactions[false].Get(mCurrentTopBrowsingContextId);
trs = mActiveTransactions[false].Get(mCurrentBrowserId);
au = trs ? trs->Length() : 0;
trs = mActiveTransactions[true].Get(mCurrentTopBrowsingContextId);
trs = mActiveTransactions[true].Get(mCurrentBrowserId);
at = trs ? trs->Length() : 0;
for (const auto& data : mActiveTransactions[false].Values()) {
@ -2805,7 +2804,7 @@ void nsHttpConnectionMgr::LogActiveTransactions(char operation) {
void nsHttpConnectionMgr::AddActiveTransaction(nsHttpTransaction* aTrans) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
uint64_t tabId = aTrans->TopBrowsingContextId();
uint64_t tabId = aTrans->BrowserId();
bool throttled = aTrans->EligibleForThrottling();
nsTArray<RefPtr<nsHttpTransaction>>* transactions =
@ -2817,10 +2816,10 @@ void nsHttpConnectionMgr::AddActiveTransaction(nsHttpTransaction* aTrans) {
LOG(("nsHttpConnectionMgr::AddActiveTransaction t=%p tabid=%" PRIx64
"(%d) thr=%d",
aTrans, tabId, tabId == mCurrentTopBrowsingContextId, throttled));
aTrans, tabId, tabId == mCurrentBrowserId, throttled));
LogActiveTransactions('+');
if (tabId == mCurrentTopBrowsingContextId) {
if (tabId == mCurrentBrowserId) {
mActiveTabTransactionsExist = true;
if (!throttled) {
mActiveTabUnthrottledTransactionsExist = true;
@ -2846,8 +2845,8 @@ void nsHttpConnectionMgr::RemoveActiveTransaction(
nsHttpTransaction* aTrans, Maybe<bool> const& aOverride) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
uint64_t tabId = aTrans->TopBrowsingContextId();
bool forActiveTab = tabId == mCurrentTopBrowsingContextId;
uint64_t tabId = aTrans->BrowserId();
bool forActiveTab = tabId == mCurrentBrowserId;
bool throttled = aOverride.valueOr(aTrans->EligibleForThrottling());
nsTArray<RefPtr<nsHttpTransaction>>* transactions =
@ -2926,7 +2925,7 @@ void nsHttpConnectionMgr::RemoveActiveTransaction(
// active tab we can wake the throttled transactions for the active tab.
if (forActiveTab && !throttled) {
LOG((" resuming throttled for active tab"));
ResumeReadOf(mActiveTransactions[true].Get(mCurrentTopBrowsingContextId));
ResumeReadOf(mActiveTransactions[true].Get(mCurrentBrowserId));
}
return;
}
@ -2983,8 +2982,8 @@ bool nsHttpConnectionMgr::ShouldThrottle(nsHttpTransaction* aTrans) {
}
}
uint64_t tabId = aTrans->TopBrowsingContextId();
bool forActiveTab = tabId == mCurrentTopBrowsingContextId;
uint64_t tabId = aTrans->BrowserId();
bool forActiveTab = tabId == mCurrentBrowserId;
bool throttled = aTrans->EligibleForThrottling();
bool stop = [=]() {
@ -3065,7 +3064,7 @@ bool nsHttpConnectionMgr::IsConnEntryUnderPressure(
return false;
}
return ent->PendingQueueLengthForWindow(mCurrentTopBrowsingContextId) > 0;
return ent->PendingQueueLengthForWindow(mCurrentBrowserId) > 0;
}
bool nsHttpConnectionMgr::IsThrottleTickerNeeded() {
@ -3257,7 +3256,7 @@ void nsHttpConnectionMgr::ResumeReadOf(
hashtable,
bool excludeForActiveTab) {
for (const auto& entry : hashtable) {
if (excludeForActiveTab && entry.GetKey() == mCurrentTopBrowsingContextId) {
if (excludeForActiveTab && entry.GetKey() == mCurrentBrowserId) {
// These have never been throttled (never stopped reading)
continue;
}
@ -3274,7 +3273,7 @@ void nsHttpConnectionMgr::ResumeReadOf(
}
}
void nsHttpConnectionMgr::NotifyConnectionOfBrowsingContextIdChange(
void nsHttpConnectionMgr::NotifyConnectionOfBrowserIdChange(
uint64_t previousId) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
@ -3298,54 +3297,54 @@ void nsHttpConnectionMgr::NotifyConnectionOfBrowsingContextIdChange(
// Get unthrottled transactions with the previous and current window id.
transactions = mActiveTransactions[false].Get(previousId);
addConnectionHelper(transactions);
transactions = mActiveTransactions[false].Get(mCurrentTopBrowsingContextId);
transactions = mActiveTransactions[false].Get(mCurrentBrowserId);
addConnectionHelper(transactions);
// Get throttled transactions with the previous and current window id.
transactions = mActiveTransactions[true].Get(previousId);
addConnectionHelper(transactions);
transactions = mActiveTransactions[true].Get(mCurrentTopBrowsingContextId);
transactions = mActiveTransactions[true].Get(mCurrentBrowserId);
addConnectionHelper(transactions);
for (const auto& conn : connections) {
conn->TopBrowsingContextIdChanged(mCurrentTopBrowsingContextId);
conn->CurrentBrowserIdChanged(mCurrentBrowserId);
}
}
void nsHttpConnectionMgr::OnMsgUpdateCurrentTopBrowsingContextId(
int32_t aLoading, ARefBase* param) {
void nsHttpConnectionMgr::OnMsgUpdateCurrentBrowserId(int32_t aLoading,
ARefBase* param) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
uint64_t id = static_cast<UINT64Wrapper*>(param)->GetValue();
if (mCurrentTopBrowsingContextId == id) {
if (mCurrentBrowserId == id) {
// duplicate notification
return;
}
bool activeTabWasLoading = mActiveTabTransactionsExist;
uint64_t previousId = mCurrentTopBrowsingContextId;
mCurrentTopBrowsingContextId = id;
uint64_t previousId = mCurrentBrowserId;
mCurrentBrowserId = id;
if (gHttpHandler->ActiveTabPriority()) {
NotifyConnectionOfBrowsingContextIdChange(previousId);
NotifyConnectionOfBrowserIdChange(previousId);
}
LOG(
("nsHttpConnectionMgr::OnMsgUpdateCurrentTopBrowsingContextId"
("nsHttpConnectionMgr::OnMsgUpdateCurrentBrowserId"
" id=%" PRIx64 "\n",
mCurrentTopBrowsingContextId));
mCurrentBrowserId));
nsTArray<RefPtr<nsHttpTransaction>>* transactions = nullptr;
// Update the "Exists" caches and resume any transactions that now deserve it,
// changing the active tab changes the conditions for throttling.
transactions = mActiveTransactions[false].Get(mCurrentTopBrowsingContextId);
transactions = mActiveTransactions[false].Get(mCurrentBrowserId);
mActiveTabUnthrottledTransactionsExist = !!transactions;
if (!mActiveTabUnthrottledTransactionsExist) {
transactions = mActiveTransactions[true].Get(mCurrentTopBrowsingContextId);
transactions = mActiveTransactions[true].Get(mCurrentBrowserId);
}
mActiveTabTransactionsExist = !!transactions;

View File

@ -126,9 +126,7 @@ class nsHttpConnectionMgr final : public HttpConnectionMgrShell,
// NOTE: relatively expensive to call, there are two hashtable lookups.
bool IsConnEntryUnderPressure(nsHttpConnectionInfo*);
uint64_t CurrentTopBrowsingContextId() {
return mCurrentTopBrowsingContextId;
}
uint64_t CurrentBrowserId() { return mCurrentBrowserId; }
void DoFallbackConnection(SpeculativeTransaction* aTrans, bool aFetchHTTPSRR);
void DoSpeculativeConnection(SpeculativeTransaction* aTrans,
@ -329,7 +327,7 @@ class nsHttpConnectionMgr final : public HttpConnectionMgrShell,
void OnMsgUpdateRequestTokenBucket(int32_t, ARefBase*);
void OnMsgVerifyTraffic(int32_t, ARefBase*);
void OnMsgPruneNoTraffic(int32_t, ARefBase*);
void OnMsgUpdateCurrentTopBrowsingContextId(int32_t, ARefBase*);
void OnMsgUpdateCurrentBrowserId(int32_t, ARefBase*);
void OnMsgClearConnectionHistory(int32_t, ARefBase*);
// Total number of active connections in all of the ConnectionEntry objects
@ -376,7 +374,7 @@ class nsHttpConnectionMgr final : public HttpConnectionMgrShell,
void OnMsgPrintDiagnostics(int32_t, ARefBase*);
nsCString mLogData;
uint64_t mCurrentTopBrowsingContextId{0};
uint64_t mCurrentBrowserId{0};
// Called on a pref change
void SetThrottlingEnabled(bool aEnable);
@ -453,10 +451,10 @@ class nsHttpConnectionMgr final : public HttpConnectionMgrShell,
// When current active tab is changed, this function uses
// |previousId| to select background transactions and
// |mCurrentTopBrowsingContextId| to select foreground transactions.
// |mCurrentBrowserId| to select foreground transactions.
// Then, it notifies selected transactions' connection of the new active tab
// id.
void NotifyConnectionOfBrowsingContextIdChange(uint64_t previousId);
void NotifyConnectionOfBrowserIdChange(uint64_t previousId);
void CheckTransInPendingQueue(nsHttpTransaction* aTrans);
};

View File

@ -490,8 +490,7 @@ nsresult nsHttpHandler::Init() {
obsService->AddObserver(this, "network:socket-process-crashed", true);
if (!IsNeckoChild()) {
obsService->AddObserver(this, "net:current-top-browsing-context-id",
true);
obsService->AddObserver(this, "net:current-browser-id", true);
}
// disabled as its a nop right now
@ -2166,7 +2165,7 @@ nsHttpHandler::Observe(nsISupports* subject, const char* topic,
static_cast<uint32_t>(rv)));
}
}
} else if (!strcmp(topic, "net:current-top-browsing-context-id")) {
} else if (!strcmp(topic, "net:current-browser-id")) {
// The window id will be updated by HttpConnectionMgrParent.
if (XRE_IsParentProcess()) {
nsCOMPtr<nsISupportsPRUint64> wrapper = do_QueryInterface(subject);
@ -2176,12 +2175,11 @@ nsHttpHandler::Observe(nsISupports* subject, const char* topic,
wrapper->GetData(&id);
MOZ_ASSERT(id);
static uint64_t sCurrentBrowsingContextId = 0;
if (sCurrentBrowsingContextId != id) {
sCurrentBrowsingContextId = id;
static uint64_t sCurrentBrowserId = 0;
if (sCurrentBrowserId != id) {
sCurrentBrowserId = id;
if (mConnMgr) {
mConnMgr->UpdateCurrentTopBrowsingContextId(
sCurrentBrowsingContextId);
mConnMgr->UpdateCurrentBrowserId(sCurrentBrowserId);
}
}
}

View File

@ -203,7 +203,7 @@ nsresult nsHttpTransaction::Init(
nsIInputStream* requestBody, uint64_t requestContentLength,
bool requestBodyHasHeaders, nsIEventTarget* target,
nsIInterfaceRequestor* callbacks, nsITransportEventSink* eventsink,
uint64_t topBrowsingContextId, HttpTrafficCategory trafficCategory,
uint64_t browserId, HttpTrafficCategory trafficCategory,
nsIRequestContext* requestContext, ClassOfService classOfService,
uint32_t initialRwin, bool responseTimeoutEnabled, uint64_t channelId,
TransactionObserverFunc&& transactionObserver,
@ -221,7 +221,7 @@ nsresult nsHttpTransaction::Init(
mChannelId = channelId;
mTransactionObserver = std::move(transactionObserver);
mOnPushCallback = std::move(aOnPushCallback);
mTopBrowsingContextId = topBrowsingContextId;
mBrowserId = browserId;
mTrafficCategory = trafficCategory;
@ -914,8 +914,7 @@ nsresult nsHttpTransaction::WriteSegments(nsAHttpSegmentWriter* writer,
}
if (mThrottlingReadAllowance == 0) { // depleted
if (gHttpHandler->ConnMgr()->CurrentTopBrowsingContextId() !=
mTopBrowsingContextId) {
if (gHttpHandler->ConnMgr()->CurrentBrowserId() != mBrowserId) {
nsHttp::NotifyActiveTabLoadOptimization();
}

View File

@ -161,7 +161,7 @@ class nsHttpTransaction final : public nsAHttpTransaction,
// restart - this indicates that state for dev tools
void Refused0RTT();
uint64_t TopBrowsingContextId() override { return mTopBrowsingContextId; }
uint64_t BrowserId() override { return mBrowserId; }
void SetHttpTrailers(nsCString& aTrailers);
@ -473,7 +473,7 @@ class nsHttpTransaction final : public nsAHttpTransaction,
TimeStamp mPendingTime;
TimeDuration mPendingDurationTime;
uint64_t mTopBrowsingContextId{0};
uint64_t mBrowserId{0};
// For Rate Pacing via an EventTokenBucket
public:

View File

@ -459,12 +459,12 @@ interface nsIHttpChannel : nsIIdentChannel
[must_use] attribute uint64_t topLevelContentWindowId;
/**
* ID of the top-level browsing context for this channel.
* ID of the browser for this channel.
*
* NOTE: The setter of this attribute is currently for xpcshell test only.
* Don't alter it otherwise.
*/
[must_use] attribute uint64_t topBrowsingContextId;
[must_use] attribute uint64_t browserId;
/**
* In e10s, the information that the CORS response blocks the load is in the

View File

@ -768,15 +768,15 @@ nsViewSourceChannel::SetTopLevelContentWindowId(uint64_t aWindowId) {
}
NS_IMETHODIMP
nsViewSourceChannel::GetTopBrowsingContextId(uint64_t* aId) {
nsViewSourceChannel::GetBrowserId(uint64_t* aId) {
return !mHttpChannel ? NS_ERROR_NULL_POINTER
: mHttpChannel->GetTopBrowsingContextId(aId);
: mHttpChannel->GetBrowserId(aId);
}
NS_IMETHODIMP
nsViewSourceChannel::SetTopBrowsingContextId(uint64_t aId) {
nsViewSourceChannel::SetBrowserId(uint64_t aId) {
return !mHttpChannel ? NS_ERROR_NULL_POINTER
: mHttpChannel->SetTopBrowsingContextId(aId);
: mHttpChannel->SetBrowserId(aId);
}
NS_IMETHODIMP

View File

@ -57,10 +57,10 @@ function serverStopListener() {
server.stop();
}
function createHttpRequest(browsingContextId, requestId) {
function createHttpRequest(browserId, requestId) {
let uri = baseURL;
var chan = make_channel(uri);
chan.topBrowsingContextId = browsingContextId;
chan.browserId = browserId;
var listner = new HttpResponseListener(requestId);
chan.setRequestHeader("X-ID", requestId, false);
chan.setRequestHeader("Cache-control", "no-store", false);
@ -191,5 +191,5 @@ function run_test() {
);
windowIdWrapper.data = FOCUSED_WINDOW_ID;
var obsvc = Services.obs;
obsvc.notifyObservers(windowIdWrapper, "net:current-top-browsing-context-id");
obsvc.notifyObservers(windowIdWrapper, "net:current-browser-id");
}

View File

@ -62,10 +62,10 @@ function serverStopListener() {
server.stop();
}
function createHttpRequest(windowId, requestId, priority) {
function createHttpRequest(browserId, requestId, priority) {
let uri = baseURL;
var chan = make_channel(uri);
chan.topBrowsingContextId = windowId;
chan.browserId = browserId;
chan.QueryInterface(Ci.nsISupportsPriority).priority = priority;
var listner = new HttpResponseListener(requestId);
chan.setRequestHeader("X-ID", requestId, false);
@ -121,11 +121,11 @@ HttpResponseListener.prototype = {
},
};
function check_response_id(responses, windowId) {
function check_response_id(responses, browserId) {
for (var i = 0; i < responses.length; i++) {
var id = responses[i].getHeader("X-ID");
log("response id=" + id + " windowId=" + windowId);
Assert.equal(id, windowId);
log("response id=" + id + " browserId=" + browserId);
Assert.equal(id, browserId);
}
}