Bug 1451293 - P2: Call SetConnRefTaken r=michal

In part1 patch[1], nsHttpTransaction::GetConnectionReference is removed in order to make sure single thread access to nsHttpTransaction::mConnection. Since we called mH2WSTransaction->SetConnRefTaken in nsHttpTransaction::GetConnectionReference, we need to find a new place to do this.
This patch adds a new function nsHttpTransaction::SetH2WSConnRefTaken to call mH2WSTransaction->SetConnRefTaken.



[1]  https://phabricator.services.mozilla.com/D17221

Differential Revision: https://phabricator.services.mozilla.com/D17853

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kershaw Chang 2019-02-04 08:42:11 +00:00
Родитель a9a7383ac8
Коммит 9c911c6c2f
3 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -7506,6 +7506,10 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt,
}
}
if (mCaps & NS_HTTP_STICKY_CONNECTION) {
mTransaction->SetH2WSConnRefTaken();
}
mTransferSize = mTransaction->GetTransferSize();
// If we are using the transaction to serve content, we also save the

Просмотреть файл

@ -462,6 +462,16 @@ nsAHttpConnection *nsHttpTransaction::Connection() {
return mConnection.get();
}
void nsHttpTransaction::SetH2WSConnRefTaken() {
if (mH2WSTransaction) {
// Need to let the websocket transaction/connection know we've reached
// this point so it can stop forwarding information through us and
// instead communicate directly with the websocket channel.
mH2WSTransaction->SetConnRefTaken();
mH2WSTransaction = nullptr;
}
}
nsHttpResponseHead *nsHttpTransaction::TakeResponseHead() {
MOZ_ASSERT(!mResponseHeadTaken, "TakeResponseHead called 2x");

Просмотреть файл

@ -111,6 +111,8 @@ class nsHttpTransaction final : public nsAHttpTransaction,
// Returning null if there is no trailer.
nsHttpHeaderArray *TakeResponseTrailers();
void SetH2WSConnRefTaken();
// Called to set/find out if the transaction generated a complete response.
bool ResponseIsComplete() { return mResponseIsComplete; }
void SetResponseIsComplete() { mResponseIsComplete = true; }