Skip to content

Commit

Permalink
Bug 1791027 - Support transaction pending time for socket process, r=…
Browse files Browse the repository at this point in the history
…necko-reviewers,jesup

Differential Revision: https://phabricator.services.mozilla.com/D185056
  • Loading branch information
KershawChang committed Aug 2, 2023
1 parent 48036af commit 8c9cb76
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
1 change: 1 addition & 0 deletions netwerk/ipc/NeckoChannelParams.ipdlh
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ struct TimingStructArgs {
TimeStamp requestStart;
TimeStamp responseStart;
TimeStamp responseEnd;
TimeStamp transactionPending;
};

struct ResourceTimingStructArgs {
Expand Down
2 changes: 1 addition & 1 deletion netwerk/protocol/http/HttpBaseChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5534,7 +5534,7 @@ HttpBaseChannel::GetCacheReadEnd(TimeStamp* _retval) {

NS_IMETHODIMP
HttpBaseChannel::GetTransactionPending(TimeStamp* _retval) {
*_retval = mTransactionPendingTime;
*_retval = mTransactionTimings.transactionPending;
return NS_OK;
}

Expand Down
1 change: 0 additions & 1 deletion netwerk/protocol/http/HttpBaseChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,6 @@ class HttpBaseChannel : public nsHashPropertyBag,
TimeStamp mAsyncOpenTime;
TimeStamp mCacheReadStart;
TimeStamp mCacheReadEnd;
TimeStamp mTransactionPendingTime;
TimeStamp mLaunchServiceWorkerStart;
TimeStamp mLaunchServiceWorkerEnd;
TimeStamp mDispatchFetchEventStart;
Expand Down
1 change: 1 addition & 0 deletions netwerk/protocol/http/HttpChannelChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions netwerk/protocol/http/HttpTransactionChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions netwerk/protocol/http/HttpTransactionParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
4 changes: 1 addition & 3 deletions netwerk/protocol/http/TimingStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct TimingStruct {
TimeStamp requestStart;
TimeStamp responseStart;
TimeStamp responseEnd;
TimeStamp transactionPending;
};

struct ResourceTimingStruct : TimingStruct {
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions netwerk/protocol/http/nsHttpChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6881,7 +6881,7 @@ nsHttpChannel::GetTransactionPending(TimeStamp* _retval) {
if (mTransaction) {
*_retval = mTransaction->GetPendingTime();
} else {
*_retval = mTransactionPendingTime;
*_retval = mTransactionTimings.transactionPending;
}
return NS_OK;
}
Expand Down Expand Up @@ -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;

Expand Down
15 changes: 7 additions & 8 deletions netwerk/protocol/http/nsHttpTransaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -477,7 +477,6 @@ class nsHttpTransaction final : public nsAHttpTransaction,
Atomic<bool> mRestarted{false};

// The time when the transaction was submitted to the Connection Manager
TimeStamp mPendingTime;
TimeDuration mPendingDurationTime;

uint64_t mBrowserId{0};
Expand Down

0 comments on commit 8c9cb76

Please sign in to comment.