Last active
October 15, 2025 15:35
-
-
Save jrmuizel/7e8475161bd7af87928434a61fbe5da5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| commit d38a61ab87acab9c1e379cfe952082c22da08d55 | |
| Author: Jeff Muizelaar <jmuizelaar@mozilla.com> | |
| Date: Fri Nov 15 09:57:49 2024 +0100 | |
| trr channel annotation | |
| diff --git a/netwerk/protocol/http/TRRServiceChannel.cpp b/netwerk/protocol/http/TRRServiceChannel.cpp | |
| index 85e6d299e869f..dd4335149aa2e 100644 | |
| --- a/netwerk/protocol/http/TRRServiceChannel.cpp | |
| +++ b/netwerk/protocol/http/TRRServiceChannel.cpp | |
| @@ -4,20 +4,21 @@ | |
| /* 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/. */ | |
| #include "TRRServiceChannel.h" | |
| #include "HttpLog.h" | |
| #include "AltServiceChild.h" | |
| #include "mozilla/glean/NetwerkMetrics.h" | |
| #include "mozilla/glean/NetwerkProtocolHttpMetrics.h" | |
| +#include "mozilla/FlowMarkers.h" | |
| #include "mozilla/ScopeExit.h" | |
| #include "mozilla/StaticPrefs_network.h" | |
| #include "mozilla/Unused.h" | |
| #include "nsDNSPrefetch.h" | |
| #include "nsEscape.h" | |
| #include "nsHttpTransaction.h" | |
| #include "nsICancelable.h" | |
| #include "nsICachingChannel.h" | |
| #include "nsIProtocolProxyService2.h" | |
| #include "nsIOService.h" | |
| @@ -86,24 +87,37 @@ NS_INTERFACE_MAP_BEGIN(TRRServiceChannel) | |
| NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) | |
| NS_INTERFACE_MAP_ENTRY(nsIUploadChannel2) | |
| NS_INTERFACE_MAP_ENTRY_CONCRETE(TRRServiceChannel) | |
| NS_INTERFACE_MAP_END_INHERITING(HttpBaseChannel) | |
| TRRServiceChannel::TRRServiceChannel() | |
| : HttpAsyncAborter<TRRServiceChannel>(this), | |
| mProxyRequest(nullptr, "TRRServiceChannel::mProxyRequest"), | |
| mCurrentEventTarget(GetCurrentSerialEventTarget()) { | |
| LOG(("TRRServiceChannel ctor [this=%p]\n", this)); | |
| + profiler_add_marker( | |
| + mozilla::ProfilerString8View::WrapNullTerminatedString("TRRServiceChannel"), | |
| + mozilla::baseprofiler::category::NETWORK, | |
| + {mozilla::MarkerTiming::InstantNow(), | |
| + }, | |
| + FlowMarker{}, Flow::FromPointer(this)); | |
| + | |
| } | |
| TRRServiceChannel::~TRRServiceChannel() { | |
| LOG(("TRRServiceChannel dtor [this=%p]\n", this)); | |
| + profiler_add_marker( | |
| + mozilla::ProfilerString8View::WrapNullTerminatedString("~TRRServiceChannel"), | |
| + mozilla::baseprofiler::category::NETWORK, | |
| + {mozilla::MarkerTiming::InstantNow(), | |
| + }, | |
| + TerminatingFlowMarker{}, Flow::FromPointer(this)); | |
| } | |
| NS_IMETHODIMP TRRServiceChannel::SetCanceledReason(const nsACString& aReason) { | |
| return SetCanceledReasonImpl(aReason); | |
| } | |
| NS_IMETHODIMP TRRServiceChannel::GetCanceledReason(nsACString& aReason) { | |
| return GetCanceledReasonImpl(aReason); | |
| } | |
| @@ -899,21 +913,21 @@ void TRRServiceChannel::ProcessAltService( | |
| NS_DispatchToMainThread(NS_NewRunnableFunction( | |
| "TRRServiceChannel::ProcessAltService", std::move(processHeaderTask))); | |
| } | |
| NS_IMETHODIMP | |
| TRRServiceChannel::OnStartRequest(nsIRequest* request) { | |
| LOG(("TRRServiceChannel::OnStartRequest [this=%p request=%p status=%" PRIx32 | |
| "]\n", | |
| this, request, static_cast<uint32_t>(static_cast<nsresult>(mStatus)))); | |
| - | |
| + AUTO_PROFILER_FLOW_MARKER("TRRServiceChannel::OnStartRequest", NETWORK, Flow::FromPointer(this)); | |
| if (!(mCanceled || NS_FAILED(mStatus))) { | |
| // capture the request's status, so our consumers will know ASAP of any | |
| // connection failures, etc - bug 93581 | |
| nsresult status; | |
| request->GetStatus(&status); | |
| mStatus = status; | |
| } | |
| MOZ_ASSERT(request == mTransactionPump, "Unexpected request"); | |
| @@ -1101,20 +1115,21 @@ nsresult TRRServiceChannel::SetupReplacementChannel(nsIURI* aNewURI, | |
| mRequestHead.ParsedMethod() == nsHttpRequestHead::kMethod_Get, | |
| mContentTypeHint); | |
| } | |
| NS_IMETHODIMP | |
| TRRServiceChannel::OnDataAvailable(nsIRequest* request, nsIInputStream* input, | |
| uint64_t offset, uint32_t count) { | |
| LOG(("TRRServiceChannel::OnDataAvailable [this=%p request=%p offset=%" PRIu64 | |
| " count=%" PRIu32 "]\n", | |
| this, request, offset, count)); | |
| + AUTO_PROFILER_FLOW_MARKER("TRRServiceChannel::OnDataAvailable", NETWORK, Flow::FromPointer(this)); | |
| // don't send out OnDataAvailable notifications if we've been canceled. | |
| if (mCanceled) return mStatus; | |
| MOZ_ASSERT(mResponseHead, "No response head in ODA!!"); | |
| if (mListener) { | |
| return mListener->OnDataAvailable(this, input, offset, count); | |
| } | |
| @@ -1210,20 +1225,21 @@ static void TelemetryReport(nsITimedChannel* aTimedChannel, | |
| } | |
| glean::networking::trr_request_size.Get(key).Accumulate(aRequestSize); | |
| glean::networking::trr_response_size.Get(key).Accumulate(aTransferSize); | |
| } | |
| NS_IMETHODIMP | |
| TRRServiceChannel::OnStopRequest(nsIRequest* request, nsresult status) { | |
| LOG(("TRRServiceChannel::OnStopRequest [this=%p request=%p status=%" PRIx32 | |
| "]\n", | |
| this, request, static_cast<uint32_t>(status))); | |
| + AUTO_PROFILER_FLOW_MARKER("TRRServiceChannel::OnStopRequest", NETWORK, Flow::FromPointer(this)); | |
| if (mCanceled || NS_FAILED(mStatus)) status = mStatus; | |
| mTransactionTimings = mTransaction->Timings(); | |
| mRequestSize = mTransaction->GetRequestSize(); | |
| mTransferSize = mTransaction->GetTransferSize(); | |
| mTransaction = nullptr; | |
| mTransactionPump = nullptr; | |
| if (mListener) { | |
| @@ -1251,20 +1267,21 @@ TRRServiceChannel::OnStopRequest(nsIRequest* request, nsresult status) { | |
| NS_IMETHODIMP | |
| TRRServiceChannel::OnLookupComplete(nsICancelable* request, nsIDNSRecord* rec, | |
| nsresult status) { | |
| LOG( | |
| ("TRRServiceChannel::OnLookupComplete [this=%p] prefetch complete%s: " | |
| "%s status[0x%" PRIx32 "]\n", | |
| this, mCaps & NS_HTTP_REFRESH_DNS ? ", refresh requested" : "", | |
| NS_SUCCEEDED(status) ? "success" : "failure", | |
| static_cast<uint32_t>(status))); | |
| + AUTO_PROFILER_FLOW_MARKER("TRRServiceChannel::OnLookupComplete", NETWORK, Flow::FromPointer(this)); | |
| // We no longer need the dns prefetch object. Note: mDNSPrefetch could be | |
| // validly null if OnStopRequest has already been called. | |
| // We only need the domainLookup timestamps when not loading from cache | |
| if (mDNSPrefetch && mDNSPrefetch->TimingsValid() && mTransaction) { | |
| TimeStamp connectStart = mTransaction->GetConnectStart(); | |
| TimeStamp requestStart = mTransaction->GetRequestStart(); | |
| // We only set the domainLookup timestamps if we're not using a | |
| // persistent connection. | |
| if (requestStart.IsNull() && connectStart.IsNull()) { | |
| mTransaction->SetDomainLookupStart(mDNSPrefetch->StartTimestamp()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment