Bug 1758524 (WIP) - Implement http priority flag r=necko-reviewers,dragana

Differential Revision: https://phabricator.services.mozilla.com/D142694
This commit is contained in:
edguloien 2022-04-28 15:40:33 +00:00
Родитель 8247453c26
Коммит 7172c05d39
38 изменённых файлов: 331 добавлений и 115 удалений

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

@ -27,6 +27,8 @@ using struct mozilla::void_t from "mozilla/ipc/IPCCore.h";
using struct mozilla::dom::LoadingSessionHistoryInfo
from "mozilla/dom/SessionHistoryEntry.h";
using mozilla::net::ClassOfServiceStruct from "nsIClassOfService.h";
using hal::ScreenOrientation from "mozilla/HalIPCUtils.h";
using LayoutDeviceIntRect from "Units.h";
using DesktopIntRect from "Units.h";
@ -334,7 +336,7 @@ struct TimedChannelInfo
struct ReplacementChannelConfigInit
{
uint32_t redirectFlags;
uint32_t classOfService;
ClassOfServiceStruct classOfService;
bool? privateBrowsing;
nsCString? method;
nsIReferrerInfo referrerInfo;

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

@ -14,13 +14,21 @@
* information in different ways.
*/
// convenience class for passing around the class of service
%{C++
#include "../../../netwerk/protocol/http/ClassOfService.h"
%}
native ClassOfServiceStruct(mozilla::net::ClassOfServiceStruct);
[scriptable, uuid(1ccb58ec-5e07-4cf9-a30d-ac5490d23b41)]
interface nsIClassOfService : nsISupports
{
attribute unsigned long classFlags;
attribute bool incremental;
void clearClassFlags(in unsigned long flags);
void addClassFlags(in unsigned long flags);
void setClassOfService(in ClassOfServiceStruct s);
// All these flags have a (de)prioritization effect.
@ -29,7 +37,7 @@ interface nsIClassOfService : nsISupports
// belonging to a single top level window (RequestContextService). Requests
// marked with the Leader flag are blocking (preventing from being sent to the
// server) all other resource loads except those marked with the Unblocked
// flag. Other classes run in parallel - neither being blocked nor blocking.
// flag. Other classes run in parallel - neither being blocked no ;r blocking.
// The Leader flag is used only for <head> blocking resources (sync and
// defer javascript resources and stylesheets.) Purpose is to deliver these
// first-paint and domcontentloaded blocking resources as soon as possbile.

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

@ -21,6 +21,7 @@ include "mozilla/dom/ReferrerInfoUtils.h";
include "mozilla/ipc/URIUtils.h";
include "mozilla/net/CacheInfoIPCTypes.h";
include "mozilla/AntiTrackingIPCUtils.h";
include "nsIClassOfService.h";
using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
using RequestHeaderTuples from "mozilla/net/PHttpChannelParams.h";
@ -289,7 +290,7 @@ struct HttpChannelOpenArgs
IPCStream? uploadStream;
bool uploadStreamHasHeaders;
int16_t priority;
uint32_t classOfService;
ClassOfServiceStruct classOfService;
uint8_t redirectionLimit;
bool allowSTS;
uint32_t thirdPartyFlags;

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

@ -0,0 +1,69 @@
#ifndef __ClassOfService_h__
#define __ClassOfService_h__
#include "ipc/IPCMessageUtils.h"
// namespace IPC {}
namespace mozilla {
namespace net {
class ClassOfServiceStruct {
public:
ClassOfServiceStruct() : mClassFlags(0), mIncremental(false) {}
ClassOfServiceStruct(unsigned long flags, bool incremental)
: mClassFlags(flags), mIncremental(incremental) {}
// class flags (priority)
unsigned long Flags() const { return mClassFlags; }
void SetFlags(unsigned long flags) { mClassFlags = flags; }
// incremental flags
bool Incremental() const { return mIncremental; }
void SetIncremental(bool incremental) { mIncremental = incremental; }
private:
unsigned long mClassFlags;
bool mIncremental;
friend IPC::ParamTraits<mozilla::net::ClassOfServiceStruct>;
friend bool operator==(const ClassOfServiceStruct& lhs,
const ClassOfServiceStruct& rhs);
friend bool operator!=(const ClassOfServiceStruct& lhs,
const ClassOfServiceStruct& rhs);
};
inline bool operator==(const ClassOfServiceStruct& lhs,
const ClassOfServiceStruct& rhs) {
return lhs.mClassFlags == rhs.mClassFlags &&
lhs.mIncremental == rhs.mIncremental;
}
inline bool operator!=(const ClassOfServiceStruct& lhs,
const ClassOfServiceStruct& rhs) {
return !(lhs == rhs);
}
} // namespace net
} // namespace mozilla
namespace IPC {
template <>
struct ParamTraits<mozilla::net::ClassOfServiceStruct> {
typedef mozilla::net::ClassOfServiceStruct paramType;
static void Write(MessageWriter* aWriter, const paramType& aParam) {
WriteParam(aWriter, aParam.mClassFlags);
WriteParam(aWriter, aParam.mIncremental);
}
static bool Read(MessageReader* aReader, paramType* aResult) {
if (!ReadParam(aReader, &aResult->mClassFlags) ||
!ReadParam(aReader, &aResult->mIncremental))
return false;
return true;
}
};
} // namespace IPC
#endif

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

@ -1250,7 +1250,7 @@ void Http2Stream::SetPriorityDependency(uint32_t newPriority,
static uint32_t GetPriorityDependencyFromTransaction(nsHttpTransaction* trans) {
MOZ_ASSERT(trans);
uint32_t classFlags = trans->ClassOfService();
uint32_t classFlags = trans->ClassOfService().Flags();
if (classFlags & nsIClassOfService::UrgentStart) {
return Http2Session::kUrgentStartGroupID;

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

@ -750,7 +750,7 @@ bool Http3Session::AddStream(nsAHttpTransaction* aHttpTransaction,
// reset the read timers to wash away any idle time
mLastWriteTime = PR_IntervalNow();
uint32_t cos = 0;
ClassOfServiceStruct cos;
if (trans) {
cos = trans->ClassOfService();
}

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

@ -24,7 +24,8 @@ namespace mozilla {
namespace net {
Http3Stream::Http3Stream(nsAHttpTransaction* httpTransaction,
Http3Session* session, uint32_t aCos, uint64_t bcId)
Http3Session* session, const ClassOfServiceStruct& cos,
uint64_t bcId)
: mSession(session),
mTransaction(httpTransaction),
mCurrentTopBrowsingContextId(bcId) {
@ -36,7 +37,8 @@ Http3Stream::Http3Stream(nsAHttpTransaction* httpTransaction,
mTransactionTabId = trans->TopBrowsingContextId();
}
SetPriority(aCos);
SetPriority(cos.Flags());
SetIncremental(cos.Incremental());
}
void Http3Stream::Close(nsresult aResult) {
@ -96,6 +98,10 @@ void Http3Stream::SetPriority(uint32_t aCos) {
}
}
void Http3Stream::SetIncremental(bool incremental) {
mPriorityIncremental = incremental;
}
nsresult Http3Stream::TryActivating() {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("Http3Stream::TryActivating [this=%p]", this));

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

@ -9,6 +9,7 @@
#include "nsAHttpTransaction.h"
#include "ARefBase.h"
#include "mozilla/WeakPtr.h"
#include "nsIClassOfService.h"
namespace mozilla {
namespace net {
@ -25,7 +26,8 @@ class Http3Stream final : public nsAHttpSegmentReader,
// for RefPtr
NS_INLINE_DECL_REFCOUNTING(Http3Stream, override)
Http3Stream(nsAHttpTransaction*, Http3Session*, uint32_t, uint64_t);
Http3Stream(nsAHttpTransaction*, Http3Session*, const ClassOfServiceStruct&,
uint64_t);
bool HasStreamId() const { return mStreamId != UINT64_MAX; }
uint64_t StreamId() const { return mStreamId; }
@ -70,6 +72,7 @@ class Http3Stream final : public nsAHttpSegmentReader,
nsresult StartRequest();
void SetPriority(uint32_t aCos);
void SetIncremental(bool incremental);
/**
* SendStreamState:

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

@ -197,7 +197,7 @@ HttpBaseChannel::HttpBaseChannel()
mFlashPluginState(nsIHttpChannel::FlashPluginUnknown),
mLoadFlags(LOAD_NORMAL),
mCaps(0),
mClassOfService(0),
mClassOfService(0, false),
mTlsFlags(0),
mSuspendCount(0),
mInitialRwin(0),
@ -4191,7 +4191,7 @@ HttpBaseChannel::CloneReplacementChannelConfig(bool aPreserveMethod,
ReplacementReason aReason) {
nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(newChannel));
if (cos) {
cos->SetClassFlags(config.classOfService);
cos->SetClassOfService(config.classOfService);
}
// Try to preserve the privacy bit if it has been overridden

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

@ -352,7 +352,12 @@ class HttpBaseChannel : public nsHashPropertyBag,
// nsIClassOfService
NS_IMETHOD GetClassFlags(uint32_t* outFlags) override {
*outFlags = mClassOfService;
*outFlags = mClassOfService.Flags();
return NS_OK;
}
NS_IMETHOD GetIncremental(bool* outIncremental) override {
*outIncremental = mClassOfService.Incremental();
return NS_OK;
}
@ -499,7 +504,7 @@ class HttpBaseChannel : public nsHashPropertyBag,
const dom::ReplacementChannelConfigInit& aInit);
uint32_t redirectFlags = 0;
uint32_t classOfService = 0;
ClassOfServiceStruct classOfService = {0, false};
Maybe<bool> privateBrowsing = Nothing();
Maybe<nsCString> method;
nsCOMPtr<nsIReferrerInfo> referrerInfo;
@ -770,7 +775,8 @@ class HttpBaseChannel : public nsHashPropertyBag,
uint32_t mLoadFlags;
uint32_t mCaps;
uint32_t mClassOfService;
ClassOfServiceStruct mClassOfService;
// clang-format off
MOZ_ATOMIC_BITFIELDS(mAtomicBitfields1, 32, (

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

@ -2564,7 +2564,6 @@ HttpChannelChild::ResumeAt(uint64_t startPos, const nsACString& entityID) {
NS_IMETHODIMP
HttpChannelChild::SetPriority(int32_t aPriority) {
LOG(("HttpChannelChild::SetPriority %p p=%d", this, aPriority));
int16_t newValue = clamped<int32_t>(aPriority, INT16_MIN, INT16_MAX);
if (mPriority == newValue) return NS_OK;
mPriority = newValue;
@ -2577,13 +2576,14 @@ HttpChannelChild::SetPriority(int32_t aPriority) {
//-----------------------------------------------------------------------------
NS_IMETHODIMP
HttpChannelChild::SetClassFlags(uint32_t inFlags) {
if (mClassOfService == inFlags) {
if (mClassOfService.Flags() == inFlags) {
return NS_OK;
}
mClassOfService = inFlags;
mClassOfService.SetFlags(inFlags);
LOG(("HttpChannelChild %p ClassOfService=%u", this, mClassOfService));
LOG(("HttpChannelChild %p ClassOfService flags=%lu inc=%d", this,
mClassOfService.Flags(), mClassOfService.Incremental()));
if (RemoteChannelExists()) {
SendSetClassOfService(mClassOfService);
@ -2593,9 +2593,10 @@ HttpChannelChild::SetClassFlags(uint32_t inFlags) {
NS_IMETHODIMP
HttpChannelChild::AddClassFlags(uint32_t inFlags) {
mClassOfService |= inFlags;
mClassOfService.SetFlags(inFlags | mClassOfService.Flags());
LOG(("HttpChannelChild %p ClassOfService=%u", this, mClassOfService));
LOG(("HttpChannelChild %p ClassOfService flags=%lu inc=%d", this,
mClassOfService.Flags(), mClassOfService.Incremental()));
if (RemoteChannelExists()) {
SendSetClassOfService(mClassOfService);
@ -2605,9 +2606,10 @@ HttpChannelChild::AddClassFlags(uint32_t inFlags) {
NS_IMETHODIMP
HttpChannelChild::ClearClassFlags(uint32_t inFlags) {
mClassOfService &= ~inFlags;
mClassOfService.SetFlags(~inFlags & mClassOfService.Flags());
LOG(("HttpChannelChild %p ClassOfService=%u", this, mClassOfService));
LOG(("HttpChannelChild %p ClassOfService=%lu", this,
mClassOfService.Flags()));
if (RemoteChannelExists()) {
SendSetClassOfService(mClassOfService);
@ -2615,6 +2617,27 @@ HttpChannelChild::ClearClassFlags(uint32_t inFlags) {
return NS_OK;
}
NS_IMETHODIMP
HttpChannelChild::SetClassOfService(ClassOfServiceStruct inCos) {
mClassOfService = inCos;
LOG(("HttpChannelChild %p ClassOfService flags=%lu inc=%d", this,
mClassOfService.Flags(), mClassOfService.Incremental()));
if (RemoteChannelExists()) {
SendSetClassOfService(mClassOfService);
}
return NS_OK;
}
NS_IMETHODIMP
HttpChannelChild::SetIncremental(bool inIncremental) {
mClassOfService.SetIncremental(inIncremental);
LOG(("HttpChannelChild %p ClassOfService flags=%lu inc=%d", this,
mClassOfService.Flags(), mClassOfService.Incremental()));
if (RemoteChannelExists()) {
SendSetClassOfService(mClassOfService);
}
return NS_OK;
}
//-----------------------------------------------------------------------------
// HttpChannelChild::nsIProxiedChannel
//-----------------------------------------------------------------------------

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

@ -104,6 +104,8 @@ class HttpChannelChild final : public PHttpChannelChild,
NS_IMETHOD SetClassFlags(uint32_t inFlags) override;
NS_IMETHOD AddClassFlags(uint32_t inFlags) override;
NS_IMETHOD ClearClassFlags(uint32_t inFlags) override;
NS_IMETHOD SetClassOfService(ClassOfServiceStruct inCos) override;
NS_IMETHOD SetIncremental(bool inIncremental) override;
// nsIResumableChannel
NS_IMETHOD ResumeAt(uint64_t startPos, const nsACString& entityID) override;

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

@ -361,7 +361,7 @@ bool HttpChannelParent::DoAsyncOpen(
const Maybe<URIParams>& aTopWindowURI, const uint32_t& aLoadFlags,
const RequestHeaderTuples& requestHeaders, const nsCString& requestMethod,
const Maybe<IPCStream>& uploadStream, const bool& uploadStreamHasHeaders,
const int16_t& priority, const uint32_t& classOfService,
const int16_t& priority, const ClassOfServiceStruct& classOfService,
const uint8_t& redirectionLimit, const bool& allowSTS,
const uint32_t& thirdPartyFlags, const bool& doResumeAt,
const uint64_t& startPos, const nsCString& entityID, const bool& allowSpdy,
@ -536,8 +536,8 @@ bool HttpChannelParent::DoAsyncOpen(
if (priority != nsISupportsPriority::PRIORITY_NORMAL) {
httpChannel->SetPriority(priority);
}
if (classOfService) {
httpChannel->SetClassFlags(classOfService);
if (classOfService.Flags() || classOfService.Incremental()) {
httpChannel->SetClassOfService(classOfService);
}
httpChannel->SetRedirectionLimit(redirectionLimit);
httpChannel->SetAllowSTS(allowSTS);
@ -692,9 +692,9 @@ mozilla::ipc::IPCResult HttpChannelParent::RecvSetPriority(
}
mozilla::ipc::IPCResult HttpChannelParent::RecvSetClassOfService(
const uint32_t& cos) {
const ClassOfServiceStruct& cos) {
if (mChannel) {
mChannel->SetClassFlags(cos);
mChannel->SetClassOfService(cos);
}
return IPC_OK();
}

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

@ -138,7 +138,7 @@ class HttpChannelParent final : public nsIInterfaceRequestor,
const Maybe<URIParams>& topWindowUri, const uint32_t& loadFlags,
const RequestHeaderTuples& requestHeaders, const nsCString& requestMethod,
const Maybe<IPCStream>& uploadStream, const bool& uploadStreamHasHeaders,
const int16_t& priority, const uint32_t& classOfService,
const int16_t& priority, const ClassOfServiceStruct& classOfService,
const uint8_t& redirectionLimit, const bool& allowSTS,
const uint32_t& thirdPartyFlags, const bool& doResumeAt,
const uint64_t& startPos, const nsCString& entityID,
@ -168,7 +168,7 @@ class HttpChannelParent final : public nsIInterfaceRequestor,
virtual mozilla::ipc::IPCResult RecvSetPriority(
const int16_t& priority) override;
virtual mozilla::ipc::IPCResult RecvSetClassOfService(
const uint32_t& cos) override;
const ClassOfServiceStruct& cos) override;
virtual mozilla::ipc::IPCResult RecvSuspend() override;
virtual mozilla::ipc::IPCResult RecvResume() override;
virtual mozilla::ipc::IPCResult RecvCancel(

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

@ -89,7 +89,8 @@ mozilla::ipc::IPCResult HttpConnectionMgrChild::RecvRescheduleTransaction(
mozilla::ipc::IPCResult
HttpConnectionMgrChild::RecvUpdateClassOfServiceOnTransaction(
PHttpTransactionChild* aTrans, const uint32_t& aClassOfService) {
PHttpTransactionChild* aTrans,
const ClassOfServiceStruct& aClassOfService) {
mConnMgr->UpdateClassOfServiceOnTransaction(ToRealHttpTransaction(aTrans),
aClassOfService);
return IPC_OK();

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

@ -33,7 +33,8 @@ class HttpConnectionMgrChild final : public PHttpConnectionMgrChild {
mozilla::ipc::IPCResult RecvRescheduleTransaction(
PHttpTransactionChild* aTrans, const int32_t& aPriority);
mozilla::ipc::IPCResult RecvUpdateClassOfServiceOnTransaction(
PHttpTransactionChild* aTrans, const uint32_t& aClassOfService);
PHttpTransactionChild* aTrans,
const ClassOfServiceStruct& aClassOfService);
mozilla::ipc::IPCResult RecvCancelTransaction(PHttpTransactionChild* aTrans,
const nsresult& aReason);
mozilla::ipc::IPCResult RecvSpeculativeConnect(

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

@ -183,7 +183,7 @@ nsresult HttpConnectionMgrParent::RescheduleTransaction(
}
void HttpConnectionMgrParent::UpdateClassOfServiceOnTransaction(
HttpTransactionShell* aTrans, uint32_t aClassOfService) {
HttpTransactionShell* aTrans, const ClassOfServiceStruct& aClassOfService) {
MOZ_ASSERT(gIOService->SocketProcessReady());
if (!CanSend()) {

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

@ -10,6 +10,7 @@
class nsIEventTarget;
class nsIHttpUpgradeListener;
class nsIInterfaceRequestor;
struct ClassOfServiceStruct;
namespace mozilla {
namespace net {
@ -113,8 +114,8 @@ class HttpConnectionMgrShell : public nsISupports {
[[nodiscard]] virtual nsresult RescheduleTransaction(HttpTransactionShell*,
int32_t priority) = 0;
void virtual UpdateClassOfServiceOnTransaction(HttpTransactionShell*,
uint32_t classOfService) = 0;
void virtual UpdateClassOfServiceOnTransaction(
HttpTransactionShell*, const ClassOfServiceStruct& classOfService) = 0;
// cancels a transaction w/ the given reason.
[[nodiscard]] virtual nsresult CancelTransaction(HttpTransactionShell*,
@ -204,7 +205,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(HttpConnectionMgrShell,
virtual nsresult RescheduleTransaction(HttpTransactionShell*, \
int32_t priority) override; \
void virtual UpdateClassOfServiceOnTransaction( \
HttpTransactionShell*, uint32_t classOfService) override; \
HttpTransactionShell*, const ClassOfServiceStruct& classOfService) \
override; \
virtual nsresult CancelTransaction(HttpTransactionShell*, nsresult reason) \
override; \
virtual nsresult ReclaimConnection(HttpConnectionBase* conn) override; \

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

@ -70,8 +70,8 @@ nsresult HttpTransactionChild::InitInternal(
nsHttpRequestHead* requestHead, nsIInputStream* requestBody,
uint64_t requestContentLength, bool requestBodyHasHeaders,
uint64_t topLevelOuterContentWindowId, uint8_t httpTrafficCategory,
uint64_t requestContextID, uint32_t classOfService, uint32_t initialRwin,
bool responseTimeoutEnabled, uint64_t channelId,
uint64_t requestContextID, ClassOfServiceStruct 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));
@ -173,7 +173,7 @@ mozilla::ipc::IPCResult HttpTransactionChild::RecvInit(
const uint64_t& aReqContentLength, const bool& aReqBodyIncludesHeaders,
const uint64_t& aTopLevelOuterContentWindowId,
const uint8_t& aHttpTrafficCategory, const uint64_t& aRequestContextID,
const uint32_t& aClassOfService, const uint32_t& aInitialRwin,
const ClassOfServiceStruct& aClassOfService, const uint32_t& aInitialRwin,
const bool& aResponseTimeoutEnabled, const uint64_t& aChannelId,
const bool& aHasTransactionObserver,
const Maybe<H2PushedStreamArg>& aPushedStreamArg,

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

@ -56,7 +56,7 @@ class HttpTransactionChild final : public PHttpTransactionChild,
const bool& aReqBodyIncludesHeaders,
const uint64_t& aTopLevelOuterContentWindowId,
const uint8_t& aHttpTrafficCategory, const uint64_t& aRequestContextID,
const uint32_t& aClassOfService, const uint32_t& aInitialRwin,
const ClassOfServiceStruct& aClassOfService, const uint32_t& aInitialRwin,
const bool& aResponseTimeoutEnabled, const uint64_t& aChannelId,
const bool& aHasTransactionObserver,
const Maybe<H2PushedStreamArg>& aPushedStreamArg,
@ -88,8 +88,8 @@ class HttpTransactionChild final : public PHttpTransactionChild,
nsIInputStream* requestBody, // use the trick in bug 1277681
uint64_t requestContentLength, bool requestBodyHasHeaders,
uint64_t topLevelOuterContentWindowId, uint8_t httpTrafficCategory,
uint64_t requestContextID, uint32_t classOfService, uint32_t initialRwin,
bool responseTimeoutEnabled, uint64_t channelId,
uint64_t requestContextID, ClassOfServiceStruct classOfService,
uint32_t initialRwin, bool responseTimeoutEnabled, uint64_t channelId,
bool aHasTransactionObserver,
const Maybe<H2PushedStreamArg>& aPushedStreamArg);

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

@ -88,7 +88,7 @@ nsresult HttpTransactionParent::Init(
bool requestBodyHasHeaders, nsIEventTarget* target,
nsIInterfaceRequestor* callbacks, nsITransportEventSink* eventsink,
uint64_t topLevelOuterContentWindowId, HttpTrafficCategory trafficCategory,
nsIRequestContext* requestContext, uint32_t classOfService,
nsIRequestContext* requestContext, ClassOfServiceStruct classOfService,
uint32_t initialRwin, bool responseTimeoutEnabled, uint64_t channelId,
TransactionObserverFunc&& transactionObserver,
OnPushCallback&& aOnPushCallback,

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

@ -7,6 +7,7 @@
#include <functional>
#include "nsISupports.h"
#include "nsIClassOfService.h"
#include "TimingStruct.h"
#include "nsInputStreamPump.h"
#include "nsIEarlyHintObserver.h"
@ -81,7 +82,7 @@ class HttpTransactionShell : public nsISupports {
nsIEventTarget* consumerTarget, nsIInterfaceRequestor* callbacks,
nsITransportEventSink* eventsink, uint64_t topBrowsingContextId,
HttpTrafficCategory trafficCategory, nsIRequestContext* requestContext,
uint32_t classOfService, uint32_t initialRwin,
ClassOfServiceStruct classOfService, uint32_t initialRwin,
bool responseTimeoutEnabled, uint64_t channelId,
TransactionObserverFunc&& transactionObserver,
OnPushCallback&& aOnPushCallback,
@ -173,7 +174,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(HttpTransactionShell, HTTPTRANSACTIONSHELL_IID)
nsIEventTarget* consumerTarget, nsIInterfaceRequestor* callbacks, \
nsITransportEventSink* eventsink, uint64_t topBrowsingContextId, \
HttpTrafficCategory trafficCategory, nsIRequestContext* requestContext, \
uint32_t classOfService, uint32_t initialRwin, \
ClassOfServiceStruct classOfService, uint32_t initialRwin, \
bool responseTimeoutEnabled, uint64_t channelId, \
TransactionObserverFunc&& transactionObserver, \
OnPushCallback&& aOnPushCallback, \

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

@ -616,19 +616,31 @@ InterceptedHttpChannel::SetPriority(int32_t aPriority) {
NS_IMETHODIMP
InterceptedHttpChannel::SetClassFlags(uint32_t aClassFlags) {
mClassOfService = aClassFlags;
mClassOfService.SetFlags(aClassFlags);
return NS_OK;
}
NS_IMETHODIMP
InterceptedHttpChannel::ClearClassFlags(uint32_t aClassFlags) {
mClassOfService &= ~aClassFlags;
mClassOfService.SetFlags(~aClassFlags & mClassOfService.Flags());
return NS_OK;
}
NS_IMETHODIMP
InterceptedHttpChannel::AddClassFlags(uint32_t aClassFlags) {
mClassOfService |= aClassFlags;
mClassOfService.SetFlags(aClassFlags | mClassOfService.Flags());
return NS_OK;
}
NS_IMETHODIMP
InterceptedHttpChannel::SetClassOfService(ClassOfServiceStruct cos) {
mClassOfService = cos;
return NS_OK;
}
NS_IMETHODIMP
InterceptedHttpChannel::SetIncremental(bool incremental) {
mClassOfService.SetIncremental(incremental);
return NS_OK;
}

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

@ -268,6 +268,12 @@ class InterceptedHttpChannel final
NS_IMETHOD
AddClassFlags(uint32_t flags) override;
NS_IMETHOD
SetClassOfService(ClassOfServiceStruct cos) override;
NS_IMETHOD
SetIncremental(bool incremental) override;
NS_IMETHOD
ResumeAt(uint64_t startPos, const nsACString& entityID) override;

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

@ -18,6 +18,7 @@ include "mozilla/dom/ReferrerInfoUtils.h";
include "mozilla/net/NeckoMessageUtils.h";
using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
using struct ClassOfServiceStruct from "nsIClassOfService.h";
namespace mozilla {
namespace net {
@ -32,7 +33,7 @@ parent:
// Note: channels are opened during construction, so no open method here:
// see PNecko.ipdl
async SetClassOfService(uint32_t cos);
async SetClassOfService(ClassOfServiceStruct cos);
async Suspend();
async Resume();

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

@ -10,6 +10,7 @@ include protocol PSocketProcess;
include protocol PHttpTransaction;
include NeckoChannelParams;
using mozilla::net::ClassOfServiceStruct from "nsIClassOfService.h";
namespace mozilla {
namespace net {
@ -28,7 +29,7 @@ child:
PHttpTransaction aTransWithStickyConn);
async RescheduleTransaction(PHttpTransaction aTrans, int32_t aPriority);
async UpdateClassOfServiceOnTransaction(PHttpTransaction aTrans,
uint32_t aClassOfService);
ClassOfServiceStruct aClassOfService);
async CancelTransaction(PHttpTransaction aTrans, nsresult aReason);
async SpeculativeConnect(HttpConnectionInfoCloneArgs aConnInfo,
SpeculativeConnectionOverriderArgs? aOverriderArgs,

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

@ -17,6 +17,7 @@ include "mozilla/net/NeckoMessageUtils.h";
using class mozilla::net::nsHttpRequestHead from "nsHttpRequestHead.h";
using class nsHttpHeaderArray from "nsHttpHeaderArray.h";
using mozilla::net::NetAddr from "mozilla/net/DNS.h";
using mozilla::net::ClassOfServiceStruct from "nsIClassOfService.h";
namespace mozilla {
namespace net {
@ -83,7 +84,7 @@ child:
uint64_t topLevelOuterContentWindowId,
uint8_t httpTrafficCategory,
uint64_t requestContextID,
uint32_t classOfService,
ClassOfServiceStruct classOfService,
uint32_t initialRwin,
bool responseTimeoutEnabled,
uint64_t channelId,

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

@ -442,13 +442,13 @@ nsresult TRRServiceChannel::BeginConnect() {
}
if (gHttpHandler->CriticalRequestPrioritization()) {
if (mClassOfService & nsIClassOfService::Leader) {
if (mClassOfService.Flags() & nsIClassOfService::Leader) {
mCaps |= NS_HTTP_LOAD_AS_BLOCKING;
}
if (mClassOfService & nsIClassOfService::Unblocked) {
if (mClassOfService.Flags() & nsIClassOfService::Unblocked) {
mCaps |= NS_HTTP_LOAD_UNBLOCKED;
}
if (mClassOfService & nsIClassOfService::UrgentStart &&
if (mClassOfService.Flags() & nsIClassOfService::UrgentStart &&
gHttpHandler->IsUrgentStartEnabled()) {
mCaps |= NS_HTTP_URGENT_START;
SetPriority(nsISupportsPriority::PRIORITY_HIGHEST);
@ -528,8 +528,10 @@ nsresult TRRServiceChannel::Connect() {
}
nsresult TRRServiceChannel::SetupTransaction() {
LOG(("TRRServiceChannel::SetupTransaction [this=%p, cos=%u, prio=%d]\n", this,
mClassOfService, mPriority));
LOG((
"TRRServiceChannel::SetupTransaction "
"[this=%p, cos=%lu, inc=%d, prio=%d]\n",
this, mClassOfService.Flags(), mClassOfService.Incremental(), mPriority));
NS_ENSURE_TRUE(!mTransaction, NS_ERROR_ALREADY_INITIALIZED);
@ -1275,8 +1277,8 @@ TRRServiceChannel::SetPriority(int32_t value) {
}
void TRRServiceChannel::OnClassOfServiceUpdated() {
LOG(("TRRServiceChannel::OnClassOfServiceUpdated this=%p, cos=%u", this,
mClassOfService));
LOG(("TRRServiceChannel::OnClassOfServiceUpdated this=%p, cos=%lu inc=%d",
this, mClassOfService.Flags(), mClassOfService.Incremental()));
if (mTransaction) {
gHttpHandler->UpdateClassOfServiceOnTransaction(mTransaction,
@ -1286,8 +1288,28 @@ void TRRServiceChannel::OnClassOfServiceUpdated() {
NS_IMETHODIMP
TRRServiceChannel::SetClassFlags(uint32_t inFlags) {
uint32_t previous = mClassOfService;
mClassOfService = inFlags;
uint32_t previous = mClassOfService.Flags();
mClassOfService.SetFlags(inFlags);
if (previous != mClassOfService.Flags()) {
OnClassOfServiceUpdated();
}
return NS_OK;
}
NS_IMETHODIMP
TRRServiceChannel::SetIncremental(bool inFlag) {
bool previous = mClassOfService.Incremental();
mClassOfService.SetIncremental(inFlag);
if (previous != mClassOfService.Incremental()) {
OnClassOfServiceUpdated();
}
return NS_OK;
}
NS_IMETHODIMP
TRRServiceChannel::SetClassOfService(ClassOfServiceStruct cos) {
ClassOfServiceStruct previous = mClassOfService;
mClassOfService = cos;
if (previous != mClassOfService) {
OnClassOfServiceUpdated();
}
@ -1296,9 +1318,9 @@ TRRServiceChannel::SetClassFlags(uint32_t inFlags) {
NS_IMETHODIMP
TRRServiceChannel::AddClassFlags(uint32_t inFlags) {
uint32_t previous = mClassOfService;
mClassOfService |= inFlags;
if (previous != mClassOfService) {
uint32_t previous = mClassOfService.Flags();
mClassOfService.SetFlags(inFlags | mClassOfService.Flags());
if (previous != mClassOfService.Flags()) {
OnClassOfServiceUpdated();
}
return NS_OK;
@ -1306,9 +1328,9 @@ TRRServiceChannel::AddClassFlags(uint32_t inFlags) {
NS_IMETHODIMP
TRRServiceChannel::ClearClassFlags(uint32_t inFlags) {
uint32_t previous = mClassOfService;
mClassOfService &= ~inFlags;
if (previous != mClassOfService) {
uint32_t previous = mClassOfService.Flags();
mClassOfService.SetFlags(~inFlags & mClassOfService.Flags());
if (previous != mClassOfService.Flags()) {
OnClassOfServiceUpdated();
}
return NS_OK;

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

@ -82,6 +82,8 @@ class TRRServiceChannel : public HttpBaseChannel,
NS_IMETHOD SetClassFlags(uint32_t inFlags) override;
NS_IMETHOD AddClassFlags(uint32_t inFlags) override;
NS_IMETHOD ClearClassFlags(uint32_t inFlags) override;
NS_IMETHOD SetIncremental(bool inFlag) override;
NS_IMETHOD SetClassOfService(ClassOfServiceStruct cos) override;
// nsIResumableChannel
NS_IMETHOD ResumeAt(uint64_t startPos, const nsACString& entityID) override;
NS_IMETHOD SetEarlyHintObserver(nsIEarlyHintObserver* aObserver) override {

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

@ -717,8 +717,9 @@ nsresult nsHttpChannel::Connect() {
}
bool isTrackingResource = IsThirdPartyTrackingResource();
LOG(("nsHttpChannel %p tracking resource=%d, cos=%u", this,
isTrackingResource, mClassOfService));
LOG(("nsHttpChannel %p tracking resource=%d, cos=%lu, inc=%d", this,
isTrackingResource, mClassOfService.Flags(),
mClassOfService.Incremental()));
if (isTrackingResource) {
AddClassFlags(nsIClassOfService::Tail);
@ -1076,8 +1077,9 @@ void nsHttpChannel::HandleAsyncNotModified() {
}
nsresult nsHttpChannel::SetupTransaction() {
LOG(("nsHttpChannel::SetupTransaction [this=%p, cos=%u, prio=%d]\n", this,
mClassOfService, mPriority));
LOG(("nsHttpChannel::SetupTransaction [this=%p, cos=%lu, inc=%d prio=%d]\n",
this, mClassOfService.Flags(), mClassOfService.Incremental(),
mPriority));
NS_ENSURE_TRUE(!mTransaction, NS_ERROR_ALREADY_INITIALIZED);
@ -1368,7 +1370,7 @@ HttpTrafficCategory nsHttpChannel::CreateTrafficCategory() {
HttpTrafficAnalyzer::ClassOfService cos;
{
if ((mClassOfService & nsIClassOfService::Leader) &&
if ((mClassOfService.Flags() & nsIClassOfService::Leader) &&
mLoadInfo->GetExternalContentPolicyType() ==
ExtContentPolicy::TYPE_SCRIPT) {
cos = HttpTrafficAnalyzer::ClassOfService::eLeader;
@ -3485,7 +3487,7 @@ nsresult nsHttpChannel::OpenCacheEntryInternal(bool isHttps) {
}
NS_ENSURE_SUCCESS(rv, rv);
if ((mClassOfService & nsIClassOfService::Leader) ||
if ((mClassOfService.Flags() & nsIClassOfService::Leader) ||
(mLoadFlags & LOAD_INITIAL_DOCUMENT_URI)) {
cacheEntryOpenFlags |= nsICacheStorage::OPEN_PRIORITY;
}
@ -6178,13 +6180,13 @@ nsresult nsHttpChannel::BeginConnect() {
}
if (gHttpHandler->CriticalRequestPrioritization()) {
if (mClassOfService & nsIClassOfService::Leader) {
if (mClassOfService.Flags() & nsIClassOfService::Leader) {
mCaps |= NS_HTTP_LOAD_AS_BLOCKING;
}
if (mClassOfService & nsIClassOfService::Unblocked) {
if (mClassOfService.Flags() & nsIClassOfService::Unblocked) {
mCaps |= NS_HTTP_LOAD_UNBLOCKED;
}
if (mClassOfService & nsIClassOfService::UrgentStart &&
if (mClassOfService.Flags() & nsIClassOfService::UrgentStart &&
gHttpHandler->IsUrgentStartEnabled()) {
mCaps |= NS_HTTP_URGENT_START;
SetPriority(nsISupportsPriority::PRIORITY_HIGHEST);
@ -6462,8 +6464,8 @@ nsHttpChannel::SetPriority(int32_t value) {
//-----------------------------------------------------------------------------
void nsHttpChannel::OnClassOfServiceUpdated() {
LOG(("nsHttpChannel::OnClassOfServiceUpdated this=%p, cos=%u", this,
mClassOfService));
LOG(("nsHttpChannel::OnClassOfServiceUpdated this=%p, cos=%lu, inc=%d", this,
mClassOfService.Flags(), mClassOfService.Incremental()));
if (mTransaction) {
gHttpHandler->UpdateClassOfServiceOnTransaction(mTransaction,
@ -6478,9 +6480,9 @@ void nsHttpChannel::OnClassOfServiceUpdated() {
NS_IMETHODIMP
nsHttpChannel::SetClassFlags(uint32_t inFlags) {
uint32_t previous = mClassOfService;
mClassOfService = inFlags;
if (previous != mClassOfService) {
uint32_t previous = mClassOfService.Flags();
mClassOfService.SetFlags(inFlags);
if (previous != mClassOfService.Flags()) {
OnClassOfServiceUpdated();
}
return NS_OK;
@ -6488,9 +6490,9 @@ nsHttpChannel::SetClassFlags(uint32_t inFlags) {
NS_IMETHODIMP
nsHttpChannel::AddClassFlags(uint32_t inFlags) {
uint32_t previous = mClassOfService;
mClassOfService |= inFlags;
if (previous != mClassOfService) {
uint32_t previous = mClassOfService.Flags();
mClassOfService.SetFlags(inFlags | mClassOfService.Flags());
if (previous != mClassOfService.Flags()) {
OnClassOfServiceUpdated();
}
return NS_OK;
@ -6498,14 +6500,34 @@ nsHttpChannel::AddClassFlags(uint32_t inFlags) {
NS_IMETHODIMP
nsHttpChannel::ClearClassFlags(uint32_t inFlags) {
uint32_t previous = mClassOfService;
mClassOfService &= ~inFlags;
uint32_t previous = mClassOfService.Flags();
mClassOfService.SetFlags(~inFlags & mClassOfService.Flags());
if (previous != mClassOfService.Flags()) {
OnClassOfServiceUpdated();
}
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::SetClassOfService(ClassOfServiceStruct cos) {
ClassOfServiceStruct previous = mClassOfService;
mClassOfService = cos;
if (previous != mClassOfService) {
OnClassOfServiceUpdated();
}
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::SetIncremental(bool incremental) {
bool previous = mClassOfService.Incremental();
mClassOfService.SetIncremental(incremental);
if (previous != mClassOfService.Incremental()) {
OnClassOfServiceUpdated();
}
return NS_OK;
}
//-----------------------------------------------------------------------------
// nsHttpChannel::nsIProtocolProxyCallback
//-----------------------------------------------------------------------------
@ -9161,18 +9183,18 @@ nsHttpChannel::TimerCallback::Notify(nsITimer* aTimer) {
}
bool nsHttpChannel::EligibleForTailing() {
if (!(mClassOfService & nsIClassOfService::Tail)) {
if (!(mClassOfService.Flags() & nsIClassOfService::Tail)) {
return false;
}
if (mClassOfService &
if (mClassOfService.Flags() &
(nsIClassOfService::UrgentStart | nsIClassOfService::Leader |
nsIClassOfService::TailForbidden)) {
return false;
}
if (mClassOfService & nsIClassOfService::Unblocked &&
!(mClassOfService & nsIClassOfService::TailAllowed)) {
if (mClassOfService.Flags() & nsIClassOfService::Unblocked &&
!(mClassOfService.Flags() & nsIClassOfService::TailAllowed)) {
return false;
}

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

@ -159,6 +159,8 @@ class nsHttpChannel final : public HttpBaseChannel,
NS_IMETHOD SetClassFlags(uint32_t inFlags) override;
NS_IMETHOD AddClassFlags(uint32_t inFlags) override;
NS_IMETHOD ClearClassFlags(uint32_t inFlags) override;
NS_IMETHOD SetClassOfService(ClassOfServiceStruct cos) override;
NS_IMETHOD SetIncremental(bool incremental) override;
// nsIResumableChannel
NS_IMETHOD ResumeAt(uint64_t startPos, const nsACString& entityID) override;

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

@ -453,7 +453,7 @@ nsresult nsHttpConnection::Activate(nsAHttpTransaction* trans, uint32_t caps,
nsHttpTransaction* hTrans = trans->QueryHttpTransaction();
if (hTrans) {
hTrans->BootstrapTimings(mBootstrappedTimings);
SetUrgentStartPreferred(hTrans->ClassOfService() &
SetUrgentStartPreferred(hTrans->ClassOfService().Flags() &
nsIClassOfService::UrgentStart);
}
}

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

@ -349,14 +349,29 @@ nsresult nsHttpConnectionMgr::RescheduleTransaction(HttpTransactionShell* trans,
}
void nsHttpConnectionMgr::UpdateClassOfServiceOnTransaction(
HttpTransactionShell* trans, uint32_t classOfService) {
HttpTransactionShell* trans, const ClassOfServiceStruct& classOfService) {
LOG(
("nsHttpConnectionMgr::UpdateClassOfServiceOnTransaction [trans=%p "
"classOfService=%" PRIu32 "]\n",
trans, static_cast<uint32_t>(classOfService)));
Unused << PostEvent(
&nsHttpConnectionMgr::OnMsgUpdateClassOfServiceOnTransaction,
static_cast<int32_t>(classOfService), trans->AsHttpTransaction());
"classOfService flags=%" PRIu32 " inc=%d]\n",
trans, static_cast<uint32_t>(classOfService.Flags()),
classOfService.Incremental()));
Unused << EnsureSocketThreadTarget();
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (!mSocketThreadTarget) {
NS_WARNING("cannot post event if not initialized");
}
RefPtr<nsHttpConnectionMgr> self(this);
Unused << mSocketThreadTarget->Dispatch(NS_NewRunnableFunction(
"nsHttpConnectionMgr::CallUpdateClassOfServiceOnTransaction",
[cos{std::move(classOfService)}, self{std::move(self)},
trans{std::move(trans)}]() {
self->OnMsgUpdateClassOfServiceOnTransaction(
cos, trans->AsHttpTransaction());
}));
}
nsresult nsHttpConnectionMgr::CancelTransaction(HttpTransactionShell* trans,
@ -1256,7 +1271,7 @@ nsresult nsHttpConnectionMgr::MakeNewConnection(
nsresult rv = ent->CreateDnsAndConnectSocket(
trans, trans->Caps(), false, false,
trans->ClassOfService() & nsIClassOfService::UrgentStart, true,
trans->ClassOfService().Flags() & nsIClassOfService::UrgentStart, true,
pendingTransInfo);
if (NS_FAILED(rv)) {
/* hard failure */
@ -1440,7 +1455,7 @@ nsresult nsHttpConnectionMgr::TryDispatchTransaction(
// don't respect urgency so that non-urgent transaction will be allowed
// to dispatch on an urgent-start-only marked connection to avoid
// dispatch deadlocks
if (!(trans->ClassOfService() & nsIClassOfService::UrgentStart) &&
if (!(trans->ClassOfService().Flags() & nsIClassOfService::UrgentStart) &&
idleConnsAllUrgent &&
ent->ActiveConnsLength() < MaxPersistConnections(ent)) {
rv = TryDispatchTransactionOnIdleConn(ent, pendingTransInfo, false);
@ -1478,7 +1493,8 @@ nsresult nsHttpConnectionMgr::TryDispatchTransactionOnIdleConn(
bool onlyUrgent = !!ent->IdleConnectionsLength();
nsHttpTransaction* trans = pendingTransInfo->Transaction();
bool urgentTrans = trans->ClassOfService() & nsIClassOfService::UrgentStart;
bool urgentTrans =
trans->ClassOfService().Flags() & nsIClassOfService::UrgentStart;
LOG(
("nsHttpConnectionMgr::TryDispatchTransactionOnIdleConn, ent=%p, "
@ -2051,20 +2067,21 @@ void nsHttpConnectionMgr::OnMsgReschedTransaction(int32_t priority,
}
void nsHttpConnectionMgr::OnMsgUpdateClassOfServiceOnTransaction(
int32_t arg, ARefBase* param) {
ClassOfServiceStruct cos, ARefBase* param) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(
("nsHttpConnectionMgr::OnMsgUpdateClassOfServiceOnTransaction "
"[trans=%p]\n",
param));
uint32_t cos = static_cast<uint32_t>(arg);
nsHttpTransaction* trans = static_cast<nsHttpTransaction*>(param);
uint32_t previous = trans->ClassOfService();
ClassOfServiceStruct previous = trans->ClassOfService();
trans->SetClassOfService(cos);
if ((previous ^ cos) & (NS_HTTP_LOAD_AS_BLOCKING | NS_HTTP_LOAD_UNBLOCKED)) {
// incremental change alone will not trigger a reschedule
if ((previous.Flags() ^ cos.Flags()) &
(NS_HTTP_LOAD_AS_BLOCKING | NS_HTTP_LOAD_UNBLOCKED)) {
Unused << RescheduleTransaction(trans, trans->Priority());
}
}

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

@ -313,7 +313,7 @@ class nsHttpConnectionMgr final : public HttpConnectionMgrShell,
void OnMsgNewTransaction(int32_t, ARefBase*);
void OnMsgNewTransactionWithStickyConn(int32_t, ARefBase*);
void OnMsgReschedTransaction(int32_t, ARefBase*);
void OnMsgUpdateClassOfServiceOnTransaction(int32_t, ARefBase*);
void OnMsgUpdateClassOfServiceOnTransaction(ClassOfServiceStruct, ARefBase*);
void OnMsgCancelTransaction(int32_t, ARefBase*);
void OnMsgCancelTransactions(int32_t, ARefBase*);
void OnMsgProcessPendingQ(int32_t, ARefBase*);

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

@ -2662,7 +2662,7 @@ nsresult nsHttpHandler::RescheduleTransaction(HttpTransactionShell* trans,
}
void nsHttpHandler::UpdateClassOfServiceOnTransaction(
HttpTransactionShell* trans, uint32_t classOfService) {
HttpTransactionShell* trans, const ClassOfServiceStruct& classOfService) {
mConnMgr->UpdateClassOfServiceOnTransaction(trans, classOfService);
}

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

@ -271,8 +271,8 @@ class nsHttpHandler final : public nsIHttpProtocolHandler,
[[nodiscard]] nsresult RescheduleTransaction(HttpTransactionShell* trans,
int32_t priority);
void UpdateClassOfServiceOnTransaction(HttpTransactionShell* trans,
uint32_t classOfService);
void UpdateClassOfServiceOnTransaction(
HttpTransactionShell* trans, const ClassOfServiceStruct& classOfService);
// Called to cancel a transaction, which may or may not be assigned to
// a connection. Callable from any thread.

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

@ -112,19 +112,20 @@ void nsHttpTransaction::ResumeReading() {
}
bool nsHttpTransaction::EligibleForThrottling() const {
return (mClassOfService &
return (mClassOfServiceFlags &
(nsIClassOfService::Throttleable | nsIClassOfService::DontThrottle |
nsIClassOfService::Leader | nsIClassOfService::Unblocked)) ==
nsIClassOfService::Throttleable;
}
void nsHttpTransaction::SetClassOfService(uint32_t cos) {
void nsHttpTransaction::SetClassOfService(ClassOfServiceStruct cos) {
if (mClosed) {
return;
}
bool wasThrottling = EligibleForThrottling();
mClassOfService = cos;
mClassOfServiceFlags = cos.Flags();
mClassOfServiceIncremental = cos.Incremental();
bool isThrottling = EligibleForThrottling();
if (mConnection && wasThrottling != isThrottling) {
@ -205,7 +206,7 @@ nsresult nsHttpTransaction::Init(
bool requestBodyHasHeaders, nsIEventTarget* target,
nsIInterfaceRequestor* callbacks, nsITransportEventSink* eventsink,
uint64_t topBrowsingContextId, HttpTrafficCategory trafficCategory,
nsIRequestContext* requestContext, uint32_t classOfService,
nsIRequestContext* requestContext, ClassOfServiceStruct classOfService,
uint32_t initialRwin, bool responseTimeoutEnabled, uint64_t channelId,
TransactionObserverFunc&& transactionObserver,
OnPushCallback&& aOnPushCallback,
@ -831,7 +832,7 @@ nsresult nsHttpTransaction::WritePipeSegment(nsIOutputStream* stream,
}
bool nsHttpTransaction::ShouldThrottle() {
if (mClassOfService & nsIClassOfService::DontThrottle) {
if (mClassOfServiceFlags & nsIClassOfService::DontThrottle) {
// We deliberately don't touch the throttling window here since
// DontThrottle requests are expected to be long-standing media
// streams and would just unnecessarily block running downloads.
@ -854,7 +855,7 @@ bool nsHttpTransaction::ShouldThrottle() {
return false;
}
if (!(mClassOfService & nsIClassOfService::Throttleable) &&
if (!(mClassOfServiceFlags & nsIClassOfService::Throttleable) &&
gHttpHandler->ConnMgr()->IsConnEntryUnderPressure(mConnInfo)) {
LOG(("nsHttpTransaction::ShouldThrottle entry pressure this=%p", this));
// This is expensive to check (two hashtable lookups) but may help

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

@ -19,6 +19,7 @@
#include "nsITimer.h"
#include "nsIEarlyHintObserver.h"
#include "nsTHashMap.h"
#include "nsIClassOfService.h"
#include "TimingStruct.h"
#include "Http2Push.h"
#include "mozilla/net/DNS.h"
@ -166,7 +167,7 @@ class nsHttpTransaction final : public nsAHttpTransaction,
void UpdateConnectionInfo(nsHttpConnectionInfo* aConnInfo);
void SetClassOfService(uint32_t cos);
void SetClassOfService(ClassOfServiceStruct cos);
virtual nsresult OnHTTPSRRAvailable(
nsIDNSHTTPSSVCRecord* aHTTPSSVCRecord,
@ -485,10 +486,13 @@ class nsHttpTransaction final : public nsAHttpTransaction,
void CollectTelemetryForUploads();
public:
uint32_t ClassOfService() { return mClassOfService; }
ClassOfServiceStruct ClassOfService() {
return {mClassOfServiceFlags, mClassOfServiceIncremental};
}
private:
Atomic<uint32_t, Relaxed> mClassOfService{0};
Atomic<uint32_t, Relaxed> mClassOfServiceFlags{0};
Atomic<bool, Relaxed> mClassOfServiceIncremental{false};
public:
// setting TunnelProvider to non-null means the transaction should only