From 8c9cb764ad65be0e4060a35305c0556c2abc2ffb Mon Sep 17 00:00:00 2001 From: Kershaw Chang Date: Wed, 2 Aug 2023 09:03:57 +0000 Subject: [PATCH] Bug 1791027 - Support transaction pending time for socket process, r=necko-reviewers,jesup Differential Revision: https://phabricator.services.mozilla.com/D185056 --- netwerk/ipc/NeckoChannelParams.ipdlh | 1 + netwerk/protocol/http/HttpBaseChannel.cpp | 2 +- netwerk/protocol/http/HttpBaseChannel.h | 1 - netwerk/protocol/http/HttpChannelChild.cpp | 1 + netwerk/protocol/http/HttpTransactionChild.cpp | 3 +++ netwerk/protocol/http/HttpTransactionParent.cpp | 4 ++-- netwerk/protocol/http/TimingStruct.h | 4 +--- netwerk/protocol/http/nsHttpChannel.cpp | 3 +-- netwerk/protocol/http/nsHttpTransaction.h | 15 +++++++-------- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/netwerk/ipc/NeckoChannelParams.ipdlh b/netwerk/ipc/NeckoChannelParams.ipdlh index a26f68aad263d..40ed9de5dabd6 100644 --- a/netwerk/ipc/NeckoChannelParams.ipdlh +++ b/netwerk/ipc/NeckoChannelParams.ipdlh @@ -509,6 +509,7 @@ struct TimingStructArgs { TimeStamp requestStart; TimeStamp responseStart; TimeStamp responseEnd; + TimeStamp transactionPending; }; struct ResourceTimingStructArgs { diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 9d949b756a79f..3dec86b4a1480 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -5534,7 +5534,7 @@ HttpBaseChannel::GetCacheReadEnd(TimeStamp* _retval) { NS_IMETHODIMP HttpBaseChannel::GetTransactionPending(TimeStamp* _retval) { - *_retval = mTransactionPendingTime; + *_retval = mTransactionTimings.transactionPending; return NS_OK; } diff --git a/netwerk/protocol/http/HttpBaseChannel.h b/netwerk/protocol/http/HttpBaseChannel.h index 8286cf4c4d646..3ae025fa81746 100644 --- a/netwerk/protocol/http/HttpBaseChannel.h +++ b/netwerk/protocol/http/HttpBaseChannel.h @@ -772,7 +772,6 @@ class HttpBaseChannel : public nsHashPropertyBag, TimeStamp mAsyncOpenTime; TimeStamp mCacheReadStart; TimeStamp mCacheReadEnd; - TimeStamp mTransactionPendingTime; TimeStamp mLaunchServiceWorkerStart; TimeStamp mLaunchServiceWorkerEnd; TimeStamp mDispatchFetchEventStart; diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index 69b71a5eb910b..6f583ba99ec21 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -388,6 +388,7 @@ static void ResourceTimingStructArgsToTimingsStruct( aTimings.requestStart = aArgs.requestStart(); aTimings.responseStart = aArgs.responseStart(); aTimings.responseEnd = aArgs.responseEnd(); + aTimings.transactionPending = aArgs.transactionPending(); } void HttpChannelChild::OnStartRequest( diff --git a/netwerk/protocol/http/HttpTransactionChild.cpp b/netwerk/protocol/http/HttpTransactionChild.cpp index eb0ef7910a238..127d55eb9e3f7 100644 --- a/netwerk/protocol/http/HttpTransactionChild.cpp +++ b/netwerk/protocol/http/HttpTransactionChild.cpp @@ -344,6 +344,7 @@ static TimingStructArgs ToTimingStructArgs(TimingStruct aTiming) { args.requestStart() = aTiming.requestStart; args.responseStart() = aTiming.responseStart; args.responseEnd() = aTiming.responseEnd; + args.transactionPending() = aTiming.transactionPending; return args; } @@ -509,6 +510,8 @@ ResourceTimingStructArgs HttpTransactionChild::GetTimingAttributes() { args.encodedBodySize() = mLogicalOffset; args.redirectStart() = mRedirectStart; args.redirectEnd() = mRedirectEnd; + args.transferSize() = mTransaction->GetTransferSize(); + args.transactionPending() = mTransaction->GetPendingTime(); return args; } diff --git a/netwerk/protocol/http/HttpTransactionParent.cpp b/netwerk/protocol/http/HttpTransactionParent.cpp index f25c80dc6f2d7..d577b63834f8f 100644 --- a/netwerk/protocol/http/HttpTransactionParent.cpp +++ b/netwerk/protocol/http/HttpTransactionParent.cpp @@ -447,6 +447,7 @@ static void TimingStructArgsToTimingsStruct(const TimingStructArgs& aArgs, aTimings.requestStart = aArgs.requestStart(); aTimings.responseStart = aArgs.responseStart(); aTimings.responseEnd = aArgs.responseEnd(); + aTimings.transactionPending = aArgs.transactionPending(); } void HttpTransactionParent::DoOnStartRequest( @@ -907,9 +908,8 @@ void HttpTransactionParent::SetIsForWebTransport(bool SetIsForWebTransport) { // TODO: bug 1791727 } -// We will need to support this in the socket process (See Bug 1791027) mozilla::TimeStamp HttpTransactionParent::GetPendingTime() { - return TimeStamp::Now(); + return mTimings.transactionPending; } } // namespace mozilla::net diff --git a/netwerk/protocol/http/TimingStruct.h b/netwerk/protocol/http/TimingStruct.h index ab788be6d60db..74645e2bffe91 100644 --- a/netwerk/protocol/http/TimingStruct.h +++ b/netwerk/protocol/http/TimingStruct.h @@ -21,6 +21,7 @@ struct TimingStruct { TimeStamp requestStart; TimeStamp responseStart; TimeStamp responseEnd; + TimeStamp transactionPending; }; struct ResourceTimingStruct : TimingStruct { @@ -29,15 +30,12 @@ struct ResourceTimingStruct : TimingStruct { TimeStamp redirectEnd; uint64_t transferSize; uint64_t encodedBodySize; - nsCString protocolVersion; // Not actually part of resource timing, but not part of the transaction // timings either. These need to be passed to HttpChannelChild along with // the rest of the timings so the timing information in the child is complete. TimeStamp cacheReadStart; TimeStamp cacheReadEnd; - - TimeStamp connectionPending; }; } // namespace net diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 28373adca079e..185950e97d6a4 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -6881,7 +6881,7 @@ nsHttpChannel::GetTransactionPending(TimeStamp* _retval) { if (mTransaction) { *_retval = mTransaction->GetPendingTime(); } else { - *_retval = mTransactionPendingTime; + *_retval = mTransactionTimings.transactionPending; } return NS_OK; } @@ -7561,7 +7561,6 @@ nsHttpChannel::OnStopRequest(nsIRequest* request, nsresult status) { // at this point, we're done with the transaction mTransactionTimings = mTransaction->Timings(); - mTransactionPendingTime = mTransaction->GetPendingTime(); mTransaction = nullptr; mTransactionPump = nullptr; diff --git a/netwerk/protocol/http/nsHttpTransaction.h b/netwerk/protocol/http/nsHttpTransaction.h index 364fa7b1e6040..db0c1ea136fa5 100644 --- a/netwerk/protocol/http/nsHttpTransaction.h +++ b/netwerk/protocol/http/nsHttpTransaction.h @@ -107,26 +107,26 @@ class nsHttpTransaction final : public nsAHttpTransaction, void PrintDiagnostics(nsCString& log); - // Sets mPendingTime to the current time stamp or to a null time stamp (if now - // is false) + // Sets mTimings.transactionPending to the current time stamp or to a null + // time stamp (if now is false) void SetPendingTime(bool now = true) { mozilla::MutexAutoLock lock(mLock); - if (!now && !mPendingTime.IsNull()) { + if (!now && !mTimings.transactionPending.IsNull()) { // Remember how long it took. We will use this value to record // TRANSACTION_WAIT_TIME_HTTP2_SUP_HTTP3 telemetry, but we need to wait // for the response headers. - mPendingDurationTime = TimeStamp::Now() - mPendingTime; + mPendingDurationTime = TimeStamp::Now() - mTimings.transactionPending; } // Note that the transaction could be added in to a pending queue multiple // times (when the transaction is restarted or moved to a new conn entry due // to HTTPS RR), so we should only set the pending time once. - if (mPendingTime.IsNull()) { - mPendingTime = now ? TimeStamp::Now() : TimeStamp(); + if (mTimings.transactionPending.IsNull()) { + mTimings.transactionPending = now ? TimeStamp::Now() : TimeStamp(); } } TimeStamp GetPendingTime() override { mozilla::MutexAutoLock lock(mLock); - return mPendingTime; + return mTimings.transactionPending; } // overload of nsAHttpTransaction::RequestContext() @@ -477,7 +477,6 @@ class nsHttpTransaction final : public nsAHttpTransaction, Atomic mRestarted{false}; // The time when the transaction was submitted to the Connection Manager - TimeStamp mPendingTime; TimeDuration mPendingDurationTime; uint64_t mBrowserId{0};