tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit f4d169b146b345e64e307ceeb408038c42bc5f15
parent 46957145d6fc10e151aa1309d192ed65c2730c0c
Author: Valentin Gosu <valentin.gosu@gmail.com>
Date:   Tue,  9 Dec 2025 14:38:01 +0000

Bug 2003793 - Add priorityHeader marker to profiler r=acreskey,necko-reviewers,kershaw

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

Diffstat:
Mnetwerk/protocol/http/HttpChannelChild.cpp | 16++++++----------
Mnetwerk/protocol/http/InterceptedHttpChannel.cpp | 18+++++++-----------
Mnetwerk/protocol/http/NetworkMarker.cpp | 33++++++++++++++++++++++++++-------
Mnetwerk/protocol/http/NetworkMarker.h | 2+-
Mnetwerk/protocol/http/nsHttpChannel.cpp | 18+++++++-----------
5 files changed, 47 insertions(+), 40 deletions(-)

diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp @@ -996,9 +996,8 @@ void HttpChannelChild::OnStopRequest( mURI, requestMethod, priority, mChannelId, NetworkLoadType::LOAD_STOP, mLastStatusReported, now, mTransferSize, kCacheUnknown, mLoadInfo->GetInnerWindowID(), - mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), - mClassOfService.Flags(), mStatus, &mTransactionTimings, - std::move(mSource), httpVersion, responseStatus, + mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), this, mStatus, + &mTransactionTimings, std::move(mSource), httpVersion, responseStatus, Some(nsDependentCString(contentType.get()))); } @@ -1692,9 +1691,8 @@ void HttpChannelChild::Redirect1Begin( mURI, requestMethod, mPriority, mChannelId, NetworkLoadType::LOAD_REDIRECT, mLastStatusReported, TimeStamp::Now(), 0, kCacheUnknown, mLoadInfo->GetInnerWindowID(), - mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), - mClassOfService.Flags(), mStatus, &mTransactionTimings, - std::move(mSource), Some(responseHead.Version()), + mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), this, mStatus, + &mTransactionTimings, std::move(mSource), Some(responseHead.Version()), Some(responseHead.Status()), Some(nsDependentCString(contentType.get())), newOriginalURI, redirectFlags, channelId); @@ -2017,8 +2015,7 @@ HttpChannelChild::CompleteRedirectSetup(nsIStreamListener* aListener) { mURI, requestMethod, mPriority, mChannelId, NetworkLoadType::LOAD_START, mChannelCreationTimestamp, mLastStatusReported, 0, kCacheUnknown, mLoadInfo->GetInnerWindowID(), - mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), - mClassOfService.Flags(), mStatus); + mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), this, mStatus); } StoreIsPending(true); StoreWasOpened(true); @@ -2379,8 +2376,7 @@ nsresult HttpChannelChild::AsyncOpenInternal(nsIStreamListener* aListener) { mURI, requestMethod, mPriority, mChannelId, NetworkLoadType::LOAD_START, mChannelCreationTimestamp, mLastStatusReported, 0, kCacheUnknown, mLoadInfo->GetInnerWindowID(), - mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), - mClassOfService.Flags(), mStatus); + mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), this, mStatus); } StoreIsPending(true); StoreWasOpened(true); diff --git a/netwerk/protocol/http/InterceptedHttpChannel.cpp b/netwerk/protocol/http/InterceptedHttpChannel.cpp @@ -111,8 +111,7 @@ void InterceptedHttpChannel::AsyncOpenInternal() { mURI, requestMethod, mPriority, mChannelId, NetworkLoadType::LOAD_START, mChannelCreationTimestamp, mLastStatusReported, 0, kCacheUnknown, mLoadInfo->GetInnerWindowID(), - mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), - mClassOfService.Flags(), mStatus); + mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), this, mStatus); } // If an error occurs in this file we must ensure mListener callbacks are @@ -546,9 +545,8 @@ InterceptedHttpChannel::Cancel(nsresult aStatus) { mURI, requestMethod, priority, mChannelId, NetworkLoadType::LOAD_CANCEL, mLastStatusReported, TimeStamp::Now(), size, kCacheUnknown, mLoadInfo->GetInnerWindowID(), - mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), - mClassOfService.Flags(), mStatus, &mTransactionTimings, - std::move(mSource)); + mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), this, mStatus, + &mTransactionTimings, std::move(mSource)); } MOZ_DIAGNOSTIC_ASSERT(NS_FAILED(aStatus)); @@ -780,9 +778,8 @@ InterceptedHttpChannel::ResetInterception(bool aBypass) { mURI, requestMethod, priority, mChannelId, NetworkLoadType::LOAD_REDIRECT, mLastStatusReported, TimeStamp::Now(), size, kCacheUnknown, mLoadInfo->GetInnerWindowID(), - mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), - mClassOfService.Flags(), mStatus, &mTransactionTimings, - std::move(mSource), httpVersion, responseStatus, + mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), this, mStatus, + &mTransactionTimings, std::move(mSource), httpVersion, responseStatus, Some(nsDependentCString(contentType.get())), mURI, flags, newBaseChannel->ChannelId()); } @@ -1230,9 +1227,8 @@ InterceptedHttpChannel::OnStopRequest(nsIRequest* aRequest, nsresult aStatus) { mURI, requestMethod, priority, mChannelId, NetworkLoadType::LOAD_STOP, mLastStatusReported, TimeStamp::Now(), size, kCacheUnknown, mLoadInfo->GetInnerWindowID(), - mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), - mClassOfService.Flags(), mStatus, &mTransactionTimings, - std::move(mSource), httpVersion, responseStatus, + mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), this, mStatus, + &mTransactionTimings, std::move(mSource), httpVersion, responseStatus, Some(nsDependentCString(contentType.get()))); } diff --git a/netwerk/protocol/http/NetworkMarker.cpp b/netwerk/protocol/http/NetworkMarker.cpp @@ -10,6 +10,8 @@ #include "nsIChannelEventSink.h" #include "mozilla/Perfetto.h" #include "mozilla/ErrorNames.h" +#include "nsHttpHandler.h" +#include "nsIClassOfService.h" namespace mozilla::net { struct NetworkMarker { @@ -25,8 +27,8 @@ struct NetworkMarker { bool aIsPrivateBrowsing, const net::TimingStruct& aTimings, const ProfilerString8View& aRedirectURI, const ProfilerString8View& aContentType, uint32_t aRedirectFlags, - int64_t aRedirectChannelId, unsigned long aClassOfServiceFlag, - nsresult aRequestStatus, + int64_t aRedirectChannelId, uint32_t aClassOfServiceFlags, + bool aClassOfServiceIncremental, nsresult aRequestStatus, const mozilla::Maybe<mozilla::net::HttpVersion> aHttpVersion, mozilla::Maybe<uint32_t> aResponseStatus) { // This payload still streams a startTime and endTime property because it @@ -40,12 +42,22 @@ struct NetworkMarker { // Bug 1919148 - Moved aClassOfServiceStr here to ensure that we call // aWriter.StringProperty before the lifetime of nsAutoCString ends nsAutoCString aClassOfServiceStr; - GetClassOfService(aClassOfServiceStr, aClassOfServiceFlag); + GetClassOfService(aClassOfServiceStr, aClassOfServiceFlags); MOZ_ASSERT(aClassOfServiceStr.Length() > 0, "aClassOfServiceStr should be set after GetClassOfService"); aWriter.StringProperty("classOfService", MakeStringSpan(aClassOfServiceStr.get())); + uint8_t urgency = + nsHttpHandler::UrgencyFromCoSFlags(aClassOfServiceFlags, aPri); + nsAutoCString priorityHeader; + priorityHeader.AppendPrintf("u=%d", urgency); + if (aClassOfServiceIncremental) { + priorityHeader.Append(", i"); + } + aWriter.StringProperty("priorityHeader", + MakeStringSpan(priorityHeader.get())); + nsAutoCString aRequestStatusStr; GetErrorName(aRequestStatus, aRequestStatusStr); aWriter.StringProperty("requestStatus", @@ -165,7 +177,7 @@ struct NetworkMarker { // Update an empty string aClassOfServiceStr based on aClassOfServiceFlag static void GetClassOfService(nsAutoCString& aClassOfServiceStr, - unsigned long aClassOfServiceFlag) { + uint32_t aClassOfServiceFlag) { MOZ_ASSERT(aClassOfServiceStr.IsEmpty(), "Flags should not be appended to aClassOfServiceStr before " "calling GetClassOfService"); @@ -389,7 +401,7 @@ void profiler_add_network_marker( mozilla::TimeStamp aEnd, int64_t aCount, nsICacheInfoChannel::CacheDisposition aCacheDisposition, uint64_t aInnerWindowID, bool aIsPrivateBrowsing, - unsigned long aClassOfServiceFlag, nsresult aRequestStatus, + nsIClassOfService* aClassOfService, nsresult aRequestStatus, const mozilla::net::TimingStruct* aTimings, UniquePtr<ProfileChunkedBuffer> aSource, const Maybe<mozilla::net::HttpVersion> aHttpVersion, @@ -418,6 +430,13 @@ void profiler_add_network_marker( aRedirectURI->GetAsciiSpec(redirect_spec); } + uint32_t classOfServiceFlags = 0; + bool classOfServiceIncremental = false; + if (aClassOfService) { + aClassOfService->GetClassFlags(&classOfServiceFlags); + aClassOfService->GetIncremental(&classOfServiceIncremental); + } + profiler_add_marker( name, geckoprofiler::category::NETWORK, {MarkerTiming::Interval(aStart, aEnd), @@ -428,7 +447,7 @@ void profiler_add_network_marker( aIsPrivateBrowsing, aTimings ? *aTimings : scEmptyNetTimingStruct, redirect_spec, aContentType ? ProfilerString8View(*aContentType) : ProfilerString8View(), - aRedirectFlags, aRedirectChannelId, aClassOfServiceFlag, aRequestStatus, - aHttpVersion, aResponseStatus); + aRedirectFlags, aRedirectChannelId, classOfServiceFlags, + classOfServiceIncremental, aRequestStatus, aHttpVersion, aResponseStatus); } } // namespace mozilla::net diff --git a/netwerk/protocol/http/NetworkMarker.h b/netwerk/protocol/http/NetworkMarker.h @@ -30,7 +30,7 @@ void profiler_add_network_marker( mozilla::TimeStamp aEnd, int64_t aCount, nsICacheInfoChannel::CacheDisposition aCacheDisposition, uint64_t aInnerWindowID, bool aIsPrivateBrowsing, - unsigned long aClassOfServiceFlag, nsresult aRequestStatus, + nsIClassOfService* aClassOfService, nsresult aRequestStatus, const mozilla::net::TimingStruct* aTimings = nullptr, mozilla::UniquePtr<mozilla::ProfileChunkedBuffer> aSource = nullptr, const mozilla::Maybe<mozilla::net::HttpVersion> aHttpVersion = diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp @@ -6474,9 +6474,8 @@ nsresult nsHttpChannel::SetupReplacementChannel(nsIURI* newURI, mURI, requestMethod, priority, mChannelId, NetworkLoadType::LOAD_REDIRECT, mLastStatusReported, TimeStamp::Now(), size, mCacheDisposition, mLoadInfo->GetInnerWindowID(), - mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), - mClassOfService.Flags(), mStatus, &timings, std::move(mSource), - httpVersion, responseStatus, + mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), this, mStatus, + &timings, std::move(mSource), httpVersion, responseStatus, Some(nsDependentCString(contentType.get())), newURI, redirectFlags, channelId); } @@ -7145,9 +7144,8 @@ nsresult nsHttpChannel::CancelInternal(nsresult status) { mURI, requestMethod, priority, mChannelId, NetworkLoadType::LOAD_CANCEL, mLastStatusReported, TimeStamp::Now(), size, mCacheDisposition, mLoadInfo->GetInnerWindowID(), - mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), - mClassOfService.Flags(), mStatus, &mTransactionTimings, - std::move(mSource)); + mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), this, mStatus, + &mTransactionTimings, std::move(mSource)); } // If we don't have mTransactionPump and mCachePump, we need to call @@ -7538,8 +7536,7 @@ void nsHttpChannel::AsyncOpenFinal(TimeStamp aTimeStamp) { mURI, requestMethod, mPriority, mChannelId, NetworkLoadType::LOAD_START, mChannelCreationTimestamp, mLastStatusReported, 0, mCacheDisposition, mLoadInfo->GetInnerWindowID(), - mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), - mClassOfService.Flags(), mStatus); + mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), this, mStatus); } // Added due to PauseTask/DelayHttpChannel @@ -10279,9 +10276,8 @@ nsresult nsHttpChannel::ContinueOnStopRequest(nsresult aStatus, bool aIsFromNet, mURI, requestMethod, priority, mChannelId, NetworkLoadType::LOAD_STOP, mLastStatusReported, TimeStamp::Now(), size, mCacheDisposition, mLoadInfo->GetInnerWindowID(), - mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), - mClassOfService.Flags(), mStatus, &mTransactionTimings, - std::move(mSource), httpVersion, responseStatus, + mLoadInfo->GetOriginAttributes().IsPrivateBrowsing(), this, mStatus, + &mTransactionTimings, std::move(mSource), httpVersion, responseStatus, Some(nsDependentCString(contentType.get()))); }